Skip to content

feat: codex exec writes only the final message to stdout#4644

Merged
bolinfest merged 1 commit intomainfrom
pr4644
Oct 3, 2025
Merged

feat: codex exec writes only the final message to stdout#4644
bolinfest merged 1 commit intomainfrom
pr4644

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Oct 3, 2025

This updates codex exec so that, by default, most of the agent's activity is written to stderr so that only the final agent message is written to stdout. This makes it easier to pipe codex exec into another tool without extra filtering.

I introduced #![deny(clippy::print_stdout)] to help enforce this change and renamed the ts_println!() macro to ts_msg() because (1) it no longer calls println!() and (2), ts_eprintln!() seemed too long of a name.

While here, this also adds -o as an alias for --output-last-message.

Fixes #1670


event: response.output_item.done
data: {"type":"response.output_item.done","item":{"type":"message","role":"assistant","content":[{"type":"output_text","text":"fixture hello"}]}}
data: {"type":"response.output_item.done","item":{"type":"message","role":"assistant","content":[{"type":"output_text","text":"model: gpt-5-high
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't look right

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, not sure why that changed...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think Codex was hacking this to fix the test...

}

// If the user has not piped the final message to a file, they will see
// it twice: once written to stderr as part of the normal event
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid this?

@bolinfest bolinfest force-pushed the pr4644 branch 2 times, most recently from 699f147 to e180cd6 Compare October 3, 2025 15:13
This updates `codex exec` so that, by default, most of the agent's activity is
written to stderr so that only the final agent message is written to stdout.
This makes it easier to pipe `codex exec` into another tool without extra filtering.

I introduced `#![deny(clippy::print_stdout)]` to help enforce this change and
renamed the `ts_println!()` macro to `ts_msg()` because (1) it no longer calls
`println!()` and (2), `ts_eprintln!()` seemed too long of a name.

While here, this also adds `-o` as an alias for `--output-last-message`.

Fixes #1670
@bolinfest bolinfest enabled auto-merge (squash) October 3, 2025 15:24
@bolinfest bolinfest merged commit 042d4d5 into main Oct 3, 2025
80 of 88 checks passed
@bolinfest bolinfest deleted the pr4644 branch October 3, 2025 16:22
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: exec --output-last-message to stdout

2 participants