Parent
Part of #101
Scope
Stateful streaming business logic on top of the SSE parser (#501):
- Accumulate
response.function_call_arguments.delta by output item/index/call
- Require a matching
response.function_call_arguments.done before executing a tool
- Enforce terminal event handling (
response.completed, response.failed, response.incomplete)
- Fail closed on truncated streams, incomplete tool-call arguments, or missing terminal events
- Default policy:
buffered_final_stream — consume upstream SSE internally, buffer tool-call events, return valid final output to client
- Synthesize downstream output:
- Valid Responses JSON when returning a non-streamed final response
- Valid Responses SSE when returning a streamed final response
- Preserve final response metadata (response id, model, status, output text)
- Future-compatible
progress_events mode (do not forward tool-call events to client unless explicitly configured)
Acceptance criteria
- Interleaved function-call argument deltas are buffered by the correct output item/call
- Incomplete function calls fail closed before any tool execution
- Missing terminal events fail closed
- Final-text-only streamed model response produces a valid downstream response
- Tool-call streamed model response executes the tool only after complete arguments are available
- Synthesized downstream JSON/SSE is valid Responses-shaped output
- Stateless SSE pass-through remains unchanged
Dependencies
Reference
Parent
Part of #101
Scope
Stateful streaming business logic on top of the SSE parser (#501):
response.function_call_arguments.deltaby output item/index/callresponse.function_call_arguments.donebefore executing a toolresponse.completed,response.failed,response.incomplete)buffered_final_stream— consume upstream SSE internally, buffer tool-call events, return valid final output to clientprogress_eventsmode (do not forward tool-call events to client unless explicitly configured)Acceptance criteria
Dependencies
Reference