Add --goal support to codex exec
Resolved 💬 5 comments Opened Jun 8, 2026 by earonesty Closed Jun 9, 2026
Feature request
Add baseline goal support to codex exec, exposed as a root-level flag:
codex exec --goal "here's a goal" "start working"
This is separate from resume support. The requested behavior is for a new codex exec thread to start with an active persisted goal before the initial user turn is submitted.
Proposed behavior
- Accept
--goal <OBJECTIVE>oncodex execwhen starting a new exec thread. - Persist the goal as active before the first turn.
- Make the goal objective visible to the first model request.
- Reject
--goalfor paths where a new persisted goal cannot be cleanly established, such as exec subcommands and ephemeral threads.
Implementation sketch
I put together a small implementation branch here:
https://github.com/openai/codex/compare/main...earonesty:codex/exec-goal-flag?expand=1
The implementation adds codex exec --goal <OBJECTIVE>, sets the active thread goal through thread/goal/set, suppresses idle goal continuation for this setup path so the initial prompt remains the first turn, and passes the goal objective into the initial turn as untrusted additional context.
Testing included in the implementation branch
- CLI parsing coverage for
--goal - exec integration test verifying the goal is set before the initial turn and reaches the model request
- rejection tests for
--goalwith--ephemeraland exec subcommands - regenerated app-server protocol schema for the small
thread/goal/setsetup flag
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗