fix(auxiliary): route Codex Responses path through shared converter (#5709)#41714
Merged
Conversation
Contributor
🔎 Lint report:
|
…5709) The auxiliary Codex adapter maintained its own chat->Responses conversion loop that forwarded every non-system message's role verbatim into Responses input[]. When flush_memories()/compression replayed session history containing assistant tool_calls + role=tool results, those tool messages leaked into the request and the Responses API rejected them with HTTP 400: Invalid value: 'tool'. Route _CodexCompletionsAdapter.create() through the same shared converter the main agent transport uses (_chat_messages_to_responses_input), so tool calls become function_call items and tool results become function_call_output items with a valid call_id. Single conversion path means no future drift. Also remove the now-dead _convert_content_for_responses() helper — its only caller was the private conversion loop this change deletes. Co-authored-by: ProgramCaiCai <techxacm@gmail.com>
1920b07 to
02bf374
Compare
This was referenced Jun 8, 2026
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
Auxiliary Codex Responses calls no longer crash with
HTTP 400: Invalid value: 'tool'when replaying session history that contains tool results.Root cause:
agent/auxiliary_client.py::_CodexCompletionsAdapter.create()maintained its own chat→Responses conversion loop that forwarded every non-system message'sroleverbatim into Responsesinput[]. Whenflush_memories()/ context compression replayed real session history (assistanttool_calls+role="tool"results), those tool messages leaked into the request and the Responses API rejected them. The main agent transport already converts tool history correctly — the auxiliary path was a second, divergent converter.Changes
agent/auxiliary_client.py: route_CodexCompletionsAdapter.create()through the shared_chat_messages_to_responses_input()(the same converteragent/transports/codex.pyuses). Assistant tool calls →function_callitems, tool results →function_call_outputitems with a validcall_id. The async adapter delegates to this sync path, so it's covered too. Single conversion path = no future drift (the issue's explicit scope).tests/agent/test_auxiliary_client.py: regression tests — tool history never leaksrole=tool, becomesfunction_call/function_call_outputwith matchingcall_id; plain-text history still works; system → instructions.scripts/release.py: AUTHOR_MAP entry for the contributor.Validation
role="tool"in Responsesinput[]role=toolfunction_call_output+call_idfunction_call+call_idTargeted: 49 Codex auxiliary tests pass (incl. 2 new regression tests). E2E: fed realistic system+user+assistant(tool_calls)+tool+assistant history through the adapter, captured the
responses.createpayload, confirmed norole=tooland correctfunction_call/function_call_outputitems.Closes #5709. Salvages the approach from #5711 (@ProgramCaiCai, issue author) — reimplemented on current
mainto reuse the existing canonical converter inagent/codex_responses_adapter.pyrather than introducing a new module. Co-authored credit preserved.Infographic