Skip to content

feat: a goal pauses while its thread waits on you or on threads it started - #1004

Merged
badcuban merged 5 commits into
mainfrom
feat/goal-pause-while-waiting
Nov 19, 2026
Merged

badcuban merged 5 commits into
mainfrom
feat/goal-pause-while-waiting

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

A Codex goal kept spending turns while its thread waited. When the agent asked for something through a card (threads to start, a scheduled task, a settings change, an invite, a command to run) it got control back at once, and the goal ran turns that could only say "still pending": three before Codex marked it blocked, and more after Start while the started threads worked.

Now the goal pauses while the thread waits on a card or on threads it started, and carries on when the wait ends:

  • The rule is in packages/shared/src/goalWaitPause.ts, from the same facts the sidebar reads. The decider applies it on a new server-only command, thread.goal.wait.sync, which the new GoalWaitReactor sends when a wait or the goal changes. It also looks at every goal once at startup.
  • Only our own pause is undone. The goal carries an optional mark, waitPause: paused, resuming (kept until Codex confirms, so a restart resends it), or user. It is not a new status value, so older clients aren't affected. When the user pauses, resumes, edits, clears or stops during a wait, nothing automatic happens until that wait is over.
  • No race with our own turns. Resuming an idle Codex goal starts a goal turn at once. So the resume waits while a turn is about to start, including a report or command output waiting in the queue. The report then carries the goal forward in its own turn.
  • Codex gets thread/goal/set with origin: "automatic", the same message the pause before Stop already sends. The provider reactor sends it only while the goal still carries our intent.
  • Claude is left alone: its goal is a Stop hook inside one turn and has no pause. The other agents have no goals.
  • The goal bar says "Paused until you answer" or "Paused while its threads work", and Resume and clear still work.

This goes one step past "pause while its card waits": live, after Start, the goal kept running turns while the started threads worked, so that wait is covered too.

Checked live on a throwaway setup with Codex. The goal paused 40 ms after the card appeared, and no turns ran while the card waited or the thread worked. The report came back as one turn, the goal resumed 40 ms into it, and it completed inside that turn.

Design: docs/design/goal-wait-pause.md.

…arted

A Codex goal whose agent asked for something through a card (threads to
start, a scheduled task, a settings change, an invite, a command to run)
kept running turns that could only say "still pending", and again while
the threads it started worked. Threadlines now pauses the goal while the
thread waits and resumes it when the wait ends.

- goalWaitOf/goalWaitStep (shared) say what the thread waits on and what
  the goal should do; the decider applies them on the server-only
  thread.goal.wait.sync, sent by the new GoalWaitReactor.
- The pause is marked on the goal (pausedForWait, optional) and sent to
  Codex with origin automatic. The user's own pause, resume, edit or clear
  drops the mark; a goal that completes or hits a limit loses it.
- A resume waits while a turn is about to start, so a report never gets a
  second goal turn beside it.
- The goal bar says "Paused until you answer" or "Paused while its threads
  work". Claude's goals have no pause and are left alone.
…under way

A report from a thread the agent started settles its request and waits in
the queue in one decision, then goes out a moment later. Resuming the goal
in that gap let Codex start a goal turn first, with the report steered into
it. A message waiting in the queue now counts as a turn about to start, so
the resume lands after the report's own turn starts and the goal carries on
inside it (seen live: one turn, resume 44 ms after it started).
…-waiting

# Conflicts:
#	apps/server/src/orchestration/decider.ts
- The mark has three states: paused (ours), resuming (sent, until the
  provider reports the goal active, so a restart in between resends it),
  and user (the user acted during the wait). A resume the user made while
  a card still waited was paused again as soon as Codex confirmed it; the
  user mark keeps their choice until that wait is over, including a pause
  that landed before ours.
- Stop marks the goal the user's, so the waits Stop ends never resume it.
- A command's output on its way still counts as a wait: the run's finish
  is recorded a moment before the output goes back.
- The reactor also watches reverts and agents leaving.
- The reactor reports each user goal action and Stop (userActed), so a
  pause the user made where the only wait is a scheduled-task card, which
  the decider can't see, is theirs for that wait.
- A resume not yet confirmed is sent again only on the reactor's startup
  pass (retryResume), never on every look.
- A new wait before a resume was confirmed sends the pause, so the resume
  still on its way doesn't win.
- The provider reactor sends an automatic pause or resume only while the
  goal still carries that intent: a goal the user took over, or that the
  provider ended or blocked since, is left alone.
@vercel

vercel Bot commented Nov 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Nov 19, 2026 12:31am UTC

Request Review

@badcuban
badcuban added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 67ebab1 Nov 19, 2026
24 checks passed
@badcuban
badcuban deleted the feat/goal-pause-while-waiting branch November 19, 2026 00:48

This branch was previously deployed

1 inactive deployment
Preview — 78f7a3f6 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant