Fix Codex subagent final result preservation#602
Merged
tiann merged 3 commits intoMay 9, 2026
Conversation
There was a problem hiding this comment.
Findings
- [Major] Empty status message suppresses structured output —
statusObjectFromAgentStatenow preserves completed agent states such as{ status: 'completed', message: '', output: { value: 42 } }, but the launcher readsrecord.messagewith nullish coalescing, so an empty string is treated as the final result and the structuredoutputis dropped. That reintroduces the blank/terminal-only completed card for this added case. Evidencecli/src/codex/codexRemoteLauncher.ts:962.
Suggested fix:const extractAgentStatusMessage = (record: Record<string, unknown>): unknown => { const message = asString(record.message); if (message) return message; if (record.output !== undefined && record.output !== null) return record.output; if (record.result !== undefined && record.result !== null) return record.result; if (record.finalMessage !== undefined && record.finalMessage !== null) return record.finalMessage; return record.final_message; };
Summary
- Review mode: initial
- One issue found: completed child-agent states with blank
messagestill lose structured output in the launcher.
Testing
- Not run (automation)
HAPI Bot
There was a problem hiding this comment.
Findings
- [Minor] Reset the new harness flag between tests —
emitChildWaitStructuredOutputis enabled by the new structured-output test, butafterEachresets the neighboring child-event flags without resetting this one. Because the harness object is shared, every later test now runs withagentsStatescarryingmessage: ''andoutput: { value: 42 }, so the suite becomes order-dependent and can mask regressions in the normal child-message path. Evidencecli/src/codex/codexRemoteLauncher.test.ts:1078.
Suggested fix:harness.emitChildDoneStatusWithoutMessage = false; harness.emitChildWaitStructuredOutput = false; harness.emitChildTaskCompleteBeforeMessage = false;
Summary
- Review mode: follow-up after new commits
- One test-isolation issue found in the follow-up changes. The prior structured-output finding appears addressed in the launcher path.
Testing
- Not run (automation;
bunis unavailable in this runner:/bin/bash: bun: command not found)
HAPI Bot
There was a problem hiding this comment.
Findings
- No findings.
Summary
- Review mode: follow-up after new commits
- No issues found in the latest PR diff. The prior HAPI Bot test-isolation finding is fixed in the current head.
- Residual risk: Codex app-server event ordering is hard to exhaustively validate from the diff alone.
Testing
- Not run (automation/review only; PR code not executed)
HAPI Bot
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
Fix Codex subagent result handling so completed subagent cards preserve the actual final assistant message instead of sometimes showing only a terminal status such as
done.Problem
In some Codex multi-agent flows, a child agent could complete successfully but the parent-side result would only contain a completion marker (
done/completed) rather than the child agent's final message.This could happen when:
wait_agentreturned a completed/done status without a messageChanges
agent_messagewait_agentreports completed/done without a messagedone,complete, andcompletedagent states consistentlysend_input/resume_agentto remain visible without letting late child tool events overwrite terminal statetask_startedTests
Also smoke-tested against a deployed local HAPI build with real Codex subagents:
wait_agentresult contained full final messages, not onlydoneNotes
This is a clean resubmission from the latest upstream
main, replacing the closed PR #599 without force-pushing the old branch.