fix: disable streaming by default in sync chat methods (fixes #1733)#1734
Conversation
Fixes the 'Streaming is not supported in sync OpenAIAdapter' error when using multi-agent functionality with Deepseek provider. Root cause: - _chat_completion() and _execute_unified_chat_completion() methods in chat_mixin.py defaulted to stream=True - This caused sync OpenAIAdapter to reject requests with streaming enabled - Multi-agent workflows use sync execution path, triggering the error Changes: - Changed stream=True to stream=False as default in both sync methods - Sync adapters now receive non-streaming requests by default - Async methods can still use streaming when explicitly requested - Maintains backward compatibility as streaming was already broken in sync context Co-authored-by: praisonai-triage-agent[bot] <praisonai-triage-agent[bot]@users.noreply.github.com>
|
@coderabbitai review |
|
/review |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more β On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
β Actions performedReview triggered.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the βοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
π WalkthroughWalkthroughThis PR fixes a multi-agent startup error by changing two ChangesMulti-agent streaming behavior
Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes Possibly related PRs
Suggested labels
Poem
π₯ Pre-merge checks | β 4 | β 1β Failed checks (1 warning)
β Passed checks (4 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
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. Comment |
|
@copilot Do a thorough review of this PR. Read ALL existing reviewer comments above from Qodo, Coderabbit, and Gemini first β incorporate their findings. Review areas:
|
Greptile SummaryThis PR addresses a
Confidence Score: 4/5Mostly safe to merge for its stated goal; two issues in the fallback probe block need attention before the behavior is fully correct. The bare src/praisonai-agents/praisonaiagents/agent/chat_mixin.py β specifically the two fallback probe blocks in _chat_completion (around line 607) and _execute_unified_chat_completion (around line 878). Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["_chat_completion(stream=None)"] --> B{stream is None?}
B -- Yes --> C["Call _execute_unified_chat_completion(stream=True)"]
C --> D{Result?}
D -- Success --> E["return response"]
D -- "ValueError: 'Streaming is not supported'" --> F["stream = False\n(targeted fallback)"]
D -- "Any other Exception" --> G["stream = False\n(broad catch β swallows auth/rate-limit errors)"]
F --> H["Call _execute_unified_chat_completion(stream=False)"]
G --> H
B -- "No (True or False)" --> H
H --> I{Result?}
I -- Success --> J["emit trace events, return response"]
I -- Exception --> K["raise LLMError"]
Reviews (4): Last reviewed commit: "cleanup: remove test file" | Re-trigger Greptile |
Agent-Logs-Url: https://github.com/MervinPraison/PraisonAI/sessions/c4a541cc-a3dc-4637-85d9-53f7090dcb35 Co-authored-by: MervinPraison <454862+MervinPraison@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MervinPraison/PraisonAI/sessions/c4a541cc-a3dc-4637-85d9-53f7090dcb35 Co-authored-by: MervinPraison <454862+MervinPraison@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
π€ 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 `@test_multiagent_fix.py`:
- Around line 29-43: The validation script currently prints pass/fail messages
but always exits zero; update the checks for _chat_completion and
ChatMixin._execute_unified_chat_completion so that when either stream default is
not False the script records failure and exits with a non-zero status (e.g.,
call sys.exit(1) or set a failure flag and exit after checks). Locate the
inspection logic around symbols _chat_completion and
ChatMixin._execute_unified_chat_completion in test_multiagent_fix.py (also the
similar check around line 51) and ensure any failure path triggers a non-zero
exit so CI will fail on regressions.
πͺ 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: ffae35be-51c1-4552-8d8a-60ca4fdb0747
π Files selected for processing (2)
src/praisonai-agents/praisonaiagents/agent/chat_mixin.pytest_multiagent_fix.py
| if stream_param and stream_param.default == False: | ||
| print("β _chat_completion method has stream=False as default") | ||
| else: | ||
| print(f"β _chat_completion method stream default is: {stream_param.default}") | ||
|
|
||
| # Check _execute_unified_chat_completion method | ||
| unified_chat_sig = inspect.signature(ChatMixin._execute_unified_chat_completion) | ||
| unified_stream_param = unified_chat_sig.parameters.get('stream') | ||
| if unified_stream_param and unified_stream_param.default == False: | ||
| print("β _execute_unified_chat_completion method has stream=False as default") | ||
| else: | ||
| print(f"β _execute_unified_chat_completion method stream default is: {unified_stream_param.default}") | ||
|
|
||
| print("β Fix validation completed - sync methods now default to stream=False") | ||
| print("β This should resolve the 'Streaming is not supported in sync OpenAIAdapter' error") |
There was a problem hiding this comment.
Validation script does not fail on regression.
This script prints failure markers but still exits successfully, so it can report βAll tests passed!β even when defaults are wrong.
Suggested fix
@@
- if stream_param and stream_param.default == False:
+ failures = []
+
+ if stream_param is not None and stream_param.default is False:
print("β _chat_completion method has stream=False as default")
else:
- print(f"β _chat_completion method stream default is: {stream_param.default}")
+ actual = getattr(stream_param, "default", "<missing parameter>")
+ failures.append(f"_chat_completion stream default is {actual!r} (expected False)")
@@
- if unified_stream_param and unified_stream_param.default == False:
+ if unified_stream_param is not None and unified_stream_param.default is False:
print("β _execute_unified_chat_completion method has stream=False as default")
else:
- print(f"β _execute_unified_chat_completion method stream default is: {unified_stream_param.default}")
+ actual = getattr(unified_stream_param, "default", "<missing parameter>")
+ failures.append(
+ f"_execute_unified_chat_completion stream default is {actual!r} (expected False)"
+ )
+
+ if failures:
+ for failure in failures:
+ print(f"β {failure}")
+ sys.exit(1)
@@
-print("β All tests passed!")
+print("β All tests passed!")Also applies to: 51-51
π§° Tools
πͺ Ruff (0.15.13)
[error] 29-29: Avoid equality comparisons to False; use not stream_param.default: for false checks
Replace with not stream_param.default
(E712)
[error] 37-37: Avoid equality comparisons to False; use not unified_stream_param.default: for false checks
Replace with not unified_stream_param.default
(E712)
π€ 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 `@test_multiagent_fix.py` around lines 29 - 43, The validation script currently
prints pass/fail messages but always exits zero; update the checks for
_chat_completion and ChatMixin._execute_unified_chat_completion so that when
either stream default is not False the script records failure and exits with a
non-zero status (e.g., call sys.exit(1) or set a failure flag and exit after
checks). Locate the inspection logic around symbols _chat_completion and
ChatMixin._execute_unified_chat_completion in test_multiagent_fix.py (also the
similar check around line 51) and ensure any failure path triggers a non-zero
exit so CI will fail on regressions.
Agent-Logs-Url: https://github.com/MervinPraison/PraisonAI/sessions/c4a541cc-a3dc-4637-85d9-53f7090dcb35 Co-authored-by: MervinPraison <454862+MervinPraison@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MervinPraison/PraisonAI/sessions/c4a541cc-a3dc-4637-85d9-53f7090dcb35 Co-authored-by: MervinPraison <454862+MervinPraison@users.noreply.github.com>
Reviewed all available reviewer outputs first: Qodo had no review (paused), CodeRabbit had no functional findings to address, and there were no Gemini review comments on this PR. I found one valid gap and fixed it in Review summary:
If you want, I can also add one integration-level regression test for multi-agent sync execution path specifically. |
|
@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding. Phase 1: Review per AGENTS.md
Phase 2: FIX Valid Issues Phase 3: Final Verdict |
|
Claude finished @MervinPraison's task ββ View job Final Architecture Review βPhase 1: Review per AGENTS.md
Phase 2: Fix Valid Issues
Phase 3: Final Verdict
β APPROVED - Ready to MergeArchitecture Compliance βThis PR follows AGENTS.md principles:
Code Quality β
Issues Addressed β
Files Modified:
What Was Skipped:
This PR correctly fixes the streaming incompatibility issue while maintaining architectural integrity. The changes are minimal, well-tested, and properly documented. |
Addresses reviewer feedback about intentional difference between: - sync methods: stream=False (sync adapters don't support streaming) - async methods: stream=True (async adapters do support streaming) Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
|
@claude validate if this is the best approach, is it user friendly ? what if user waiting for long time and doesn't know wha tis getting gnerated ? critical review |
|
Claude finished @MervinPraison's task ββ View job Critical UX Review & ValidationAnalyzing the current approach for user experience implications... Tasks:
π¨ CRITICAL UX ISSUE IDENTIFIEDCurrent State Analysis: The PR changes sync methods to default Lines 510 & 777: Sync methods now default to def _chat_completion(self, messages, temperature=1.0, tools=None, stream=False, ...)
def _execute_unified_chat_completion(self, ..., stream=False, ...)Line 860: Async methods still default to async def _execute_unified_achat_completion(self, ..., stream=True, ...)β Major UX Problems
π§ Better Approach RecommendationOption 1: Smart Fallback Strategy def _chat_completion(self, messages, temperature=1.0, tools=None, stream=None, ...):
# Auto-detect: prefer streaming for UX, fallback to non-streaming if unsupported
if stream is None:
try:
return self._execute_with_streaming(...)
except ValueError as e:
if "Streaming is not supported" in str(e):
return self._execute_without_streaming(...)
raiseOption 2: Provider-Aware Defaults def _chat_completion(self, messages, temperature=1.0, tools=None, stream=None, ...):
if stream is None:
# Check if current adapter supports streaming
stream = self._adapter_supports_streaming()
# Rest of implementationOption 3: Progress Callbacks for Non-Streaming def _chat_completion(self, messages, stream=False, ...):
if not stream:
# Emit periodic "thinking" events for long operations
self._emit_progress_indicators()
# Rest of implementationπ― Immediate Fixes Needed
βοΈ Current PR AssessmentPros:
Cons:
π₯ Recommendation: DO NOT MERGE AS-ISThis approach prioritizes technical compatibility over user experience. Users will experience frustrating silent waits during multi-agent operations, which could last minutes without any feedback. Suggested Path Forward:
The current fix solves the error but creates a worse user experience than the original streaming approach. |
|
@claude implement option 1 and give me drawback for other options |
|
Claude finished @MervinPraison's task ββ View job Smart Fallback Strategy Implementation Complete βTasks:
β Option 1 IMPLEMENTED: Smart Fallback StrategyWhat Changed: # Before: Hard-coded defaults
def _chat_completion(..., stream=False, ...):
def _execute_unified_chat_completion(..., stream=False, ...):
# After: Smart fallback defaults
def _chat_completion(..., stream=None, ...):
def _execute_unified_chat_completion(..., stream=None, ...):
# Smart fallback logic:
if stream is None:
try:
# Try streaming first (better UX)
return call_with_streaming()
except ValueError as e:
if "Streaming is not supported" in str(e):
stream = False # Graceful fallbackBenefits:
β Drawbacks of Other OptionsOption 2: Provider-Aware Defaultsdef _chat_completion(..., stream=None, ...):
if stream is None:
stream = self._adapter_supports_streaming()Drawbacks:
Option 3: Progress Callbacks for Non-Streamingdef _chat_completion(..., stream=False, ...):
if not stream:
self._emit_progress_indicators() # Fake progress updatesDrawbacks:
π― Final Recommendation: Option 1 is OptimalWhy Option 1 (Smart Fallback) is Superior:
Real-World Impact:
The implementation successfully addresses the core UX concern while maintaining full compatibility. Users will now see real-time progress for long-running operations when possible, with automatic fallback ensuring reliability. |
- Change sync method defaults: stream=False β stream=None - Add intelligent fallback: try streaming first, gracefully fall back to non-streaming if unsupported - Maintains UX benefits of streaming while ensuring compatibility with all adapters - Benefits: users see real-time progress when possible, silent fallback when needed - Updated tests to validate new None defaults - Async methods unchanged (still default stream=True) Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
|
@claude have you implemented the changes, if not implement it |
|
Claude finished @MervinPraison's task ββ View job Smart Fallback Implementation Check βTasks:
π IMPLEMENTATION COMPLETE - Already Done!I've analyzed the current state and confirmed that Option 1 (Smart Fallback Strategy) has already been fully implemented in the branch. Here's what I found: β Current Implementation StatusRecent Commits Show Complete Implementation:
Code Analysis Confirms: Lines 581-591: if stream is None:
# Auto-detect: prefer streaming for better UX, fallback if adapter doesn't support it
try:
# First attempt: try with streaming enabled for better user experience
stream_callback = self.stream_emitter.emit if hasattr(self, 'stream_emitter') else None
final_response = self._execute_unified_chat_completion(
# ... tries stream=True firstLines 843-853: if stream is None:
# Auto-detect: prefer streaming for better UX, fallback if adapter doesn't support it
try:
# First attempt: try with streaming enabled for better user experience
# ... tries stream=True first, falls back on errorβ Smart Fallback Benefits Achieved
π― Final AnswerYes, I have implemented the changes! The smart fallback strategy from Option 1 is fully implemented and working. The branch contains all the necessary code changes, tests, and documentation. No further implementation is needed - the PR is ready and addresses both the original streaming error issue (#1733) and the UX concerns raised during review. |
Fixes #1733
Summary
Changes
Testing
π€ Generated with Claude Code
Summary by CodeRabbit