fix(agent): surface Codex commentary items as interim messages - #60453
fix(agent): surface Codex commentary items as interim messages#60453davidrobertson wants to merge 2 commits into
Conversation
Related to #59831 and the merged #58868: this PR re-surfaces Codex |
|
I independently reproduced this against current Focused local verification of the same behavior passed:
One output-safety issue is worth fixing before merge: Suggested contract: visible = "\n\n".join(parts).strip()
if visible:
visible = self._strip_think_blocks(visible).strip()
from agent.redact import redact_sensitive_text
visible = redact_sensitive_text(visible)
return visibleAnd a regression test should construct the token dynamically so secret scanners do not rewrite the fixture: secret = "sk-" + ("A" * 32)
# put `secret` in a phase="commentary" output_text item
agent._emit_interim_assistant_message(message)
assert secret not in observed[0]The phase boundary in this PR is right: only |
|
Addressed in Structured Codex Verification:
|
|
Thanks for the focused fix. The premise is still present on current main: The proposed extraction is appropriately narrow: it accepts only No verified correctness issues found in the two-file diff. The related #59831 and #62396 propose alternative delivery lanes and remain a maintainer design-selection question rather than a defect in this patch. Automated hermes-sweeper review. |
|
Superseded by #65653, which preserves this PR’s two original commits and David Robertson’s authorship, then adds the lifecycle, retry/dedup, multi-item, fallback, compatibility, and first-class streaming fixes found during adversarial validation against current |
|
Merged via PR #66115 — your two commits were cherry-picked onto current main with your authorship preserved in git log (136ade2, a15397d). @100yenadmin built the lifecycle/dedup hardening and the separate live-stream commentary channel on top in #65653, and we added a |
Summary
phase="commentary"message items through the existing interim assistant callback when top-level assistantcontentis emptyphase="analysis"andphase="final_answer"hidden from interim deliveryWhy
Codex Responses can store user-facing mid-turn narration in structured
codex_message_itemsinstead of top-level assistantcontent._emit_interim_assistant_message()only inspectedcontent, so non-streaming gateway surfaces could miss natural progress commentary before tool execution even though the callback path was configured.This keeps the fix narrow: only explicit
phase="commentary"output text is surfaced, while provider scratchpad/analysis remains hidden.Verification
Fresh branch based on current
origin/main(1c473bc6a):python -m pytest tests/run_agent/test_run_agent_codex_responses.py -k 'interim_commentary or commentary_only or codex_commentary' -q -o 'addopts='→6 passed, 80 deselectedpython -m pytest tests/run_agent/test_run_agent_codex_responses.py -q -o 'addopts='→87 passedpython -m pytest tests/agent/test_redact.py -q -o 'addopts='→149 passedpython -m pytest tests/run_agent/test_provider_parity.py -k 'codex or commentary or message_items' -q -o 'addopts='→38 passed, 55 deselectedpython -m pytest tests/gateway -k 'commentary or interim or progress' -q -o 'addopts='→119 passed, 1 skipped, 8800 deselectedpython -m compileall -q run_agent.py tests/run_agent/test_run_agent_codex_responses.py gateway/run.py gateway/stream_consumer.py→ exit 0python -m ruff check run_agent.py tests/run_agent/test_run_agent_codex_responses.py→All checks passed!(with existing invalid# noqawarning atrun_agent.py:107)git diff --check→ exit 0Current-main compatibility check (
origin/mainat46e87b14f): both PR commits cherry-picked cleanly into a detached worktree, then:88 passed149 passed38 passed, 55 deselected145 passed, 1 skipped, 9040 deselectedcompileall, andgit diff --check: passed