fix: preserve tool_calls and tool results in Chat→Responses API conversion#50
Merged
CaddyGlow merged 4 commits intoCaddyGlow:mainfrom Mar 31, 2026
Merged
Conversation
…d tool results to Responses API input
- Reformat payload builders for cleaner multiline structures - Simplify assistant content checks in request conversion
- Emit streaming tool deltas with `ToolCallChunk` metadata - Reuse shared parsing for message content and tool arguments
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
Problem
When a client sends a Chat Completions request with tool call history:
{"messages": [ {"role": "user", "content": "What is the weather?"}, {"role": "assistant", "tool_calls": [{"id": "fc_xxx", "function": {"name": "get_weather", "arguments": "{}"}}]}, {"role": "tool", "tool_call_id": "fc_xxx", "content": "{\"temp\": 70}"} ]}CCProxy's
_build_responses_payload_from_chat_requestonly extracted the last user message asinput, dropping the assistant'stool_callsand the tool result entirely. The upstream LLM never saw the tool result, so it re-called the same tool in an infinite loop.Fix
1.
openai_to_openai/requests.py—_build_responses_payload_from_chat_requestConvert ALL non-system messages to Responses API input items:
user→{"type": "message", "role": "user", ...}assistantwith text →{"type": "message", "role": "assistant", ...}assistantwithtool_calls→{"type": "function_call", "call_id": ..., "name": ..., "arguments": ...}per calltool→{"type": "function_call_output", "call_id": ..., "output": ...}2.
claude_api/adapter.py—_convert_openai_to_anthropicAdd handling for:
tool_calls→ Anthropictool_useblockstool_call_id→ Anthropictool_resultblocksTest
Before: LLM re-calls
get_weather(tool result was dropped)After: LLM summarizes "It's 70°F and sunny in Tokyo"