Skip to content

ChatGPT/Codex provider can drop tool arguments supplied only in the final event #1194

Description

@oniisanlabs

Version / branch / commit

Reproduced against main at commit 16ccd787, using a local regression test.

OS and environment

macOS arm64; ChatGPT/Codex Responses provider.

Steps to reproduce

Feed the Codex streaming response handler a synthetic tool call sequence:

  1. Send response.output_item.added for a function call, with empty arguments.
  2. Do not send incremental argument events.
  3. Send response.output_item.done for the same call, containing complete arguments such as {"path":"README.md"}.
  4. Observe the argument deltas delivered to the runtime before the tool-call-end event.

The same behavior occurs for custom/freeform tool input and when the added event is absent.

Expected behavior

When the final output-item event is the only event containing tool input, the provider forwards that input to the runtime before ending the tool call. Input already delivered through incremental events must not be duplicated.

Actual behavior

The provider retains the final input for history replay but does not emit an argument delta to the runtime. Tool execution can consequently receive an empty argument string, even though the final event contained valid input.

This can produce errors such as:

Invalid arguments for read_file: path is required
Invalid arguments for grep: pattern is required

Relevant evidence and regression coverage

Affected code: internal/providers/openai/codex_responses.go, handling response.output_item.done.

A locally prepared regression test, TestCodexOutputItemDoneForwardsUnstreamedArguments, covers eight combinations: function/custom calls, added event present/absent, and streamed/final-only input. Using an overlay with the unmodified production file from HEAD, all four final-only cases fail, including:

arguments at tool-call-end = "", want "{\"path\":\"README.md\"}"

With a focused local fix that forwards final-only input before tool-call-end, all eight cases pass; the OpenAI provider package also passes with the race detector. The regression test and fix are local and not yet published. Full-repository validation has outstanding failures outside the provider package; this is not a claim that the full suite passes.

This demonstrates an argument-loss path, but does not establish that it caused the original user-session failures that prompted the investigation. No private session logs are included.

I can contribute the focused fix and regression coverage if maintainers approve this issue for community implementation. No PR has been opened.

Activity

  1. added
    bugSomething isn't working
    issue-approvedReviewed and approved by the core team; community PRs may implement this issue.
    on Nov 7, 2026
  2. Vasanthdev2004 commented on Nov 7, 2026

    @Vasanthdev2004
    Collaborator

    Thanks, confirmed on main at 16ccd78. I drove the provider through zeroruntime.CollectStream, which is what the runtime uses, and a function_call whose arguments arrive only on response.output_item.done comes out with empty arguments, with or without the added event. Streamed arguments are fine.

    One more case belongs in the same fix: a custom_tool_call whose input is already on response.output_item.added. handleOutputItemAdded writes it into the builder without sending a delta, and the done handler then skips the final input because the builder is no longer empty, so the runtime gets nothing there either. So the check for what still needs forwarding should track what was actually sent to the runtime, not builder.Arguments.Len().

    Labelled and assigned to you, go ahead with the PR. Please put a closing keyword for this issue in the description so it closes on merge.

  3. added a commit that references this issue on Nov 10, 2026
    15ff170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingissue-approvedReviewed and approved by the core team; community PRs may implement this issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions