Codex CLI 0.128.0 Released: /goal Command Enables Automatic Looping Until Objective is Complete

OpenAI Codex CLI ships /goal command for autonomous agent looping until objectives are achieved
OpenAI Codex CLI 0.128.0 introduces the /goal command, allowing agents to autonomously loop after users set an objective, continuing until the goal is complete or the token budget is exhausted. This feature is the official implementation of the community's Ralph Loop pattern, driven by prompt engineering (continuation.md and budget_limit.md templates), marking the evolution of coding agents from single-turn interactions to goal-driven autonomous execution.
Overview
OpenAI's Codex CLI coding agent tool has released version 0.128.0, introducing a significant new feature: the /goal command. This feature allows users to set an objective, and Codex will continuously loop through task execution until it evaluates the goal as complete, or until the configured token budget is exhausted.
Codex CLI is an open-source terminal-native coding agent tool released by OpenAI in 2025. It runs directly in the developer's command-line environment, capable of reading local codebases, executing shell commands, editing files, and running tests. Unlike browser-based AI coding assistants (such as GitHub Copilot Chat or Cursor), Codex CLI adopts a lightweight terminal interaction paradigm that aligns more closely with the workflows of experienced developers. It uses OpenAI's o4-mini model by default while supporting configuration switches to other models. As a fully open-source project (under the Apache 2.0 license), Codex CLI has also become an important testing ground for the community to explore coding agent patterns.
This is essentially OpenAI's official implementation of the Ralph Loop pattern, marking a significant evolution of coding agents from single-turn interactions to continuous autonomous execution.
How the /goal Command Works
Core Mechanism
The design philosophy behind the /goal command is straightforward: users define a clear objective, and the Codex agent automatically enters a loop mode, self-evaluating whether the goal has been achieved after each execution round. If the goal is not yet complete, the agent continues to the next operation until one of two exit conditions is met:
- Goal complete: The agent determines that the user-defined objective has been achieved
- Budget exhausted: The configured token budget has been used up
This "execute—evaluate—decide" loop structure is known as a Control Loop in computer science, widely applied in robotics, automated operations, and other domains. Introducing this pattern into LLM agents means AI coding tools are beginning to possess continuous execution capabilities similar to automated systems, rather than being limited to one-off request-response interactions.
Prompt Engineering-Based Implementation
From a code perspective, this feature is primarily implemented through two prompt templates:
goals/continuation.md: Automatically injected at the end of each round, guiding the agent to evaluate current progress and decide whether to continue executiongoals/budget_limit.md: Handles token budget limitation logic, ensuring the agent can gracefully stop when resources are exhausted
This prompt engineering-based approach doesn't introduce complex external control logic but instead leverages the LLM's own comprehension abilities to manage the execution flow, maintaining architectural simplicity.
Prompt Engineering refers to the technique of carefully designing text instructions fed to large language models to guide them toward desired behaviors. In traditional software, control flow is typically implemented through hard-coded logic like if-else statements and state machines; in LLM agent systems, prompt templates serve as "software logic"—defining agent behavior rules through natural language descriptions. The advantage of this approach is its extreme flexibility: developers can adjust agent behavior by modifying Markdown files without changing the underlying code. However, its disadvantage is equally obvious: behavioral predictability depends on the model's comprehension ability, and different model versions may produce different execution results. Codex CLI's choice of this implementation path reflects the current "Prompt as Code" design trend in AI engineering.
Why the /goal Feature Matters for Developers
The Paradigm Shift from Single-Turn to Multi-Turn
Traditional AI coding assistants typically operate in a single-turn interaction mode: the user asks, the AI answers, then waits for the next instruction. The /goal feature breaks this pattern, enabling agents to autonomously plan and execute multi-step tasks.
This is especially valuable for complex programming tasks. For example, refactoring a large module, implementing a complete feature, or fixing a series of related bugs—these tasks often require multiple steps with logical dependencies between them.
Official Adoption of the Ralph Loop Pattern
The Ralph Loop is a pattern that was already popular in the community—having an AI agent work continuously in a loop until a task is complete. This pattern was proposed and popularized by Australian developer Geoffrey Huntley, named after a straightforward concept: working in continuous loops like a tireless worker (Ralph). The typical implementation involves injecting instructions like "if the task is not complete, please continue to the next step" into the agent's system prompt, combined with external scripts that automatically re-trigger a new conversation round after the agent outputs. Before Codex CLI's official support, developers had already implemented similar loop execution patterns in tools like Claude Code and Aider through shell script wrappers and custom prompt injection. This "community wisdom" being adopted by an official tool is a typical case of healthy interaction between community and vendor in the AI tool ecosystem.
OpenAI's formal integration of this pattern into Codex CLI reflects several industry trends:
- Maturation of Agentic AI engineering: Autonomous agent patterns are moving from experimental concepts to production-grade tools
- Community-driven innovation: Official tools are actively absorbing community best practices
- Importance of token budget management: As agent autonomy increases, resource control becomes more critical
Safety and Control: Token Budget Limitation Mechanism
The /goal feature has a built-in token budget limitation mechanism—a critical safety design. In scenarios where agents autonomously loop, without appropriate stopping conditions, it could lead to unnecessary resource consumption or unexpected behavior.
To understand the importance of this mechanism, one must first understand the concept of tokens. In large language models, a token is the basic unit of text processing, roughly equivalent to 3/4 of an English word or one Chinese character. Each time an LLM processes input and generates output, it consumes tokens, and service providers like OpenAI charge by token usage (for example, GPT-4o's input price is approximately $2.5 per million tokens). In autonomous loop scenarios, each round of agent execution accumulates token consumption—including re-reading context, generating code, performing evaluations, and other steps. If a complex task requires dozens of loops, token consumption can quickly climb to tens or even hundreds of thousands. An agent without budget limits is like a credit card with no spending cap—it may generate costs far exceeding expectations when the developer isn't paying attention. Therefore, token budgets serve as both a technical safety mechanism and an economic safety mechanism.
Budget limits ensure that even if the agent misjudges goal completion, the system can stop within controllable bounds. This reflects the design philosophy of maintaining human control while granting AI more autonomy—for enterprise use cases, this kind of predictable cost control is particularly important.
The Broader Agentic AI Landscape
Codex CLI's /goal feature is a microcosm of the current Agentic AI wave. Agentic AI refers to AI systems capable of autonomously perceiving their environment, formulating plans, executing actions, and adjusting strategies based on feedback—fundamentally different from traditional "passive-responsive" AI assistants. Since 2025, this direction has become the most active competitive frontier in the AI industry: Anthropic's Claude Code supports autonomous execution of complex coding tasks, Google's Jules and Project Mariner explore agent capabilities in browser and code environments, and Microsoft integrates agent mode into VS Code through GitHub Copilot Agent Mode. In the open-source community, projects like Aider, SWE-agent, and OpenHands are also iterating rapidly. The common trend across these tools is: AI is transforming from a "suggester" to an "executor," shifting from answering "how to do it" to directly "doing it." However, this transformation also brings new challenges—how to ensure controllability of agent behavior, how to handle rollbacks when agents make mistakes, and how to balance autonomy with safety—these questions are defining the core issues of next-generation AI engineering.
Summary
Codex CLI 0.128.0's /goal feature represents an important milestone in the development of coding agent tools. It implements autonomous loop logic through concise prompt engineering, enabling developers to delegate larger-grained tasks to AI agents while maintaining necessary control through token budget mechanisms. As features like these become widespread, AI-assisted programming is transitioning from a "Q&A mode" to a "goal-driven autonomous execution mode."
Key Takeaways
- Codex CLI 0.128.0 adds the /goal command, allowing agents to continuously loop until the objective is complete or the token budget is exhausted
- This feature is the official implementation of the community-popular Ralph Loop pattern, marking the evolution of coding agents from single-turn interaction to autonomous execution
- The feature is primarily implemented through two prompt templates (continuation.md and budget_limit.md), leveraging the LLM's own capabilities to manage execution flow
- Built-in token budget limits serve as a safety mechanism to prevent agents from infinitely looping and consuming resources
- It reflects the industry trend of Agentic AI engineering moving from experimental concepts to production-grade tools
Related articles
Tech FrontiersA Rare Quiet Day in AI: Recursive Self-Improvement Stirs Beneath the Surface
A rare quiet day in AI sees multiple sources go silent simultaneously. Behind the calm, Recursive Self-Improvement (RSI) research continues. What this means for the industry.
Tech FrontiersReve 2 vs. Ideogram 4: A Deep Dive into Layout Control in AI Image Generation
A deep comparison of Reve 2 and Ideogram 4's layout control capabilities, covering technical approaches, real-world use cases, and industry trends for designers and creators.
Tech FrontiersIn the Weights: Check Your Influence Score in the AI World
In the Weights is an AI influence search engine that quantifies your presence in the AI world with a score. Explore how it evaluates practitioners and what it means for digital identity.