Skip to content

fix(parser): emit tool call arguments from added and done envelopes - #35

Merged
TheGreatAxios merged 3 commits into
mainfrom
fix/tool-call-args-fallbacks
Nov 4, 2026
Merged

TheGreatAxios merged 3 commits into
mainfrom
fix/tool-call-args-fallbacks

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes CL-11975

Closes #34

What changed

  • registerToolCallBlock stores each function_call item's real call_id and tracks hasEmittedArgs when response.output_item.added registers the block.
  • inference.tool_call.delta events (both streaming and non-streaming parseJSONResponse) now carry the real callId alongside index.
  • When response.output_item.added carries a non-empty item.arguments string on a function_call, parseResponse immediately emits inference.tool_call.delta and marks hasEmittedArgs.
  • Handles response.function_call_arguments.done and response.output_item.done (item.type === "function_call") as fallback argument sources when no prior argument delta was emitted for that item_id, preventing parallel tool calls from finalizing with empty {} arguments while avoiding duplicate emission when deltas already streamed.
  • Both done envelopes now throw ProtocolMismatchError for a function_call never announced by output_item.added (previously ignored, silently dropping the call), matching the existing .delta rule.

Verification

  • bun run check (typecheck, lint, format, 55 unit tests) passes.
  • bun run test:e2e (6 e2e tests through runInference) passes.
  • bun run build succeeds cleanly.

@linear-code

linear-code Bot commented Nov 4, 2026

Copy link
Copy Markdown

CL-11975

@TheGreatAxios
TheGreatAxios merged commit 2c7747b into main Nov 4, 2026
2 checks passed
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.

Emit tool call arguments from added/done envelopes and preserve real callId on deltas

1 participant