Skip to content

Conversation

@anton-tw
Copy link

@anton-tw anton-tw commented Dec 1, 2025

Summary

  • Fixes an issue where some providers (e.g., Bedrock) return an initial empty {} followed by actual arguments when streaming tool calls, resulting in malformed {}{...} JSON
  • Detects and strips the leading {} prefix while preserving legitimate empty {} arguments

Test plan

  • Added test for stripping {} prefix when followed by real arguments
  • Added test to verify legitimate empty {} arguments are preserved

When streaming, some models return an initial empty `{}` followed by the
actual arguments, resulting in `{}{...}`. This fix detects and strips
the leading `{}` prefix while preserving legitimate empty arguments.
@changeset-bot
Copy link

changeset-bot bot commented Dec 1, 2025

🦋 Changeset detected

Latest commit: 42f81c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@openai/agents-openai Patch
@openai/agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@anton-tw
Copy link
Author

anton-tw commented Dec 1, 2025

@seratch We ran into an issue when using Bedrock as the provider - during streaming, tool call arguments would arrive as {} in the first chunk, followed by the actual arguments in subsequent chunks. This resulted in malformed JSON like {}{\"key\":\"value\"} which breaks parsing.

This PR adds a small fix that detects and strips the leading {} when it's followed by real arguments, while still preserving legitimate empty {} arguments for tools that don't require parameters.

Would appreciate your thoughts on this approach!

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