Skip to content

fix(ai): serialize undefined historical tool input - #48863

Merged
rekram1-node merged 1 commit into
v2from
missing-tool-input
Sep 14, 2026
Merged

rekram1-node merged 1 commit into
v2from
missing-tool-input

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Summary

  • Serialize an explicit undefined historical tool input as {} in OpenAI Chat and shared Responses tool-call lowering.
  • Preserve defined inputs, including null, arrays, strings, numbers, and objects.

Schema and failure verification

ToolCallPart.input is Schema.Unknown. An explicit input: undefined passes both the part schema and decoding into the canonical Message class. Omitting the required input property entirely is rejected by the part schema.

Before this change, an otherwise schema-valid message containing undefined input failed synchronously in JSON encoding, before making an HTTP request. The new tests decode the message through the real schema, compile it successfully, assert arguments: "{}", and verify the canonical input remains unchanged.

Live verification

Requests containing undefined historical input plus a matching error result were sent through the actual native compiler and LLMClient.generate streaming path using gpt-4.1-mini on both OpenAI Chat and Responses. Both completed normally and returned the exact fixture error code INPUT_MISSING, with no generated tool calls. No model-requested tools were executed.

Checks

  • bun test test/provider/missing-tool-input.test.ts test/provider/openai-chat.test.ts test/provider/openai-responses.test.ts --timeout 30000 --only-failures — 215 passed.
  • bun typecheck from packages/ai — passed.
  • Formatting and git diff --check — passed.

@rekram1-node
rekram1-node merged commit 0722517 into v2 Sep 14, 2026
8 checks passed
@rekram1-node
rekram1-node deleted the missing-tool-input branch September 14, 2026 04:43
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
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