fix(run_agent): strip temperature from flush_memories Codex fallback path#15390
Closed
24601 wants to merge 2 commits into
Closed
fix(run_agent): strip temperature from flush_memories Codex fallback path#1539024601 wants to merge 2 commits into
24601 wants to merge 2 commits into
Conversation
…path When the auxiliary client fails for any reason (_call_llm raises), the codex_responses fallback path explicitly set codex_kwargs["temperature"] = _flush_temperature (0.3). _run_codex_stream then sent this to the Codex Responses endpoint (chatgpt.com/backend-api/codex), which rejects temperature with HTTP 400 "Unsupported parameter: temperature". The error propagated to the outer except block and surfaced as "Auxiliary memory flush failed: HTTP 400 - Unsupported parameter: temperature", misleadingly pointing at temperature rather than the original aux failure. Fix: strip temperature unconditionally from codex_kwargs before calling _run_codex_stream, consistent with how _CodexCompletionsAdapter already omits temperature from Responses API calls. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nput The _CodexCompletionsAdapter passed all non-system message roles through to the Codex Responses endpoint unchanged. The endpoint only accepts user and assistant roles in the input array; tool/function messages (from prior memory flush calls in the session) caused HTTP 400: 'Invalid value: tool. Supported values are: assistant, system, developer, and user.' Changes: - Skip role='tool' and role='function' messages (tool results not needed for the flush summary context) - Map role='developer' to instructions, same as role='system' - Silently skip any other unknown roles rather than sending them - Note: temperature was already stripped in run_agent.py (prior commit) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
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.
Problem
Two related bugs in the
flush_memoriesCodex path cause"Auxiliary memory flush failed"with HTTP 400 errors.Bug 1 — temperature in fallback path
When
flush_memoriesis incodex_responsesmode and the auxiliary client fails for any reason, the fallback path explicitly setscodex_kwargs["temperature"] = _flush_temperature(0.3) before calling_run_codex_stream. The Codex Responses endpoint does not accepttemperatureand returns:The error propagated to the outer
except Exception as e:and surfaced as"Auxiliary memory flush failed"— misleadingly implicating temperature rather than the actual aux failure.The bug was latent before
8a2506af(which widenedexcept RuntimeError→except Exception as e:). After that commit the inner failure started triggering the fallback path more frequently, exposing this.Bug 2 — unsupported message roles in adapter
_CodexCompletionsAdapter.create()passes all non-system message roles through to the Responses API unchanged. The Codex endpoint only acceptsuserandassistantin theinputarray. Sessions that include memory tool results (prior flush calls) containrole: 'tool'messages, causing:Root Cause
Bug 1 —
run_agent.py,flush_memoriesCodex fallback:Bug 2 —
agent/auxiliary_client.py,_CodexCompletionsAdapter.create():Note:
_CodexCompletionsAdapteralready correctly omits temperature fromresp_kwargs. The fallback path failed to do the same.Fix
Bug 1: Strip temperature unconditionally from
codex_kwargsbefore_run_codex_stream.Bug 2: In
_CodexCompletionsAdapter, skiprole='tool'androle='function'messages; maprole='developer'to instructions; silently skip unknown roles.Tests
Existing
test_codex_mode_no_aux_uses_responses_apiintests/run_agent/test_flush_memories_codex.pycovers the fallback path.