Skip to content

feat(codex): wire /goal slash command with mid-turn support#711

Merged
boudra merged 1 commit into
mainfrom
feat-codex-goal-command
May 6, 2026
Merged

feat(codex): wire /goal slash command with mid-turn support#711
boudra merged 1 commit into
mainfrom
feat-codex-goal-command

Conversation

@boudra
Copy link
Copy Markdown
Collaborator

@boudra boudra commented May 4, 2026

Summary

  • Adds optional tryHandleOutOfBand on AgentSession so providers can handle slash commands as side effects, bypassing turn allocation and the activeForegroundTurnId gate. Manager dispatches handler events through recordTimeline + dispatchStream so timeline rows persist.
  • Codex provider implements it for /goal (set / pause / resume / clear), gated to codex >= 0.128.0 with --enable goals. Older binaries don't see the command and don't get the launch flag — no crash, no surprise.
  • Mid-turn /goal pause now works concurrently with a live turn against the same thread.

Why this shape

/rewind allocates a turnId and trips the same active-turn gate, so it isn't a usable model for mid-turn side effects. The new path is genuinely additive: providers opt in by implementing tryHandleOutOfBand, manager routes around turn machinery only when they do. No existing provider changes, no WS schema changes, fully BC-compatible with old clients.

Test plan

  • npm run typecheck clean
  • npm run lint clean
  • E2E codex-goal-mid-turn.real.e2e.test.ts against real codex 0.128.0 — 3 cases, all pass in ~49s:
    • /goal <obj> sets goal; model reads it back via sentinel on a follow-up turn
    • /goal pause mid-turn during sleep 30 — turn finishes with done, ack persisted
    • /goal clear — ack persisted

Known follow-up (not blocking)

mergeAssistantChunks in timeline-projection.ts:193 collapses contiguous assistant_message rows. When /goal pause lands mid-turn, the ack and the resumed model stream are visually glued together in the default projected view. Test asserts against the canonical projection. UI fix is a separate PR.

@boudra boudra force-pushed the feat-codex-goal-command branch from d06092f to 0c23cb6 Compare May 5, 2026 06:57
@boudra boudra closed this May 5, 2026
@boudra boudra force-pushed the feat-codex-goal-command branch from 0c23cb6 to 9f01b4b Compare May 5, 2026 13:12
@boudra boudra reopened this May 5, 2026
Adds optional `tryHandleOutOfBand` on AgentSession so providers can
handle slash commands as side effects without allocating a turn or
tripping the activeForegroundTurnId gate. Codex provider implements it
for /goal (set/pause/resume/clear), version-gated to codex >= 0.128.0
with `--enable goals`. Mid-turn /goal pause now works alongside a live
turn against the same thread.

E2E test against real codex 0.128.0 covers set + mid-turn pause + clear.
@boudra boudra force-pushed the feat-codex-goal-command branch from a196c56 to 676f0f8 Compare May 5, 2026 14:50
@boudra boudra merged commit 6c319d0 into main May 6, 2026
16 checks passed
@boudra boudra deleted the feat-codex-goal-command branch May 6, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant