Skip to content

fix: Codex CLI type compatibility for text, reasoning in multi-turn conversation.#81

Merged
leseb merged 1 commit into
vllm-project:mainfrom
EmbeddedLLM:codex-cli-type-fixes
Jun 30, 2026
Merged

fix: Codex CLI type compatibility for text, reasoning in multi-turn conversation.#81
leseb merged 1 commit into
vllm-project:mainfrom
EmbeddedLLM:codex-cli-type-fixes

Conversation

@maralbahari

Copy link
Copy Markdown
Collaborator

Summary

Four targeted fixes to make agentic-api correctly deserialize and rehydrate Codex CLI requests for text input/output and reasoning. Without these, multi-turn conversations fail silently due to serde tag conflicts, missing optional fields, and dropped history items.

types/io/input.rs: InputContent deserialization fix

  • Removed type_: String from InputTextContent and InputImageContent. The #[serde(tag = "type")] on InputContent consumes the tag field; inner structs must not redeclare it or deserialization silently fails.
  • Added OutputText, ReasoningText, and Unknown variants to InputContent. Codex sends these content types in rehydrated multi-turn history; the old two-variant enum would reject them.
  • Added FunctionCall(FunctionToolCall) variant to InputItem so tool invocations round-trip through history correctly.

types/io/output.rs: ReasoningOutput id default

  • Added #[serde(default)] to ReasoningOutput.id. Codex does not always include id on reasoning items in the input array, causing a deserialization error on any request that included prior reasoning in its history.
  • Updated OutputMessage -> InputMessage conversion to produce InputContent::OutputText instead of the now-removed InputContent::Text.

types/io/tools.rs: FunctionTool type default

  • Added #[serde(default = "default_function_type")] to FunctionTool.type_. Codex occasionally omits the "type" field on function tools, causing deserialization to fail for the entire request.

storage/types/item.rs: FunctionCall preserved in rehydration

  • into_input_items() was discarding OutputItem::FunctionCall items from stored history. vLLM requires the full call/output pair in the input array for subsequent turns; dropping the call item caused context corruption in any multi-turn session that used tools.

Test Plan

  • cargo clippy --all-targets -- -D warnings clean
  • cargo test: all tests pass, 0 failed
  • New test test_into_input_items_preserves_function_calls covers the FunctionCall rehydration fix

…history.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: maral <maralbahari.98@gmail.com>
@leseb leseb merged commit 6ad3ae8 into vllm-project:main Jun 30, 2026
3 checks passed
ashwing added a commit to ashwing/agentic-api that referenced this pull request Jun 30, 2026
Rebased on main after vllm-project#79 and vllm-project#81 merged.

Adds src/tool/ — the behavioral layer that complements the wire types
already in types/tools/ (merged via PR vllm-project#79):

- tool/handler.rs  — ToolHandler trait, ToolOutput, ToolError
- tool/registry.rs — ToolType, ToolEntry, ToolRegistry::build/lookup/etc
- tool/function.rs — FunctionHandler + From<&FunctionToolParam> for FunctionTool
- tool/normalize.rs — ResponsesTool::to_function_tool(), From<ToolOutput>

Also adds types/tools/ wire types (params.rs with ResponsesTool enum,
param structs, NonEmptyToolName), EmptyToolNameError, and wires normalize
into RequestPayload::to_upstream_request() so vLLM always receives
Vec<FunctionTool>.

12 cassette-based tests in tool_normalization_test.rs validate the full
pipeline against real multi-turn tool-call cassettes.

Addresses all PR vllm-project#80 review feedback:
- types/ → wire shapes only; tool/ → behaviors
- From<&FunctionToolParam> for FunctionTool (typed conversion)
- MCP registry entries deferred to PR C (discovery not yet wired)
- EmptyToolNameError in types/ (no cross-layer import)
- ToolOutput derives Debug + Clone

Signed-off-by: Ashwin Giridharan <girida@amazon.com>
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