/goal cannot create a new goal in the same thread after previous goal is complete

Resolved 💬 4 comments Opened Jun 16, 2026 by jepson66 Closed Jun 18, 2026

What happened?

After completing a /goal in an interactive Codex thread, the CLI/tooling still refuses to create a second goal in the same thread.

The existing goal is already marked as complete, but creating another goal fails with:

cannot create a new goal because this thread already has a goal; use update_goal only when the existing goal is complete

This is confusing because the goal is already complete. Re-entering/resuming the same thread does not release the goal state.

Expected behavior

Once a thread goal is marked as complete, one of these should be possible:

  1. Creating a new /goal in the same thread, or
  2. A clear built-in command/action to archive/delete/replace the completed goal, or
  3. A clearer error explaining that /goal is intentionally one-per-thread forever.

Actual behavior

The completed goal remains associated with the thread and blocks any subsequent /goal creation. The error message suggests using update_goal only when the existing goal is complete, but the existing goal is already complete.

Local diagnostics

Codex version:

codex-cli 0.131.0

Feature flag:

goals experimental true

Local state observations:

  • ~/.codex/state_5.sqlite contains a thread_goals record for the current thread.
  • The record status is complete.
  • ~/.codex/goals_1.sqlite exists, but its thread_goals table is empty in this environment.
  • The schema in state_5.sqlite has thread_id TEXT PRIMARY KEY, so the thread can only hold one goal record.

Observed schema:

CREATE TABLE thread_goals (
  thread_id TEXT PRIMARY KEY NOT NULL,
  goal_id TEXT NOT NULL,
  objective TEXT NOT NULL,
  status TEXT NOT NULL CHECK(status IN ('active','paused','blocked','usage_limited','budget_limited','complete')),
  token_budget INTEGER,
  tokens_used INTEGER NOT NULL DEFAULT 0,
  time_used_seconds INTEGER NOT NULL DEFAULT 0,
  created_at_ms INTEGER NOT NULL,
  updated_at_ms INTEGER NOT NULL
);

Why this matters

The /goal workflow is useful for phased project work. A common pattern is:

  1. Goal 1: standardize project structure
  2. Goal 2: refactor database access layer
  3. Goal 3: abstract AI providers

Currently, after Goal 1 is complete, Goal 2 cannot be created in the same thread. Opening a new thread loses useful context, and manually deleting local SQLite state is risky and not a reasonable user workflow.

Suggested fix

Support one of the following:

  • Allow create_goal when the existing goal status is complete by replacing/archiving the old record.
  • Add a supported command to clear/archive a completed goal from the current thread.
  • Improve the error message if one-goal-per-thread is intentional.

Environment

  • macOS
  • Codex installed via npm package @openai/codex
  • Version: 0.131.0

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗