[#125]: Fix Codex v0.139.0 compat — accept JSON-object function_call arguments and add oneOf/allOf schema tests#130
Merged
Merged
Conversation
…r Codex v0.139.0 compat
Codex v0.139.0 (PRs #24118, #27084) preserves oneOf and allOf in tool and
connector input schemas instead of flattening them. When a tool's schema uses
composition keywords, the model may generate arguments that Codex logs as a
JSON object directly in the function_call payload rather than as a stringified
JSON string.
The existing function_call handler used .as_str().unwrap_or("{}"), which
silently dropped any non-string arguments (resulting in Value::Null on the
ToolCall). The mcp_tool_call handler already handles both forms correctly.
Align function_call with the same pattern.
Changes:
- src-tauri/src/parser/turn.rs: handle string or object arguments in the
function_call response_item handler (matches mcp_tool_call behaviour)
- src-tauri/src/parser/entry.rs: add v0.139.0 regression tests covering all
standard entry types, JSON-object function_call arguments, and mcp_tool_call
entries with oneOf/allOf schema structures
- src-tauri/src/parser/turn.rs: add three v0.139.0 turn-level tests verifying
JSON-object arguments are preserved through the full build_turns pipeline
Fixes #125
Extends the v0.139.0 coverage (which fixed JSON-object arguments in function_call entries) with three additional test areas: entry.rs (3 tests): session_meta entries where a tool's input_schema uses oneOf, allOf, or deeply nested oneOf-within-allOf composition. Guards against future regressions if schema parsing becomes typed. session.rs (3 tests): full parse_session round-trips with tools having oneOf/allOf schemas in session_meta. Confirms session id, cli_version, turn count, and tool call classification are all correct. turn.rs (3 tests): mcp_tool_call response_items carrying an input_schema field with oneOf or allOf composition. Verifies the field is ignored (it is not used by the parser) and the call is classified correctly as McpTool. Also covers a function_call in a session whose session_meta has tools with complex schemas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codex v0.139.0 (PRs #24118, #27084) changed tool and connector input schemas to preserve
oneOfandallOfstructures instead of flattening them. Large schemas also keep more shallow structure when compacted.Root cause: When a tool's schema uses composition keywords, the model may generate
function_callarguments as a JSON object directly in the JSONL payload rather than as a stringified JSON string. The existing handler used.as_str().unwrap_or("{}"), which silently dropped any non-stringargumentsvalue (producingValue::Nullon theToolCall). Themcp_tool_callhandler already handled both forms correctly.Changes
Fix (
src-tauri/src/parser/turn.rs)Updated the
function_callresponse_item handler to accept both string and object argument formats, matching the existingmcp_tool_callhandler:Regression tests (9 new tests across 3 files)
entry.rs(5 tests): All four standard v0.139.0 entry types parse correctly;function_callwith JSON-object arguments is preserved;mcp_tool_callwithoneOf/allOfschema fields is handled;session_metawith tools havingoneOf,allOf, and deeply nested composition schemas all parse without panic.session.rs(3 tests): Fullparse_sessionround-trips with tools havingoneOfschemas,allOfconnector schemas, and afunction_callmade in a session whosesession_metacarries complex tool schemas — confirms session id, cli_version, turn count, and tool call classification are all correct.turn.rs(5 tests): JSON-objectfunction_callarguments are preserved through the fullbuild_turnspipeline; complex nested argument structures are not dropped;mcp_tool_callitems withoneOf/allOfinput_schemafields are classified asMcpTool;function_callin a session with complexsession_metatool schemas is classified correctly.Verification
cargo test --lib: 220 tests pass (215 before this PR)cargo clippy -- -D warnings: cleancargo fmt --check: clean--headlessmode):POST /api/sessionsreturns JSON arrayFixes #125