OpenAI Cookbook / Codex Goals
01 / 09
English briefing deck

Codex
Goals

Persistent objectives that turn uncertain multi-step work into a verified continuation loop.

Source: developers.openai.com/cookbook/examples/codex/using_goals_in_codex
Core idea
02 / 09
Thesis

Not a bigger prompt.
A persistent objective.

What changes
Completion contract

A Goal keeps the target visible across turns: what should be true, how success will be checked, and which constraints must stay intact.

Bounded autonomy

The user defines the outcome. Codex follows evidence inside that scope, then completes, pauses, clears, or stops at a blocker or budget limit.

Prompt: ask → work → result → wait
Goal: work → check → continue or complete

Model shift
03 / 09
Diagram comparing one-off prompts with active Goals
From prompts to outcomes

Prompts stop. Goals check.

Finish line

The objective persists until the evidence says complete or blocked.

Verification

Tests, benchmarks, logs, artifacts, or source material become the audit surface.

Constraints

Correctness, APIs, files, tools, and budget remain explicit.

How to write one
04 / 09
Six-part contract

A strong Goal defines what “done” means.

01 Outcome

What should be true when the work is finished.

02 Verification

The test, benchmark, report, artifact, or command output that proves it.

03 Constraints

What must not regress while Codex works.

04 Boundaries

Allowed files, tools, data, repositories, and resources.

05 Iteration policy

How Codex chooses the next best action after each attempt.

06 Blocked stop

When to stop and report attempted paths, evidence, blocker, and needed input.

Quickstart
05 / 09
Lifecycle in practice

Start, steer, verify, then stop honestly.

Install

npm install -g @openai/codex@latest

Set

/goal Reduce p95 latency below 120 ms…

Work

Codex inspects code, runs commands, and changes the smallest useful thing.

Check

Benchmarks and tests decide whether the target is met.

Continue

If the evidence is not enough, Codex chooses the next action.

Control

/goal pause · resume · clear

Goals are available starting in Codex 0.128.0, per the source article.
Architecture
06 / 09
Thread-scoped, bounded, auditable

Goals persist inside the current thread, not everywhere.

Thread state

The objective belongs to the thread where files, logs, diffs, and reasoning already live.

Goal thread architecture diagram
Continuation gates

Codex continues only when the thread is idle, active, within budget, and no user input is queued.

Goal lifecycle and continuation gates
Evidence audit

Completion requires concrete files, tests, logs, benchmarks, artifacts, or research evidence.

Safety boundary

Budget limits and lifecycle controls prevent infinite loops and preserve user authority.

The template
07 / 09
If you only remember one thing

This is the Goal pattern.

Photo moment

Read it once. Take a photo. This example came directly from friends at OpenAI.

/goal syntax worth memorizing

/goal <end state> verified by <evidence> while preserving <constraints>.
Use <scope>. Between tries, <decision rule>.
If blocked, <report why>.

Weak
08 / 09
Vague objective

/goal Improve performance

No finish line. No verification surface. No constraint. Codex cannot know whether to stop, continue, or report uncertainty.

Strong
Auditable
Measurable contract

/goal Reduce p95 latency below 120 ms…

Verified by the checkout benchmark, while keeping the correctness suite green. If blocked, report attempted paths, evidence, blocker, and next input needed.

Closing
09 / 09

Let the objective persist.
Let evidence decide.

Takeaways
End
01

Use Goals for uncertain paths

Debugging, optimization, migrations, flaky tests, benchmarks, and research audits.

02

Write the evidence first

Name the outcome, audit surface, constraints, boundaries, iteration policy, and blocked stop.

03

Do not hide uncertainty

If proof is partial, call it partial. If blocked, say what would unlock progress.