Marks the active goal complete or blocked.
Hidden until a continue verdict increments turnsUsed, then hidden again when
the goal is complete, blocked, paused, cleared, or resumed into a fresh 0-turn
state.
If invoked while stale, it errors when no active goal exists, the goal has not
been judged, or the goal belongs to another session.
/goal <objective> creates an active goal with empty criteria, current
session ownership, and the configured turn budget.
It sends a kickoff prompt immediately.
A raw prompt containing standing goal plus an <objective>...</objective>
block is adopted as an active goal when no goal exists.
New goals require an idle agent.
Subcommands can run while the agent is busy.
Goal state is stored as append-only custom goal-state entries.
Replay scans backward; newest valid state or clear tombstone wins.
before_agent_start injects the active goal and criteria into the system
prompt for the owning session.
After each owned active goal turn, the extension writes a goal-judge start
entry, shows goal judging N/M in persistent UI, then asks a judge model for
strict JSON:
done, blocked, reason.
The judge sees the objective, criteria, and tail of the latest assistant
response.
Judge completion writes a goal-judge verdict entry and updates the goal
widget/footer with the latest verdict reason.
Continue verdicts stay quiet except for persistent UI.
Complete, blocked, paused, and judge-failed verdicts notify.
Done verdict marks the goal complete and clears persistent
status/widget/footer.
Blocked verdict marks it blocked and keeps persistent UI.
Incomplete verdict increments turnsUsed; exhausted budget pauses the goal.
If still active, continuation is sent when the session becomes idle.
Retry window:
20 attempts, 250 ms apart after the immediate attempt.
update_goal is hidden until the first continue verdict increments
turnsUsed, then hidden again for terminal or paused goals.
/goal pause only pauses active owned goals.
/goal resume rebinds a goal to the current session, sets it active, resets
turnsUsed, and schedules continuation.
/goal complete [reason] is a user override.
Default reason:
marked complete by user.
/goal clear writes a clear tombstone and removes status.
/goal add, /goal remove, and /goal clear-criteria edit criteria on the
current owned goal.
/goal criteria lists criteria.
Empty criteria print No goal criteria.
UI status key:
goal for active, paused, judging, and blocked goals when the shared footer
extension is absent.
Complete/cleared goals clear status and notify instead.
UI widget key:
goal.
Active, judging, paused, and blocked goals show an above-editor widget with
phase, turn progress, objective, and last judge reason.
Shared footer integration:
emits footer:segment id goal when extensions/footer is loaded.
Goals owned by another session show owned by another session; mutating
commands require /goal resume first.
PI_GOAL_PROBE=1 adds /goal-probe and writes custom goal-probe entries
for continuation scheduling checks.
# goal<!-- demo:goal:start -->
<!-- demo:goal:end -->Persistent standing-goal loop for Pi sessions.
## Install / loadLoaded through the root pi-ext package.
See [../../README.md](../../README.md).
## CommandsSubcommands autocomplete.
`/goal remove` autocompletes criterion numbers.
```text/goal
/goal <objective>
/goal status
/goal pause
/goal resume
/goal complete [reason]
/goal clear
/goal add <criterion>
/goal remove <n>
/goal criteria
/goal clear-criteria
```
Debug command, registered only when `PI_GOAL_PROBE=1`:
```text/goal-probe direct|microtask|timeout
```
## Tool```textupdate_goal({ status: "complete" | "blocked", reason: string })
```
Marks the active goal complete or blocked.
Hidden until a continue verdict increments `turnsUsed`, then hidden again when
the goal is complete, blocked, paused, cleared, or resumed into a fresh 0-turn
state.
If invoked while stale, it errors when no active goal exists, the goal has not
been judged, or the goal belongs to another session.
## Settings```json{
"goal": {
"maxTurns": 20,
"judgeModel": "provider/model",
"tailBytes": 4096 }
}
```
- `maxTurns`:
turn budget for a new goal.
Default `20`, clamped to `1..10000`.
- `judgeModel`:
optional Pi model ref, `provider/model`.
When unset, the current session model is used.
- `tailBytes`:
bytes read from the latest assistant response for judgment.
Default `4096`, clamped to `512..65536`.
## Hooks```textsession_start
before_agent_start
agent_start
agent_end
session_shutdown
```
## Behavior- `/goal` and `/goal status` print current goal status.
- `/goal <objective>` creates an active goal with empty criteria, current
session ownership, and the configured turn budget.
It sends a kickoff prompt immediately.
- A raw prompt containing `standing goal` plus an `<objective>...</objective>`
block is adopted as an active goal when no goal exists.
- New goals require an idle agent.
Subcommands can run while the agent is busy.
- Goal state is stored as append-only custom `goal-state` entries.
Replay scans backward; newest valid state or clear tombstone wins.
- `before_agent_start` injects the active goal and criteria into the system
prompt for the owning session.
- After each owned active goal turn, the extension writes a `goal-judge` start
entry, shows `goal judging N/M` in persistent UI, then asks a judge model for
strict JSON:
`done`, `blocked`, `reason`.
- The judge sees the objective, criteria, and tail of the latest assistant
response.
- Judge completion writes a `goal-judge` verdict entry and updates the goal
widget/footer with the latest verdict reason.
- Continue verdicts stay quiet except for persistent UI.
Complete, blocked, paused, and judge-failed verdicts notify.
- Done verdict marks the goal complete and clears persistent
status/widget/footer.
Blocked verdict marks it blocked and keeps persistent UI.
- Incomplete verdict increments `turnsUsed`; exhausted budget pauses the goal.
- If still active, continuation is sent when the session becomes idle.
Retry window:
20 attempts, 250 ms apart after the immediate attempt.
- `update_goal` is hidden until the first continue verdict increments
`turnsUsed`, then hidden again for terminal or paused goals.
- `/goal pause` only pauses active owned goals.
- `/goal resume` rebinds a goal to the current session, sets it active, resets
`turnsUsed`, and schedules continuation.
- `/goal complete [reason]` is a user override.
Default reason:
`marked complete by user`.
- `/goal clear` writes a clear tombstone and removes status.
- `/goal add`, `/goal remove`, and `/goal clear-criteria` edit criteria on the
current owned goal.
- `/goal criteria` lists criteria.
Empty criteria print `No goal criteria.`
- UI status key:
`goal` for active, paused, judging, and blocked goals when the shared `footer`
extension is absent.
Complete/cleared goals clear status and notify instead.
- UI widget key:
`goal`.
Active, judging, paused, and blocked goals show an above-editor widget with
phase, turn progress, objective, and last judge reason.
- Shared footer integration:
emits `footer:segment` id `goal` when `extensions/footer` is loaded.
- Goals owned by another session show `owned by another session`; mutating
commands require `/goal resume` first.
- `PI_GOAL_PROBE=1` adds `/goal-probe` and writes custom `goal-probe` entries
for continuation scheduling checks.