Skip to content

Conversation

@naveen-corpusant
Copy link
Contributor

For OpenAI responses API, the response.function_call_arguments.delta returns an item_id (docs) . This item_id is actually the id of the tool_call, rather than the tool_call_id.

The problem is that when using agent_stream or more generally the parts_manager, these deltas are accumulated and the tool_call_id for the ToolCallNode ends up being set to the incorrect id. This is particularly problematic because the id is a longer string than is supported by some gpt models (for example, an id is fc_6876aca7db8c8192af95414c6cf92796035a7a219e794395, whereas the tool call id for the same request is call_YHzL9zYTlauY9bw9dEoE4uA4.

gpt-4o-mini only allows tool call ids that are 40 characters or less, so using the longer id breaks things (and is incorrect from a tool call id perspective).

@Kludex
Copy link
Member

Kludex commented Jul 16, 2025

Do you have a snippet I can reproduce so we can add a test here?

@Kludex Kludex self-assigned this Jul 16, 2025
@DouweM DouweM assigned DouweM and unassigned Kludex Jul 16, 2025
@DouweM DouweM merged commit 64b64a5 into pydantic:main Jul 16, 2025
18 checks passed
@DouweM
Copy link
Collaborator

DouweM commented Jul 16, 2025

@naveen-corpusant Thank you!

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.

4 participants