goal
extension
Codex-style persisted thread goals with a hardened autonomous continuation loop and visible completion/stop summaries
automationcoregoal-seekingloopproductivitysession
Open Settings → Add-Ons and pick goal
Source: addons/goal

Codex-style persisted thread goals for Piclaw.

Requires Piclaw >=2.0.0.

This add-on replaces the older prompt-template goal loop with a high-fidelity port of Codex CLI's goal model: a per-chat/thread goal record, Codex-compatible model tools, /goal user controls, budget accounting, and continuation/budget-limit prompts derived from Codex's upstream logic.

Install

Open Settings → Add-Ons and install goal from the catalog.

What it does

/goal command

Tool contract

get_goal

Read the current thread goal and usage state.

json
{}

Returns:

json
{
  "goal": {
    "threadId": "web:default",
    "goalId": "...",
    "objective": "Ship the feature",
    "status": "active",
    "tokenBudget": 100000,
    "tokensUsed": 1234,
    "timeUsedSeconds": 42,
    "createdAt": "2026-05-27T...Z",
    "updatedAt": "2026-05-27T...Z"
  },
  "remainingTokens": 98766,
  "completionBudgetReport": null,
  "terminalGuidance": [
    "If the full objective is verified complete, finish the goal by calling goal_complete({ summary, evidence }) when available.",
    "Codex-compatible completion path: update_goal({ status: \"complete\", summary, evidence }) also marks the goal complete and should be used if goal_complete is unavailable or not selected."
  ]
}

create_goal

Create a new active goal only when explicitly requested. It fails if a goal already exists.

json
{
  "objective": "Ship the feature",
  "token_budget": 100000
}

goal_complete

Preferred completion tool. Use only as the final action when the full objective is verified complete:

json
{
  "summary": "Feature shipped and verified.",
  "evidence": ["bun test passed", "commit abc123 pushed", "microVM UI check passed"]
}

goal_complete records evidence and marks the goal complete. After it succeeds, the agent should send a concise final answer to the user instead of ending the turn with only the tool call.

goal_stop

Stop the autonomous loop without marking the goal complete:

json
{
  "reason": "plan_complete_unverified",
  "summary": "Plan is checked off but completion evidence is insufficient.",
  "evidence": ["all plan items completed", "missing deployment verification"]
}

Use this when completion is unverified, progress is stuck, user input is required, or external state blocks progress. It marks the goal stopped; after it succeeds, the agent should explain the stop to the user instead of ending the turn with only the tool call.

update_goal

Codex-compatible terminal tool. Use this when following upstream Codex goal policy or when goal_complete is unavailable/not selected:

json
{
  "status": "complete",
  "summary": "Verified against tests and PR state.",
  "evidence": ["bun test passed", "commit abc123 pushed"]
}
json
{ "status": "blocked", "summary": "The same external service outage blocked three consecutive goal turns." }

Prefer goal_complete for verified completion when it is available because it requires evidence explicitly, but update_goal({ "status": "complete" }) is intentionally kept as the Codex-compatible completion fallback. Both completion paths record terminal metadata and end the autonomous goal loop, but they deliberately do not early-terminate the Piclaw turn; the agent still needs to produce a user-facing final answer. update_goal intentionally cannot pause, resume, clear, budget-limit, stop, or usage-limit a goal. Those status transitions are controlled by the user, runtime, or goal_stop.

Status model

The add-on uses Codex's status vocabulary:

Status Meaning
active goal is live and auto-continuation can proceed
paused user paused the goal
blocked model verified the strict repeated-blocker audit
usage_limited reserved for runtime usage-limit integration
budget_limited token budget was exhausted
complete model verified the objective is achieved
stopped autonomous loop was stopped without verified completion

Settings pane

Open Settings → Goal to:

The pane uses /agent/addons/api/goal/goal?chat_jid=.... The add-on stores no secrets and does not use the keychain.

The prompt templates are intentionally no longer editable. The add-on embeds Codex's goal prompt policy so behaviour stays faithful to the upstream goal logic.

Storage model

What Where
Current thread goal Extension KV (goal, chat scope, key thread-goal)
Settings pane state Browser state only

Each goal has a durable lifecycle_generation. Every status transition advances it and clears any prior deadline checkpoint; replacement creates a new goal identity, while ordinary accounting and bookkeeping saves preserve both the current lifecycle identity and checkpoint. This invalidates checkpoints across pause/resume, complete/stop/reactivation, blocked, usage-limited, and budget-limited transitions without preventing an idempotent retry of the same already-claimed successor.

Deadline checkpoint expiry is fail-closed. A checkpoint is valid only while expires_at is strictly later than the current clock; equality is expired. Generated leases live for at least one minute and at most five minutes. Malformed timestamps, deadline values more than five minutes ahead of or behind the current clock, and expiry values more than five minutes ahead are treated as invalid clock skew and suppressed. Persisted checkpoint IDs and ownership counters must also be non-empty bounded IDs and safe integers; malformed evidence is cleared only at an invalidation boundary.

Scheduled and claimed checkpoint evidence survives process restart. The same exact claimed successor may retry within its lifecycle and expiry window, including after a crash. A matching scheduling retry is idempotent and cannot change claimed evidence back to scheduled. Claimed evidence is consumed only after the successor reaches a successful agent_end; hard-error outcomes retain it for retry. Pause, terminal transitions, replacement, expiry, or malformed ownership invalidate it.

Runtime checkpoint state is bounded to 1,024 live leases and exact-turn suppressions. Expired entries are pruned and suppressions also have expiry timers. At capacity, Goal rejects a new checkpoint latch rather than evicting live duplicate-prevention state.

Notes