Skip to content

fix: support raw JSON response tool arguments - #14

Merged
lyz52789 merged 2 commits into
mainfrom
agent/fix-responses-object-arguments
Jul 12, 2026
Merged

fix: support raw JSON response tool arguments#14
lyz52789 merged 2 commits into
mainfrom
agent/fix-responses-object-arguments

Conversation

@lyz52789

Copy link
Copy Markdown

What changed

  • preserve Responses API tool-call arguments as raw JSON instead of requiring a JSON string
  • normalize both object-form and string-form arguments when converting Responses output to Chat Completions
  • add regression coverage for response.output_item.done.item.arguments and response.completed.response.output[].arguments

Why

Some OpenAI-compatible upstreams return function-call arguments as a JSON object. The existing string DTO rejects those events during stream decoding with errors such as:

json: cannot unmarshal object into Go struct field ResponsesOutput.item.arguments of type string

This ports the focused upstream fix from QuantumNous/new-api commit db89b57e1c8ce27dcd38273a4791f806da789a57 and adds an end-to-end DTO regression test for both observed stream locations.

Independence

This commit is based directly on the current origin/main commit 738bbf25fdb42a46f891e3a80d4b18b6f9b275f3. It was tested from a clean detached worktree with no other local or upstream patches applied.

Validation

go test ./common ./dto ./service/openaicompat ./relay/channel/openai -count=1

All targeted packages pass from the clean worktree.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 12, 2026

Copy link
Copy Markdown

Deploying new-api with  Cloudflare Pages  Cloudflare Pages

Latest commit: e017332
Status: ✅  Deploy successful!
Preview URL: https://8b05ed46.new-api-d57.pages.dev
Branch Preview URL: https://agent-fix-responses-object-a.new-api-d57.pages.dev

View logs

@lyz52789
lyz52789 marked this pull request as ready for review July 12, 2026 08:06
@lyz52789
lyz52789 merged commit 7424b12 into main Jul 12, 2026
1 check 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.

1 participant