Skip to content

fix: preserve tool history when converting Chat requests to Responses - #158

Merged
lich0821 merged 1 commit into
lich0821:masterfrom
wozhenbang2004:fix/chat-responses-tool-history
Oct 30, 2026
Merged

lich0821 merged 1 commit into
lich0821:masterfrom
wozhenbang2004:fix/chat-responses-tool-history

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Related to #132.

When a Chat Completions client sends a tool-call history to an OpenAI Responses endpoint, OpenAIReqToOpenAI2 drops the assistant's tool_calls. It also sends each tool result as a message with role: "tool", losing its tool_call_id instead of producing a Responses function_call_output item.

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):

  • Three new tool-history cases fail against the original production converter and pass with this change; ordinary-message and malformed-input controls pass on both.
  • go test ./internal/transformer/... -count=1 passes with the complete transformer package and its logger dependency.
  • go vet ./internal/transformer/... and formatting checks pass.
  • A local smoke test through cx/chat.NewOpenAI2Transformer().TransformRequest preserves 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.

@lich0821
lich0821 merged commit 1a54d6f into lich0821:master Oct 30, 2026
7 checks 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.

2 participants