Skip to content

fix(responses): normalize schema-declared integer tool arguments - #807

Merged
chenyme merged 2 commits into
chenyme:mainfrom
AmPlace:agent/responses-schema-coercion
Jul 28, 2026
Merged

fix(responses): normalize schema-declared integer tool arguments#807
chenyme merged 2 commits into
chenyme:mainfrom
AmPlace:agent/responses-schema-coercion

Conversation

@AmPlace

@AmPlace AmPlace commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • retain the client function parameter schema for response normalization
  • coerce mathematically integral JSON numbers such as 60000.0 and 6e4 to the integer spelling required by strict downstream tool decoders
  • apply the same normalization to regular Responses JSON and streamed SSE function-call arguments
  • preserve number fields, fractional values, and values outside the exact JSON integer range

Root cause

Grok Build can emit a decimal JSON spelling for a tool argument declared as integer. For example, Codex declares wait_agent.timeout_ms as an integer, but an upstream call may contain {"timeout_ms":60000.0}. Codex rejects that argument before tool execution and may repeatedly retry the same invalid call.

The existing Responses compatibility layer restored tool names and namespaces but forwarded ordinary function arguments unchanged.

Impact

Codex-compatible clients can execute strict-schema tools through Grok2API without failing on integral float spellings. Schema traversal covers nested objects, arrays, composition keywords, nullable integer types, and local $ref definitions.

Validation

  • go test ./internal/infra/provider/cli
  • go test ./...
  • git diff --check

@AmPlace
AmPlace marked this pull request as ready for review July 28, 2026 02:11
@chenyme
chenyme merged commit cf91190 into chenyme:main Jul 28, 2026
9 checks 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.

2 participants