fix: Codex CLI type compatibility for text, reasoning in multi-turn conversation.#81
Merged
Merged
Conversation
…history. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: maral <maralbahari.98@gmail.com>
leseb
approved these changes
Jun 30, 2026
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>
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
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 fixtype_: StringfromInputTextContentandInputImageContent. The#[serde(tag = "type")]onInputContentconsumes the tag field; inner structs must not redeclare it or deserialization silently fails.OutputText,ReasoningText, andUnknownvariants toInputContent. Codex sends these content types in rehydrated multi-turn history; the old two-variant enum would reject them.FunctionCall(FunctionToolCall)variant toInputItemso tool invocations round-trip through history correctly.types/io/output.rs: ReasoningOutput id default#[serde(default)]toReasoningOutput.id. Codex does not always includeidon reasoning items in the input array, causing a deserialization error on any request that included prior reasoning in its history.OutputMessage -> InputMessageconversion to produceInputContent::OutputTextinstead of the now-removedInputContent::Text.types/io/tools.rs: FunctionTool type default#[serde(default = "default_function_type")]toFunctionTool.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 rehydrationinto_input_items()was discardingOutputItem::FunctionCallitems 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 warningscleancargo test: all tests pass, 0 failedtest_into_input_items_preserves_function_callscovers the FunctionCall rehydration fix