Codex CLI: Persistent /goal Workflows for Long-Horizon Agent Tasks
Codex CLI 0.128.0 introduced persistent /goal workflows, allowing users to assign Codex a long-horizon objective that it will autonomously pursue across multiple turns until achieved β or until the configured token budget is exhausted. The feature follows the "Ralph loop" pattern, with full lifecycle management via /goal pause, /goal resume, and /goal clear commands. Goal state (pursuing, paused, achieved, unmet, budget-limited) is surfaced in the TUI and persisted through app-server APIs, enabling both interactive and headless long-running agent workflows.
Sources & Mentions
5 external resources covering this update
Codex CLI Gets Persistent Agent Goals
Codex CLI 0.128.0 introduces one of the most significant agentic capabilities to date: persistent /goal workflows. The feature gives users a structured way to assign Codex an ongoing objective β and have it keep working autonomously until that goal is genuinely completed, rather than stopping after a single turn or requiring manual restarts.
The concept mirrors what the developer community has called the "Ralph loop" β an iterative agent execution pattern where the agent re-evaluates its progress, continues toward the objective, and only stops when it can verify completion or hits a defined resource limit.
How /goal Works
To set a goal, a user types /goal <objective> in the Codex CLI TUI. From that point, Codex enters a self-directed loop: at the end of each turn, two automatically injected prompt templates β goals/continuation.md and goals/budget_limit.md β guide the model to assess whether the goal has been met. If not, Codex continues working.
The goal lifecycle supports four commands:
/goal <objective>β creates and activates a new goal/goal pauseβ suspends work while retaining the goal state/goal resumeβ resumes work toward a paused goal/goal clearβ discards the current goal entirely
The TUI surfaces the goal's current status in real time, with states including pursuing, paused, achieved, unmet, and budget-limited.
Token Budget Controls
Because autonomous looping can consume significant tokens, OpenAI built in explicit budget controls. When the configured token budget is exhausted, the goal enters a budget-limited state rather than continuing unchecked. This gives users predictable cost boundaries for long-running agent tasks without needing to monitor every turn manually.
App-Server and Runtime Integration
The /goal system is fully integrated with Codex's app-server APIs, enabling goals to be created and managed programmatically β not just through the interactive TUI. Runtime continuation means goals can survive session handoffs and remain active across reconnections, making the feature viable for background and scheduled workflows as well.
Why This Matters
Prior to this release, running Codex on a multi-step task required either manual turn-by-turn prompting or building custom automation wrappers. The /goal system makes long-horizon agent work a first-class, discoverable CLI feature. A developer can now tell Codex to "land all open PRs with passing tests" or "fix all failing tests in this repo," and Codex will keep iterating β checking its own progress and re-engaging β until the objective is verified complete or the budget runs out.