fix(session): keep tool-call arguments as mappings - #2143
Open
atirna wants to merge 5 commits into
Open
Conversation
SenseNova and other Python OpenAI-compatible backends json.loads function.arguments then call .items(). A primitive tool input serializes as a JSON number and 400s every later request in the session, including the first call after a subagent spawn.
atirna
force-pushed
the
fix/subagent-messages-serialization
branch
from
August 17, 2026 06:00
f8b7f16 to
2e7b11c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue / context
Fixes #2116
子 agent spawn 之后第一次请求就 400(
'int' object has no attribute 'items'),然后这个 session 里换任何模型都一样,直到新开一个。Type of change
Bug fix
What does this PR do?
SenseNova / 其它 Python OpenAI-compatible 后端会对
tool_call.function.arguments做json.loads再.items()。tool input 如果是个数字,@ai-sdk/openai-compatible会JSON.stringify(0)发出去变成"0",对面 parse 成 int,这段 history 就废了。子 agent spawn 会把 parent 的inheritedMessages拼进第一次请求,所以一 spawn 就中。I coerce primitive/null tool inputs to a mapping in
toModelMessages({}or{ value }).ProviderTransform.messagealso drops stray non-object entries in the messages list and does the same input wrap, since that's the pre-send choke point on the fork path.How did you verify your code works?
before, on current
main: a numeric tool-call input ships as arguments JSON0(locked@ai-sdk/openai-compatible@2.0.41).after:
toModelMessagesturns input0into{ value: 0 }[...inheritedMessages, ...ownNew, 0]throughProviderTransform.messagethen a mocked compatible provider: every message is a dict, everyfunction.argumentsparses to a non-array objectScreenshots / recordings
n/a, not a UI change
Checklist