Skip to content

Stream tool calls and structured output from Anthropic as it's received instead of in one go #1669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025

Conversation

DouweM
Copy link
Contributor

@DouweM DouweM commented May 8, 2025


  • Partial JSON is already handled properly by the PartsManager and ToolCallPartDelta.
  • In testing, the RawContentBlockStartEvent with ToolUseBlock always has input {}.

@DouweM DouweM requested a review from Kludex May 8, 2025 12:57
@DouweM DouweM changed the title Fix streaming partial tool call responses from Anthropic Fix streaming partial tool calls from Anthropic May 8, 2025
Copy link

github-actions bot commented May 8, 2025

Docs Preview

commit: 1306f44
Preview URL: https://86b2ed45-pydantic-ai-previews.pydantic.workers.dev

@DouweM
Copy link
Contributor Author

DouweM commented May 8, 2025

CI failures are the same as in #1668 so unrelated to this PR.

@Kludex
Copy link
Member

Kludex commented May 8, 2025

"Fix streaming partial tool calls from Anthropic" = "Don't parse partial JSON delta on Anthropic streaming"?

@Kludex
Copy link
Member

Kludex commented May 8, 2025

"Fix streaming partial tool calls from Anthropic" = "Don't parse partial JSON delta on Anthropic streaming"?

Please make the title a bit more specific before merging it, if it makes sense.

@DouweM DouweM changed the title Fix streaming partial tool calls from Anthropic Stream tool calls and structured output from Anthropic as parts instead of one final chunk May 8, 2025
@DouweM DouweM changed the title Stream tool calls and structured output from Anthropic as parts instead of one final chunk Stream tool calls and structured output from Anthropic as it's received instead of in one go May 8, 2025
@DouweM DouweM enabled auto-merge (squash) May 8, 2025 14:51
@DouweM DouweM merged commit 0810eed into main May 21, 2025
15 checks passed
@DouweM DouweM deleted the anthropic-tool-call-streaming branch May 21, 2025 23:09
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.

Structured streaming doesn't work with claude (Stream Whale example) Anthropic streaming returns in single chunk when agent result_type is specified
2 participants