feat(codex): wire /goal slash command with mid-turn support#711
Merged
Conversation
d06092f to
0c23cb6
Compare
0c23cb6 to
9f01b4b
Compare
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.
a196c56 to
676f0f8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tryHandleOutOfBandonAgentSessionso providers can handle slash commands as side effects, bypassing turn allocation and theactiveForegroundTurnIdgate. Manager dispatches handler events throughrecordTimeline + dispatchStreamso timeline rows persist./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./goal pausenow works concurrently with a live turn against the same thread.Why this shape
/rewindallocates 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 implementingtryHandleOutOfBand, 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 typecheckcleannpm run lintcleancodex-goal-mid-turn.real.e2e.test.tsagainst 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 pausemid-turn duringsleep 30— turn finishes withdone, ack persisted/goal clear— ack persistedKnown follow-up (not blocking)
mergeAssistantChunksintimeline-projection.ts:193collapses contiguousassistant_messagerows. When/goal pauselands 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.