fix(codex): surface commentary as interim assistant prose - #59831
fix(codex): surface commentary as interim assistant prose#59831ruizanthony wants to merge 1 commit into
Conversation
Related to recently-merged #58868 (the teknium1 salvage that closed the #24933 commentary-leak family) — this PR partially reverses its direction: #58868 routed both |
|
Confirmed against current The scope is narrower than generic "text before tools" bugs:
This PR has the right architectural direction. Two robustness cases seem worth covering before merge:
Suggested behavioral tests:
I validated the fallback behavior locally with six focused compatibility tests, plus the existing Hermes commentary/final-answer parser tests. This should make the upstream fix reliable without coupling it to Telegram streaming or tool-progress settings. |
1c8990a to
74210c6
Compare
74210c6 to
d8165ce
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for separating commentary from private analysis. The current-main premise is confirmed: agent/codex_runtime.py:721-729 routes both phases to reasoning, while gateway reasoning is hidden by default.
Problems
agent/codex_runtime.py:1024-1025sends raw commentary to the interim callback. That callback only strips think blocks (run_agent.py:4747-4753); normal assistant content is redacted atagent/chat_completion_helpers.py:1138-1147. Please redact this new visible path and add a dynamic credential-token regression.- Retry de-duplication keys include
item_id(agent/codex_runtime.py:765-770in this PR), but the test repeatsmsg_commentaryin both attempts (tests/run_agent/test_run_agent_codex_responses.py:828,850). It does not cover a retry returning a different item id.
Suggested changes
- Reuse the existing secret-redaction behavior before
_emit_interim_assistant_message. - Define a retry-stable identity or add a changed-item-id retry fixture that proves exactly-once delivery without merging distinct commentary.
Automated hermes-sweeper review.
| agent._fire_reasoning_delta(text) | ||
|
|
||
| def _on_commentary_message(text: str) -> None: | ||
| agent._emit_interim_assistant_message({"role": "assistant", "content": text}) |
There was a problem hiding this comment.
This newly visible path bypasses the normal assistant-content redaction boundary: _emit_interim_assistant_message only strips think blocks before calling the gateway callback. Please redact text here (or in that helper) and add a dynamic sk-... fixture proving an interim callback cannot receive the raw token.
| SimpleNamespace( | ||
| type="response.output_item.added", | ||
| output_index=0, | ||
| item=SimpleNamespace(type="message", id="msg_commentary", phase="commentary"), |
There was a problem hiding this comment.
The retry fixture repeats the first attempt's msg_commentary id. Because the implementation's emission key includes item_id, add a variant with a different second-attempt id to define whether retry de-duplication is intended to survive newly issued response-item identities.
|
Closing — the commentary-channel work landed via PR #66115 (salvage of #65653, which built on #60453). Your PR was the earliest submission in this cluster and correctly identified the problem: commentary deserved a visible path separate from private reasoning. The merged implementation converged on the same commentary→interim routing with additional lifecycle/dedup hardening and a |
Summary
commentaryphase deltas to theinterim_assistantchannel as one assembled messageanalysisphase deltas in the private reasoning pathoutput_text, preserving the existing final-answer behaviorWhy
Recent Codex runtime changes correctly stopped treating commentary as final assistant text, but routed both
commentaryandanalysisthrough the reasoning callback. In WebUI and gateway surfaces where raw reasoning is hidden, that removed the useful high-level “why I’m doing this next” narration and left users with only tool cards or generic tool labels.commentaryis intended as user-facing mid-turn narration;analysisis private reasoning. This patch restores that distinction.Tests
python3 -m py_compile agent/codex_runtime.pypython3 -m pytest tests/run_agent/test_run_agent_codex_responses.py -q