feat: Alma/Codex Responses multi-turn tool replay#10
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a tool-call replay cache (ToolReplayCache) to support multi-turn continuity for OpenAI Responses clients, allowing them to continue with only previous response IDs or item references and tool outputs. It integrates this cache into the server's streaming and non-streaming response handlers, handles compatibility adjustments (such as flattening tool outputs, stringifying arguments, and stripping null reasoning fields), and adds comprehensive unit tests. The review feedback focuses on performance and type-safety improvements, specifically suggesting that flattenToolOutput return a concrete string instead of any, and recommending a lazy allocation (copy-on-write) pattern in expandItemReferences and pruneOrphanToolOutputs to avoid unnecessary slice allocations when no modifications are made.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f18c3405d9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
caa3767 to
7d4496d
Compare
Summary
Fixes #9 by adding a process-local tool-call replay cache and tightening Responses ModelInput hygiene so Alma/Codex multi-turn tool results work against Grok CLI (no
previous_response_id/item_referencesupport upstream).What this PR does
ToolReplayCache: index completedfunction_call/custom_tool_callbyprev-resp:{id}, optionalcache:{prompt_cache_key}, anditem:{item.id}item_reference→ re-insert missing calls for tool outputs → normalize → prune orphan outputsweb_search_call, …); forceargumentsstring; flatten tooloutput; strip nullreasoningfieldsoutput_item.done(item ids immediately; session keys onresponse.completed, patch empty completed.output)Pipeline order
Out of scope
Test plan
go test ./internal/openai ./internal/serverweb_search_call/reasoning.content: nullhistory does not 422Notes
Inspired by CLIProxyAPI xAI tool/replay + normalize path; adapted to this repo’s single-process Responses compatibility layer (tool-call subset only).