feat(codex-cli): prefer output-last-message artifacts#2449
Open
BingqingLyu wants to merge 1 commit intomainfrom
Open
feat(codex-cli): prefer output-last-message artifacts#2449BingqingLyu wants to merge 1 commit intomainfrom
BingqingLyu wants to merge 1 commit intomainfrom
Conversation
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
codex-cliruns still finalize the user-visible reply from stdout even though Codex can write a dedicated final-message artifact--output-last-messageoutputcodex-cliruns now allocate a temp--output-last-messagefile, prefer that artifact when it contains text, and keep stdout parsing as the fallback pathChange Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
codex-clirunner only treated stdout parsing as the final reply source even though Codex already exposes a more stable final-message artifact contract--output-last-message, but OpenClaw was not wiring that contract into thecodex-clibackend pathRegression Test Plan (if applicable)
src/agents/cli-runner.spawn.test.ts,src/agents/cli-output.test.ts--output-last-messagefile, OpenClaw should prefer the artifact when it is non-empty and fall back to parsed stdout when the artifact is emptyUser-visible / Behavior Changes
codex-clireplies now finalize from Codex's explicit final-message artifact when available, which makes delegated Codex runs less dependent on stdout formatting details.Diagram (if applicable)
Security Impact (required)
No)No)No)Yes)No)Yes, explain risk + mitigation:--output-last-messageflag plus a temp file under OpenClaw's preferred temp dir. The file is per-run, read back locally, and deleted in cleanup even when parsing falls back to stdout.Repro + Verification
Environment
codex-cli/gpt-5.4codex-clibackend with--jsonSteps
codex-cliexecution through the CLI runner.Expected
Actual
Evidence
Human Verification (required)
src/agents/cli-output.test.ts,src/agents/cli-runner.spawn.test.ts, andsrc/agents/cli-runner.reliability.test.tspnpm check/pnpm testlanes and a live end-to-end Codex CLI run against the actual binary in this branchReview Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations
finally, and the unit test asserts the artifact path is removed after successparseCliJsonlnow extracts text from Codex message content records, and the fallback path is covered by a dedicated unit testAI-assisted: Yes (Codex). Testing: targeted vitest coverage listed above. I attempted
codex review --base origin/main, but the local Codex CLI is currently rate-limited.