Skip to content

Conversation

karboom
Copy link

@karboom karboom commented Sep 23, 2025

Description

Sometimes, we need to obtain real-time responses from multiple agents. This hook function can output real-time responses to the frontend through websocket or perform other operations

Checklist

  • I have read the CONTRIBUTION guide (required)
  • I have linked this PR to an issue using the Development section on the right sidebar or by adding Fixes #issue-number in the PR description (required)
  • I have checked if any dependencies need to be added or updated in pyproject.toml and uv lock
  • I have updated the tests accordingly (required for a bug fix or a new feature)
  • I have updated the documentation if needed:
  • I have added examples if this is a new feature

Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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
Member

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

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

thanks @karboom for opening this PR,

After reviewing the PR in detail, I have concerns about the design. Users can already achieve the same result by iterating over the streaming response using code below:

  # Without stream_hook (current way)
  for chunk in agent.step(message):
      # Do something with chunk - push to websocket, queue, etc.
      handle_chunk(chunk)

The hook seems doesn't provide significant value over normal iteration. And adding the hook would make the ChatAgent is being given responsibility for side effects that should be the caller's responsibility. This mixes business logic with agent behavior.
If callbacks are needed, a proper observer/event system would be
better (like on_chunk, on_complete, on_error with event emitters).
Adding the hook will also make it be called with:
- ChatAgentResponse for chunks
- BaseMessage for final messages (in some paths)
- ChatAgentResponse for errors

This inconsistency makes it hard to use correctly.

I think it would be better to keep original design, WDYT?

@Wendong-Fan Wendong-Fan added enhancement New feature or request Waiting for Update PR has been reviewed, need to be updated based on review comment labels Oct 5, 2025
@karboom
Copy link
Author

karboom commented Oct 11, 2025

@Wendong-Fan

  1. The reason for this idea is that I want to see the real-time output of multiple agents when using workforce.
  2. I think your idea about observer/event system is correct. For a framework, if i want to increase its ability in this area, it should be designed more comprehensively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Waiting for Update PR has been reviewed, need to be updated based on review comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants