#1207
Reconcile partially streamed Codex tool input with the done item
Summary
Reconcile partially streamed Codex tool input with the complete input in response.output_item.done. This is a follow-up to the final-only input fix in PR #1201, not evidence that the original user-session failure was caused by a missing delta.
In internal/providers/openai/codex_responses.go, handleOutputItemDone forwards the done item's input only when no input has been accumulated. If a delta is missing but other fragments arrive, the runtime and replay history can retain incomplete input even when the done item contains the complete input.
Requested changes
- Compare the accumulated input with the done item's input for function and custom tool calls.
- When the accumulated input is a prefix of the final input, forward only the missing suffix before the tool-call end event. Keep the runtime input and replay history aligned.
- When the inputs do not have a prefix relationship, do not guess at a repair. Preserve the streamed copy unless maintainers choose another explicit mismatch policy.
- Preserve existing final-only and fully streamed behavior without duplicating input. Handle absent final input without discarding streamed input.
Acceptance criteria
- Add regression tests for function and custom tool calls with a missing trailing fragment, a complete stream, final-only input, and a non-prefix mismatch.
- Verify event ordering, exactly-once input delivery, runtime collection, and replay history.
- Cover added-event and no-added-event paths where applicable.
Requested by: @oniisanlabs
Pull request: https://github.com/Twigpine/zero/pull/1201 Review comment: https://github.com/Twigpine/zero/pull/1201#discussion_r4502305140
Holding this one for now. A partial copy can only happen if Zero's stream handler skips an input event, because the stream itself arrives in order, and a done item only arrives after every delta before it. If the stream breaks, there is no done item to reconcile with. #1201 fixed the case we actually saw, input that never streamed at all.
If anyone sees a tool call reach the runtime with partial arguments while the done item carries the full input, please attach the raw event log here and I'll approve this for implementation. Until then it stays unapproved, so please don't open a PR for it yet.