Skip to content

fix: disable streaming by default in sync chat methods (fixes #1733)#1734

Open
praisonai-triage-agent[bot] wants to merge 6 commits into
mainfrom
claude/issue-1733-20260523-1442
Open

fix: disable streaming by default in sync chat methods (fixes #1733)#1734
praisonai-triage-agent[bot] wants to merge 6 commits into
mainfrom
claude/issue-1733-20260523-1442

Conversation

@praisonai-triage-agent
Copy link
Copy Markdown
Contributor

@praisonai-triage-agent praisonai-triage-agent Bot commented May 23, 2026

Fixes #1733

Summary

  • Fixed the 'Streaming is not supported in sync OpenAIAdapter' error when using multi-agent functionality with Deepseek provider
  • Root cause: sync chat methods defaulted to stream=True but sync adapters don't support streaming
  • Solution: Changed default from stream=True to stream=False in sync methods

Changes

  • chat_mixin.py:510 - Changed _chat_completion() default parameter from stream=True to stream=False
  • chat_mixin.py:777 - Changed _execute_unified_chat_completion() default parameter from stream=True to stream=False

Testing

  • Added test script that validates the fix works correctly
  • Confirmed sync methods now default to non-streaming behavior
  • Multi-agent workflows should now work without streaming errors

πŸ€– Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Chat completions will no longer stream by default, allowing for complete response delivery in single payloads.
  • Tests
    • Added validation tests for chat completion streaming behavior defaults.

Review Change Stack

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>
@MervinPraison
Copy link
Copy Markdown
Owner

@coderabbitai review

@MervinPraison
Copy link
Copy Markdown
Owner

/review

@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
Contributor

coderabbitai Bot commented May 23, 2026

βœ… Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 594dec17-2eb8-44e4-a650-3c9e51e31fce

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • πŸ” Trigger review
πŸ“ Walkthrough

Walkthrough

This PR fixes a multi-agent startup error by changing two ChatMixin sync chat-completion methods to default stream=False instead of True, preventing sync-incompatible streaming errors. A test script validates the fix by inspecting method signatures.

Changes

Multi-agent streaming behavior

Layer / File(s) Summary
Stream parameter defaults adjustment
src/praisonai-agents/praisonaiagents/agent/chat_mixin.py
ChatMixin._chat_completion() and ChatMixin._execute_unified_chat_completion() change their stream default from True to False, preventing sync OpenAI adapter errors when multi-agent flows invoke these methods without explicit stream arguments.
Streaming defaults verification test
test_multiagent_fix.py
New test script constructs a two-agent setup and uses inspect.signature() to verify that both chat-completion methods default stream to False, logging success or traceback with exit code 1 on failure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Review effort 3/5

Poem

🐰 Streaming flipped with care,
False now defaults where True was there,
Multi-agents leap without despair,
Sync paths dance light as air! ✨

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly and concisely summarizes the main change: disabling streaming by default in sync chat methods to fix issue #1733.
Linked Issues check βœ… Passed The PR directly addresses issue #1733 by changing stream defaults from True to False in sync methods, eliminating the unsupported streaming error in multi-agent workflows.
Out of Scope Changes check βœ… Passed All changes are in-scope: modifications to stream parameters in chat_mixin.py and a test script validating the fix, both directly aligned with issue #1733.

✏️ 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-1733-20260523-1442

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.

@MervinPraison
Copy link
Copy Markdown
Owner

@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:

  1. Bloat check: Are changes minimal and focused? Any unnecessary code or scope creep?
  2. Security: Any hardcoded secrets, unsafe eval/exec, missing input validation?
  3. Performance: Any module-level heavy imports? Hot-path regressions?
  4. Tests: Are tests included? Do they cover the changes adequately?
  5. Backward compat: Any public API changes without deprecation?
  6. Code quality: DRY violations, naming conventions, error handling?
  7. Address reviewer feedback: If Qodo, Coderabbit, or Gemini flagged valid issues, include them in your review
  8. Suggest specific improvements with code examples where possible

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 23, 2026

Greptile Summary

This PR fixes a ValueError ("Streaming is not supported in sync OpenAIAdapter") that fired when sync chat methods defaulted to stream=True but were routed through the OpenAIAdapter sync path, which explicitly rejects streaming. The fix changes both _chat_completion and _execute_unified_chat_completion to default to stream=False.

  • Changed the stream default parameter from True to False in two sync methods (_chat_completion, _execute_unified_chat_completion), and added a comment on the async counterpart (_execute_unified_achat_completion) to document the intentional asymmetry.
  • The only call-site affected by the default change is the guardrail-retry path in agent.py:4670, which doesn't pass stream explicitly and benefits from the corrected default since it needs a complete response for validation.
  • A new unit test validates the source-level defaults via AST inspection.

Confidence Score: 5/5

Safe to merge β€” the two-line default change closes a clear error path without disrupting any call-site that explicitly passes stream.

Every caller that needs streaming already passes stream=stream explicitly; the only site affected by the default flip is the guardrail-retry path in agent.py, which benefits from non-streaming since it needs a complete response to validate against the guardrail rule. The async counterpart keeps its stream=True default and gains a clarifying comment. No behavior regressions are introduced.

No files require special attention.

Important Files Changed

Filename Overview
src/praisonai-agents/praisonaiagents/agent/chat_mixin.py Defaults for stream changed from True to False in _chat_completion and _execute_unified_chat_completion; clarifying comment added on async counterpart.
src/praisonai-agents/tests/unit/agent/test_chat_sync_stream_defaults.py New unit test validates the two changed function signatures via AST inspection.

Sequence Diagram

sequenceDiagram
    participant C as agent.chat()
    participant CC as _chat_completion(stream=False)
    participant UC as _execute_unified_chat_completion(stream=False)
    participant D as UnifiedLLMDispatcher
    participant A as OpenAIAdapter (sync)

    C->>CC: "stream=self.stream (explicit)"
    CC->>UC: "stream=stream (explicit)"
    UC->>D: "chat_completion(stream=False, ...)"
    D->>A: "adapter.chat_completion(stream=False, ...)"
    Note over A: kwargs.get('stream', False) == False β†’ no ValueError raised
    A-->>D: ChatCompletion response
    D-->>UC: response
    UC-->>CC: response
    CC-->>C: response
Loading

Reviews (3): Last reviewed commit: "docs: clarify async/sync stream default ..." | Re-trigger Greptile

Comment thread test_multiagent_fix.py Outdated
Copy link
Copy Markdown
Contributor

@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

πŸ€– 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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 5ff79d3 and 9f2cb5b.

πŸ“’ Files selected for processing (2)
  • src/praisonai-agents/praisonaiagents/agent/chat_mixin.py
  • test_multiagent_fix.py

Comment thread test_multiagent_fix.py Outdated
Comment on lines +29 to +43
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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚑ Quick win

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.

Copilot AI and others added 2 commits May 23, 2026 14:49
Agent-Logs-Url: https://github.com/MervinPraison/PraisonAI/sessions/c4a541cc-a3dc-4637-85d9-53f7090dcb35

Co-authored-by: MervinPraison <454862+MervinPraison@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 23, 2026

@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:...

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 c1f452e (plus related commits): the previous test_multiagent_fix.py was an ad-hoc root script and not part of pytest discovery. I removed it and added a proper unit test at src/praisonai-agents/tests/unit/agent/test_chat_sync_stream_defaults.py that asserts both sync methods default stream=False.

Review summary:

  1. Bloat: now minimal/focused (2 prod-line change remains; test is now scoped and discoverable).
  2. Security: no secrets/eval/exec introduced.
  3. Performance: no hot-path regressions; no new heavy imports.
  4. Tests: now covered via pytest unit test (passes locally).
  5. Backward compat: no API surface change beyond corrected sync default behavior.
  6. Code quality: improved by replacing non-discoverable script with maintainable unit test.

If you want, I can also add one integration-level regression test for multi-agent sync execution path specifically.

@MervinPraison
Copy link
Copy Markdown
Owner

@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

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions

Phase 2: FIX Valid Issues
4. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
5. Push all code fixes directly to THIS branch (do NOT create a new PR)
6. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
7. If all issues are resolved, approve the PR / close the Issue
8. If blocking issues remain, request changes / leave clear action items

@praisonai-triage-agent
Copy link
Copy Markdown
Contributor Author

praisonai-triage-agent Bot commented May 23, 2026

Claude finished @MervinPraison's task β€”β€” View job


Final Architecture Review βœ…

Phase 1: Review per AGENTS.md

  • Read AGENTS.md guidelines
  • Check protocol-driven design compliance
  • Verify backward compatibility
  • Assess performance impact

Phase 2: Fix Valid Issues

  • Review findings from Gemini, CodeRabbit, Qodo, Copilot
  • Implement fixes for valid issues
  • Push changes to branch

Phase 3: Final Verdict

  • Approve PR - all issues resolved
  • Document any remaining concerns

βœ… APPROVED - Ready to Merge

Architecture Compliance βœ…

This PR follows AGENTS.md principles:

  • Protocol-driven: Changes are in core SDK, minimal and focused
  • Backward compatible: Only changes internal method defaults, no API surface changes
  • Performance: Zero performance impact - only default parameter values changed
  • Agent-centric: Fixes multi-agent workflow issue by correcting sync adapter behavior

Code Quality βœ…

  • Minimal scope: 2-line fix targeting exact issue
  • Proper testing: Copilot added proper unit test replacing ad-hoc script
  • Documentation: Added clarifying comment about async/sync default asymmetry

Issues Addressed βœ…

  • CodeRabbit: Test validation issue - FIXED (test replaced with proper unit test)
  • Greptile: Documentation gap about async/sync asymmetry - FIXED (added clarifying comment)
  • All other reviewers: No blocking issues identified

Files Modified:

  • src/praisonai-agents/praisonaiagents/agent/chat_mixin.py: Stream defaults + documentation
  • src/praisonai-agents/tests/unit/agent/test_chat_sync_stream_defaults.py: Proper unit test

What Was Skipped:

  • No issues skipped - all valid reviewer feedback was addressed

This PR correctly fixes the streaming incompatibility issue while maintaining architectural integrity. The changes are minimal, well-tested, and properly documented.
| Branch: claude/issue-1733-20260523-1442

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>
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.

[BUG] Error on startup when using multi-agent

2 participants