Skip to content

[#125]: Fix Codex v0.139.0 compat — accept JSON-object function_call arguments and add oneOf/allOf schema tests#130

Merged
delexw merged 3 commits into
mainfrom
fix-issue-125
Jun 16, 2026
Merged

[#125]: Fix Codex v0.139.0 compat — accept JSON-object function_call arguments and add oneOf/allOf schema tests#130
delexw merged 3 commits into
mainfrom
fix-issue-125

Conversation

@delexw

@delexw delexw commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Codex v0.139.0 (PRs #24118, #27084) changed tool and connector input schemas to preserve oneOf and allOf structures 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_call arguments 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-string arguments value (producing Value::Null on the ToolCall). The mcp_tool_call handler already handled both forms correctly.

Changes

Fix (src-tauri/src/parser/turn.rs)

Updated the function_call response_item handler to accept both string and object argument formats, matching the existing mcp_tool_call handler:

// Before
let arguments_str = payload.get("arguments").and_then(|v| v.as_str()).unwrap_or("{}");

// After
let arguments_str = match payload.get("arguments") {
    Some(Value::String(s)) => s.clone(),
    Some(v) => serde_json::to_string(v).unwrap_or_else(|_| "{}".to_string()),
    None => "{}".to_string(),
};

Regression tests (9 new tests across 3 files)

entry.rs (5 tests): All four standard v0.139.0 entry types parse correctly; function_call with JSON-object arguments is preserved; mcp_tool_call with oneOf/allOf schema fields is handled; session_meta with tools having oneOf, allOf, and deeply nested composition schemas all parse without panic.

session.rs (3 tests): Full parse_session round-trips with tools having oneOf schemas, allOf connector schemas, and a function_call made in a session whose session_meta carries complex tool schemas — confirms session id, cli_version, turn count, and tool call classification are all correct.

turn.rs (5 tests): JSON-object function_call arguments are preserved through the full build_turns pipeline; complex nested argument structures are not dropped; mcp_tool_call items with oneOf/allOf input_schema fields are classified as McpTool; function_call in a session with complex session_meta tool schemas is classified correctly.

Verification

  • cargo test --lib: 220 tests pass (215 before this PR)
  • cargo clippy -- -D warnings: clean
  • cargo fmt --check: clean
  • HTTP API smoke test (--headless mode): POST /api/sessions returns JSON array

Fixes #125

delexw and others added 3 commits June 14, 2026 10:39
…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.
@delexw delexw merged commit f081fd0 into main Jun 16, 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.

[Compat] Codex v0.139.0: tool/connector schemas now preserve oneOf and allOf structures

2 participants