AI Help

How do I tell when streamed AI tool arguments are complete and ready to parse?

Accumulate argument deltas for the correct call and parse them only after the documented arguments-complete event.

Steps to follow

  1. Track each output item or function call by its identifier. Append deltas in order without mixing concurrent calls.
  2. On the endpoint's argument-completion event, parse the full JSON and validate it against the tool schema.
  3. Check final response state and execute each authorized call at most once. Event names and payloads vary by endpoint and SDK.

Example in practice

Illustrative example. Two simultaneous function calls need separate argument buffers so one contact ID cannot be combined with another call's fields.

Related AI help

Official guidance

OpenAI documentation