Skip to content

feat: Support stream + tool call + structured output#3821

Open
Zephyroam wants to merge 17 commits intocamel-ai:masterfrom
Zephyroam:3782-feature-request-support-stream-tool-call-structured-output
Open

feat: Support stream + tool call + structured output#3821
Zephyroam wants to merge 17 commits intocamel-ai:masterfrom
Zephyroam:3782-feature-request-support-stream-tool-call-structured-output

Conversation

@Zephyroam
Copy link
Copy Markdown
Collaborator

@Zephyroam Zephyroam commented Feb 10, 2026

Description

Fixes #3782

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • 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

If you are unsure about any of these, don't hesitate to ask. We are here to help!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 10, 2026

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.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aad5f641-cbba-4ecf-b298-82d9f0d2d7dc

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Zephyroam and others added 3 commits February 10, 2026 10:42
Removed the _format_message_with_fallback method and its usages throughout the chat_agent.py file.
Copy link
Copy Markdown
Collaborator

@fengju0213 fengju0213 left a comment

Choose a reason for hiding this comment

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

Nice implementation. I noticed that we also added a fallback mechanism. I think retaining the native capabilities of the OpenAI SDK is already sufficient, and introducing a fallback would bring significant maintenance overhead. I suggest removing the related code.

Since this PR was submitted via a forked repository, I’m not able to submit a PR myself, so I made the changes directly in your PR.

@Zephyroam
Copy link
Copy Markdown
Collaborator Author

Zephyroam commented Feb 11, 2026

Now Gemini and Claude are supported.

Copy link
Copy Markdown
Collaborator

@waleedalzarooni waleedalzarooni left a comment

Choose a reason for hiding this comment

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

Great job @Zephyroam!,

Couple of quick comments

@fengju0213 fengju0213 added this to the Sprint 49 milestone Mar 2, 2026
@fengju0213
Copy link
Copy Markdown
Collaborator

I've been wondering about something. Since the OpenAI SDK doesn't natively support simultaneous structured outputs and tool calling in streaming mode, our current approach departs from the native pattern. Should we avoid building these custom workarounds for capabilities the model doesn't currently support? After all, as the model's capabilities evolve, this adaptation code will likely become obsolete.
cc @Wendong-Fan

@Wendong-Fan
Copy link
Copy Markdown
Member

I've been wondering about something. Since the OpenAI SDK doesn't natively support simultaneous structured outputs and tool calling in streaming mode, our current approach departs from the native pattern. Should we avoid building these custom workarounds for capabilities the model doesn't currently support? After all, as the model's capabilities evolve, this adaptation code will likely become obsolete. cc @Wendong-Fan

It brings value to the agent framework by adding useful features beyond the current base model. While model platforms may support this natively in the future, the implementation cost is low. Given how important and useful it is, I think doing it ourselves makes sense

Copy link
Copy Markdown
Collaborator

@bytecii bytecii left a comment

Choose a reason for hiding this comment

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

In general LGTM, left some comments

@Zephyroam Zephyroam requested review from bytecii and fengju0213 March 11, 2026 16:00
@Zephyroam
Copy link
Copy Markdown
Collaborator Author

Done, thanks for your comments @bytecii

@Zephyroam
Copy link
Copy Markdown
Collaborator Author

https://github.com/camel-ai/camel/pull/3821/changes#diff-f90260a7e58e0c09b9d2e737a580635d71a7310f1a4adebdb3b41323a960698cR744
@Wendong-Fan max_tokens is a mandatory parameter for the new SDK version. I have to set a default value. I refer to pydantic/pydantic-ai#2553.

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.

[Feature Request] Support stream + tool call + structured output

5 participants