Skip to content

docs: Document smart-fallback streaming behavior for sync chat (fixes #484)#487

Merged
MervinPraison merged 1 commit into
mainfrom
claude/issue-484-20260602-1859
Jun 3, 2026
Merged

docs: Document smart-fallback streaming behavior for sync chat (fixes #484)#487
MervinPraison merged 1 commit into
mainfrom
claude/issue-484-20260602-1859

Conversation

@MervinPraison
Copy link
Copy Markdown
Owner

@MervinPraison MervinPraison commented Jun 2, 2026

Summary

This PR documents the smart-fallback streaming behavior introduced in PraisonAI PR #1734 to fix Issue #1733.

Changes

Updated docs/features/streaming.mdx:

Quick Start leads with auto-detect example - Shows the new default stream=None behavior
Expanded Streaming vs Non-Streaming table - Includes three modes: None (default), True, False
Added Sync vs Async Adapters callout - Explains async vs sync streaming behavior differences
Updated Troubleshooting section - Added entry for Streaming is not supported in sync OpenAIAdapter error
Enhanced Best Practices - Recommends letting SDK pick streaming mode automatically
Updated method comparison table - Highlights auto-detect as the recommended approach

Key Changes

Smart fallback behavior (sync only): When stream=None (new default), the SDK tries streaming first. If the adapter raises ValueError(Streaming is not supported...), it logs debug and retries with stream=False.

Behavior matrix:

  • stream=True (explicit): Streams or raises error
  • stream=False (explicit): Non-streaming
  • stream=None (default, NEW): Auto-falls-back to non-streaming, no error
  • Async path: Still defaults to stream=True (unchanged)

References

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added quick-start example for automatic streaming detection
    • Clarified streaming method recommendations and auto-detection behavior
    • Expanded guidance on streaming vs non-streaming with fallback semantics
    • Added best practices section on letting SDK pick streaming mode
    • Updated troubleshooting with version-specific fixes and upgrade guidance

- Add auto-detect (Default) subsection showing stream=None default
- Expand Streaming vs Non-Streaming table to include three modes
- Add Sync vs Async Adapters callout explaining behavior differences
- Update Troubleshooting section with Deepseek crash fix entry
- Update Best Practices with recommendation to let SDK pick mode
- Update method table to highlight auto-detect as recommended approach

Fixes #484

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Updated docs/features/streaming.mdx to document the SDK's new smart-fallback streaming behavior: added an auto-detect quick-start example, marked start() as recommended, expanded mode-comparison guidance to include stream=None default behavior, clarified sync vs async adapter differences, added best-practice guidance to omit the stream argument, and updated troubleshooting with the fixed-in version (PraisonAI 4.6.47+).

Changes

Streaming Defaults and Smart-Fallback Documentation

Layer / File(s) Summary
Quick start and method guidance
docs/features/streaming.mdx
Added "Auto-detect (Default)" quick-start example showing minimal pattern without stream argument and SDK's silent fallback behavior. Updated method comparison table to mark start() as "Recommended — works everywhere" with auto-detection semantics.
Streaming modes and adapter differences
docs/features/streaming.mdx
Expanded "Streaming vs Non-Streaming" table to define three modes: stream=None (default smart-fallback), stream=True (force streaming), and stream=False (force non-streaming). Added note explaining sync vs async adapter differences and when fallback occurs.
Best practices and troubleshooting
docs/features/streaming.mdx
Added best-practices accordion entry recommending users omit stream argument to let SDK pick mode. Updated troubleshooting for "Streaming is not supported in sync OpenAIAdapter" with fixed-in version (PraisonAI 4.6.47+) and upgrade/stream=False guidance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through docs with glee,
Auto-detect now sets adapters free!
No crashes on Deepseek, no streaming fuss—
The SDK picks what works for us.
Stream or not, the SDK knows best,
Smart fallback puts minds to rest! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs: Document smart-fallback streaming behavior for sync chat (fixes #484)' is fully related to the main change, clearly summarizing the documentation update for streaming behavior.
Linked Issues check ✅ Passed The PR addresses all primary objectives from Issue #484: documenting smart-fallback behavior, adding auto-detect example, updating streaming table, adding sync-vs-async callout, updating troubleshooting, and enhancing best practices.
Out of Scope Changes check ✅ Passed All changes are within scope—only docs/features/streaming.mdx was modified; no edits to docs/concepts/ or unrelated files occurred, aligning with the PR's stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-484-20260602-1859

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the streaming documentation to explain the new auto-detect streaming behavior, which automatically falls back to non-streaming if a provider's sync client does not support it. It updates the comparison tables, adds a best practices section, and includes troubleshooting steps for sync adapter crashes. The feedback suggests removing the internal method _execute_unified_achat_completion from the user-facing documentation to avoid exposing implementation details.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

| `stream=False` | Force non-streaming | Batch jobs, structured output, sync providers |

<Note>
**Sync vs Async Adapters**: Async methods (`achat`, `astart`, `_execute_unified_achat_completion`) still default to `stream=True` because async adapters universally support streaming. Sync methods (`chat`, `start`, `run`) use the new smart-fallback default. Some adapters (e.g., sync OpenAI/Deepseek adapter) currently do NOT support sync streaming and will trigger the fallback.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The internal/private method _execute_unified_achat_completion is documented alongside public async methods like achat and astart. Since it is an internal implementation detail, it should not be exposed in user-facing documentation. Please remove it from the list of async methods.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/features/streaming.mdx (1)

354-356: ⚡ Quick win

Consider removing internal method reference from user-facing docs.

Line 355 mentions _execute_unified_achat_completion (leading underscore = private/internal method) in the async methods list. Exposing internal method names in user documentation can confuse users who search for it in public API docs and may constrain future refactoring.

Users interact with achat() and astart()—the internal implementation detail doesn't help them use the feature.

📝 Proposed simplification
-**Sync vs Async Adapters**: Async methods (`achat`, `astart`, `_execute_unified_achat_completion`) still default to `stream=True` because async adapters universally support streaming. Sync methods (`chat`, `start`, `run`) use the new smart-fallback default. Some adapters (e.g., sync OpenAI/Deepseek adapter) currently do NOT support sync streaming and will trigger the fallback.
+**Sync vs Async Adapters**: Async methods (`achat`, `astart`) still default to `stream=True` because async adapters universally support streaming. Sync methods (`chat`, `start`, `run`) use the new smart-fallback default. Some adapters (e.g., sync OpenAI/Deepseek adapter) currently do NOT support sync streaming and will trigger the fallback.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/features/streaming.mdx` around lines 354 - 356, Remove the internal
method reference from the docs: replace the mention of the private method
`_execute_unified_achat_completion` with the public async APIs `achat()` and
`astart()` (and keep the note that async methods default to stream=True), so
users only see public symbols (`achat`, `astart`) and the sync counterparts
(`chat`, `start`, `run`) when describing streaming behavior; this avoids
exposing private implementation details and prevents coupling docs to
`_execute_unified_achat_completion`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/features/streaming.mdx`:
- Around line 354-356: Update the note so it no longer claims "async adapters
universally support streaming" and instead explains that async methods (`achat`,
`astart`, `_execute_unified_achat_completion`) default to `stream=True` only
when the adapter reports streaming capability; document that sync methods
(`chat`, `start`, `run`) use the smart-fallback default and that the runtime
uses capability checks and provider-specific disablements to trigger fallback
(e.g., Anthropic streaming disabled due to a litellm bug, Gemini disables
streaming when `tools` are present, and Ollama streaming is unreliable with
tools); replace the universal claim with language emphasizing capability-based
fallback and list those provider-specific exceptions so readers understand when
streaming may be disabled.

---

Nitpick comments:
In `@docs/features/streaming.mdx`:
- Around line 354-356: Remove the internal method reference from the docs:
replace the mention of the private method `_execute_unified_achat_completion`
with the public async APIs `achat()` and `astart()` (and keep the note that
async methods default to stream=True), so users only see public symbols
(`achat`, `astart`) and the sync counterparts (`chat`, `start`, `run`) when
describing streaming behavior; this avoids exposing private implementation
details and prevents coupling docs to `_execute_unified_achat_completion`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6f1e1c52-15c8-43a8-aa4a-21176d10cd2c

📥 Commits

Reviewing files that changed from the base of the PR and between aa7ace5 and 0af2c35.

📒 Files selected for processing (1)
  • docs/features/streaming.mdx

Comment on lines +354 to +356
<Note>
**Sync vs Async Adapters**: Async methods (`achat`, `astart`, `_execute_unified_achat_completion`) still default to `stream=True` because async adapters universally support streaming. Sync methods (`chat`, `start`, `run`) use the new smart-fallback default. Some adapters (e.g., sync OpenAI/Deepseek adapter) currently do NOT support sync streaming and will trigger the fallback.
</Note>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for async adapter implementations to confirm streaming support

# Find async adapter class definitions and check for streaming-related NotImplementedError or exceptions
rg -nP -A10 'class\s+\w*Adapter.*:' --type=py -g '!*test*' | rg -C3 'async.*chat|achat|streaming'

# Search for any documentation or comments indicating async streaming limitations
rg -nP 'async.*stream.*not.*support|async.*adapter.*stream.*unsupport' --type=py --type=md

Repository: MervinPraison/PraisonAIDocs

Length of output: 6991


Fix the streaming docs: async adapters aren’t universally streaming-capable (qualify the claim).
docs/features/streaming.mdx lines 354-356 say “async adapters universally support streaming,” but the adapter capability logic includes provider-specific disablement (e.g., Anthropic streaming disabled due to a litellm bug; Gemini streaming disabled when tools are present; Ollama streaming with tools is unreliable). Update the note to describe capability-based fallback rather than universal async streaming support.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/features/streaming.mdx` around lines 354 - 356, Update the note so it no
longer claims "async adapters universally support streaming" and instead
explains that async methods (`achat`, `astart`,
`_execute_unified_achat_completion`) default to `stream=True` only when the
adapter reports streaming capability; document that sync methods (`chat`,
`start`, `run`) use the smart-fallback default and that the runtime uses
capability checks and provider-specific disablements to trigger fallback (e.g.,
Anthropic streaming disabled due to a litellm bug, Gemini disables streaming
when `tools` are present, and Ollama streaming is unreliable with tools);
replace the universal claim with language emphasizing capability-based fallback
and list those provider-specific exceptions so readers understand when streaming
may be disabled.

@MervinPraison MervinPraison merged commit 57e7f18 into main Jun 3, 2026
28 checks passed
@MervinPraison MervinPraison deleted the claude/issue-484-20260602-1859 branch June 3, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs] Document smart-fallback streaming behavior for sync chat (PR #1734, Issue #1733)

1 participant