Repository navigation
fix: preserve tool history when converting Chat requests to Responses - #158
Merged
lich0821 merged 1 commit intoOct 30, 2026
Merged
Conversation
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.
Related to #132.
When a Chat Completions client sends a tool-call history to an OpenAI Responses endpoint,
OpenAIReqToOpenAI2drops the assistant'stool_calls. It also sends each tool result as amessagewithrole: "tool", losing itstool_call_idinstead of producing a Responsesfunction_call_outputitem.Preserve function calls and their results as separate input items, including parallel calls and result ordering. Keep accompanying assistant string content, but omit the empty message for tool-only assistant turns. String and text-part-array tool results are supported. Existing handling of other message content and streaming response conversion is unchanged.
Verification (Go 1.27.3, Linux; fixed upstream source at
425ffca2751483baf7df13dcc15fda7b2500ff8c):go test ./internal/transformer/... -count=1passes with the complete transformer package and its logger dependency.go vet ./internal/transformer/...and formatting checks pass.cx/chat.NewOpenAI2Transformer().TransformRequestpreserves call IDs, multipart output, model and streaming flag.This is converter-level verification, not a full proxy/desktop build or a live upstream-provider test. No provider API calls were made.