Skip to content

fix: improve error visibility in streaming and manager#6272

Open
wufengwind wants to merge 1 commit into
crewAIInc:mainfrom
wufengwind:fix/streaming-manager-errors
Open

fix: improve error visibility in streaming and manager#6272
wufengwind wants to merge 1 commit into
crewAIInc:mainfrom
wufengwind:fix/streaming-manager-errors

Conversation

@wufengwind

@wufengwind wufengwind commented Jun 21, 2026

Copy link
Copy Markdown
  • Add DEBUG logging when streaming chunk parsing fails instead of silent pass
  • Remove fatal exception when manager agent has tools (warn + strip instead)

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved visibility for async streaming failures by emitting debug logs (with stack traces) when a streaming chunk can’t be parsed/extracted.
    • Updated manager-agent handling: if a user-supplied manager includes tools, the system now logs a warning and removes the tools to avoid runtime errors.
  • Tests

    • Updated coverage to assert the warning and tool-stripping behavior (instead of expecting an exception) for manager agents provided with tools.

@corridor-security corridor-security Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary: This PR improves observability for streaming chunk parsing failures and changes manager-agent tool handling to strip tools without raising a fatal exception. No exploitable security vulnerabilities were identified in the added code.

Risk: Low risk. The changes do not add new public-facing endpoints, authentication or authorization paths, external integrations, or unsafe data handling, and the manager tool change removes tool access rather than expanding it.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 40b88acf-4ed0-4218-b06e-3502844759e0

📥 Commits

Reviewing files that changed from the base of the PR and between 912f0b3 and 07744f8.

📒 Files selected for processing (3)
  • lib/crewai/src/crewai/crew.py
  • lib/crewai/src/crewai/llm.py
  • lib/crewai/tests/test_crew.py
✅ Files skipped from review due to trivial changes (1)
  • lib/crewai/src/crewai/llm.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • lib/crewai/tests/test_crew.py
  • lib/crewai/src/crewai/crew.py

📝 Walkthrough

Walkthrough

Two small independent fixes: _create_manager_agent in crew.py no longer raises an exception when a provided manager_agent has tools configured — it silently strips those tools instead. In llm.py, the async streaming loop's silent pass on chunk parse exceptions is replaced with a debug log that includes the full traceback.

Changes

Crew orchestration and async streaming fixes

Layer / File(s) Summary
Manager agent tool stripping
lib/crewai/src/crewai/crew.py, lib/crewai/tests/test_crew.py
Docstring added to _create_manager_agent. The exception-raising branch for a provided manager_agent with non-empty tools is removed; the tools are now silently stripped with an explanatory inline comment. The test function is renamed from test_manager_agent_with_tools_raises_exception to test_manager_agent_with_tools_logs_warning_and_strips_tools and updated to validate warning logging and tool stripping via Logger mock instead of expecting an exception during kickoff().
Async streaming chunk parse error logging
lib/crewai/src/crewai/llm.py
Replaces the no-op pass in _ahandle_streaming_response's exception handler with a debug-level log call that captures the failure message and full exception traceback via exc_info=True.

Suggested reviewers

  • vinibrsl
🚥 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 'fix: improve error visibility in streaming and manager' accurately captures both main changes: enhanced logging in streaming and improved manager agent tool handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/crewai/src/crewai/crew.py (1)

1498-1505: ⚠️ Potential issue | 🔴 Critical

Update test to reflect new warning-and-strip contract instead of exception.

The test test_manager_agent_with_tools_raises_exception (lib/crewai/tests/test_crew.py:2881–2908) still expects an exception to be raised when a manager agent has tools, but the code now logs a warning and silently strips the tools. This test will fail with the current implementation. Update the test to verify the warning is logged and tools are removed, or remove the test if this behavior is no longer part of the API contract. Check any user-facing documentation referencing the old exception behavior.

🤖 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 `@lib/crewai/src/crewai/crew.py` around lines 1498 - 1505, The test
test_manager_agent_with_tools_raises_exception expects an exception to be raised
when a manager agent has tools, but the implementation in the crew manager code
now logs a warning and silently strips the tools instead. Update this test to
verify the new behavior by checking that a warning is logged and the manager's
tools are removed (set to an empty list), rather than asserting an exception is
raised. Additionally, review any user-facing documentation or API contracts that
reference the old exception behavior and update them to reflect the new
warning-and-strip behavior.
🤖 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 `@lib/crewai/src/crewai/crew.py`:
- Line 1505: Update the comment at set_manager_agent() that currently states
tools are "silently stripped" to accurately reflect the actual behavior where a
warning is logged before tools are stripped. The comment should describe that
tools are stripped with a warning message, not silently, to prevent confusion
during future code maintenance.

---

Outside diff comments:
In `@lib/crewai/src/crewai/crew.py`:
- Around line 1498-1505: The test test_manager_agent_with_tools_raises_exception
expects an exception to be raised when a manager agent has tools, but the
implementation in the crew manager code now logs a warning and silently strips
the tools instead. Update this test to verify the new behavior by checking that
a warning is logged and the manager's tools are removed (set to an empty list),
rather than asserting an exception is raised. Additionally, review any
user-facing documentation or API contracts that reference the old exception
behavior and update them to reflect the new warning-and-strip behavior.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0aa7d81a-e5df-455d-adfc-fb608c69678e

📥 Commits

Reviewing files that changed from the base of the PR and between 9db2d44 and 0b12bbe.

📒 Files selected for processing (2)
  • lib/crewai/src/crewai/crew.py
  • lib/crewai/src/crewai/llm.py

Comment thread lib/crewai/src/crewai/crew.py Outdated
@wufengwind wufengwind force-pushed the fix/streaming-manager-errors branch 3 times, most recently from b3805e5 to 912f0b3 Compare June 21, 2026 05:57
- Add DEBUG logging when streaming chunk parsing fails instead of silent pass
- Remove fatal exception when manager agent has tools (warn + strip instead)
@wufengwind wufengwind force-pushed the fix/streaming-manager-errors branch from 912f0b3 to 07744f8 Compare June 21, 2026 05:59
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.

1 participant