Skip to content

Unify Conversation status and archive terminology #2888

Open

Description

@sentry-junior

Conversation state is described with overlapping words across execution, Turn records, the API, agent invocations, automations and archive. The same word means different things in different places, and some states project wrongly. Define one status model and one archive model, then use the same words in TERMINOLOGY.md, the public docs, the API and the code. Split out of #2792 (PR 7, status and auto-archive).

Proposal

Worked through by @dcramer in the #2792 discussion, revised after prior-art research and an adversarial review.

Status is derived from runtime state for every Conversation (root, Thread, Task), never from model text. It describes only that Conversation's own work, not its children's.

  • active: execution is pending, running or paused (another slice is due).
  • needs_input: an open action review item added by this Conversation is assigned to a person or to everyone.
  • failed: the latest Turn record failed, or execution is failed.
  • stopped: stopped_at is set, with a stop reason: a person's stop, the parent's stopAgent, or the automated-turn limit.
  • idle: anything else. The Conversation is ready for more input. This replaces completed and done as the Conversation word. completed stays a Turn, invocation and run outcome.

These are idle, not needs_input:

  • A Turn waiting for sign-in. The sign-in prompt is the reply; the person's next message resumes it.
  • A Task whose latest invocation ended blocked. Its parent already has the result. The dashboard shows the invocation result next to the status.
  • A parent that waits for running children. The dashboard tree shows child activity.

Precedence when more than one applies: active > stopped > failed > needs_input > idle.

One rule: status alone decides behavior. The status that shows is the status that acts. How a Conversation got there, the stop reason, and who stopped it are display data only. No other check holds, drops or refuses input, and there are no per-path exceptions.

Held input. stopped and failed hold automated input: Watch Events, top-level agent messages and child results are saved as skipped Messages and start no Turn. Saving held input does not change execution, so a held Conversation never shows active for it. Only a person's input sent after the hold began, or new work from the parent for a child, ends the hold. Answering a review item is person input. The next Turn reads the saved Messages as context.

active, needs_input and idle run input as normal. In every status, each Turn that automated input starts counts toward the automated-turn limit (25). Reaching the limit stops the Conversation with the reason automated-turn limit, so the limit is the loop guard for every status that does not hold input.

Stop. Every stop does the same thing, whatever its reason (a person, the parent's stopAgent, or the automated-turn limit):

  • It stops the Conversation and every descendant. Nothing above it is stopped.
  • Its parent gets a stopped result, unless the parent made the stop.
  • Watches stay. Their Events are held like any other automated input, and a Watch's own expiry still applies.
  • Ending the stop resumes the same subtree.

So a root or Thread that reaches the limit stops its whole tree and posts one notice. A child that reaches its own limit stops its subtree; its parent is not stopped and decides what to do with the stopped result. That result is automated input, so it counts toward the parent's limit.

Archived is a separate flag, not a status. One archived_at per Conversation, shared by everyone. "Resolved" is not a separate word.

  • Only a person's Message restores an archived Conversation. Watch Events and parent work run a Turn and leave it archived.
  • Auto-archive runs only when the Conversation and every descendant are idle or stopped. For a shared Conversation it fires only when it is due for every participant (the longest grace wins). A manual restore by anyone turns auto-archive off for that Conversation.

Not statuses: unread and "ready for review", which are per person. Unread applies to every status except active.

Behavior

Given / When / Then for one Conversation. Each scenario gets an integration test.

Work and replies
  • Given idle, when a person sends a Message, then active until the reply is delivered, then idle.
  • Given active, when the Turn yields, times out, loses its lease or waits for retry backoff, then it stays active.
  • Given active, when the agent replies that it could not do the task, then idle. A failed task is not a failed Turn.
  • Given active, when the Turn ends with a plain-text question and no review item, then idle.
Failure
  • Given active, when the Turn fails on its final attempt, then failed.
  • Given active, when work runs out of retries or is dead-lettered, then failed, and the dropped pending messages are visible.
  • Given failed, when a Watch Event, top-level agent message or child result arrives, then it is saved as a skipped Message, no Turn starts, and it stays failed.
  • Given failed, when a person's Message or new parent work arrives, then active, then the outcome of the new Turn.
  • Given failed with an open action review item, then failed. Answering the item is person input that ends the hold.
Needs input
  • Given active, when the agent adds an open action review item assigned to a person or to everyone and the Turn ends, then needs_input.
  • Given needs_input, when the item is answered, then active for the Turn the answer starts, then the outcome of that Turn.
  • Given needs_input, when the item is dismissed or marked done with no new Turn, then idle.
  • Given needs_input, when a Watch Event arrives, then a Turn runs and counts toward the automated-turn limit.
  • Given an open action item, when the agent keeps working, then active.
  • Given an open action item, when the agent re-adds it with the same dedupe key, then the status does not change.
  • Given an open notice item, or an action item that another Conversation added and only links here, then it does not cause needs_input.
  • Given active, when the Turn waits for sign-in, then idle. When the person signs in, then active for the resumed Turn. When the person sends a new Message instead, the new Turn decides the status.
Automated-turn limit
  • Given 24 automated Turns since the last person Turn, when automated input starts the 25th Turn and it ends, then stopped with the reason automated-turn limit, and one notice says why.
  • Given stopped by the limit, when a Watch Event, top-level agent message or child result arrives, then it is saved as a skipped Message and no Turn starts.
  • Given stopped by the limit, when a person sends a Message, then the stop ends, the count resets, and active.
  • Given a child stopped by the limit, when its parent gives it new work, then the stop ends and the count resets.
  • Given needs_input with an open item, when the limit is reached, then stopped. The item stays open, and its answer is person input that ends the stop.
  • Given an open action item, when the limit is reached, then the item stays open and no further automated Turn runs.
  • Given a root with running children, when the root reaches the limit, then the root and every child below it are stopped with the same reason.
  • Given a child, when it reaches its own limit, then it and its subtree are stopped, its parent gets a stopped result, and the parent is not stopped.
  • Given the parent of a child stopped by the limit, when the parent gets the stopped result, then that Turn counts toward the parent's limit.
Stop
  • Given active, when a person stops it, then active until the run sees the stop, then stopped.
  • Given a root or Thread with children, when a person stops it, then it and every child below it become stopped. Its parent does not change.
  • Given stopped, when a Watch Event, top-level agent message or child result arrives, then it stays stopped, the input is saved as a skipped Message, and status does not flicker to active.
  • Given stopped, when a person's Message sent after the stop arrives, then active for that Conversation and its subtree. A Message sent before the stop does not clear it.
  • Given a stopped child, when its parent gives it new work, then active for that child and its subtree.
  • Given stopped with an open action item or a failed Turn, then stopped.
  • Given any stop reason, then the same Conversations stop, the same input is held, and Watches stay. Only the displayed reason differs.
  • Given a child stopped by a person or the limit, then its parent gets a stopped result. Given a child stopped by its parent's stopAgent, then the parent gets no result.
  • Given a held Conversation, when a person's Message ends the hold, then the new Turn reads the saved skipped Messages as context.
Children
  • Given a parent with a running child, then the parent's status comes from its own work. A parent that waits for results is idle.
  • Given a Task, when its invocation ends blocked, then the Task is idle, and the parent becomes active when it gets the result.
  • Given a Thread, when a person's Turn runs in it, then the Thread's status follows that Turn. No invocation is needed.
Archive
  • Archive does not change status. An archived Conversation keeps its status.
  • Given archived, when a person sends a Message, then it is restored and becomes active. Archived ancestors of a child are restored too.
  • Given archived, when a Watch Event or parent work starts a Turn, then it becomes active and stays archived.
  • Given a tree with any active, needs_input or failed Conversation, then auto-archive skips it.
  • Given a stopped Conversation, auto-archive uses its stop time, because skipped Messages still change its activity time.
  • Given a shared Conversation, when auto-archive is due for some participants but not all, then it stays unarchived.
  • Given a Conversation that anyone restored by hand, then auto-archive is off for it.

Scope

  • TERMINOLOGY.md and the public docs define each status, held input, archived, and the precedence.
  • statusFromConversation and ConversationProjectionSource read the latest Turn record and open action review items, without a per-row query in the feed.
  • API, MCP status enum, MCP docs and dashboard use these words; completed becomes idle with a hard cutover. Unread and auto-archive follow the Behavior section.
  • One hold check, keyed only on status, covers Watch Events, top-level agent messages and child results for stopped and failed. Held input is saved without changing execution.
  • Delete every input check that is not status-based: admitAutomatedTurn dropping Watch Events and refusing top-level agent messages, the child-result bypass, and Events other than Watch Events running on a stopped Conversation.
  • Every stop path (person, stopAgent, limit) uses the same tree stop. stopAgent keeps Watches like a person's stop.
  • Reaching the automated-turn limit sets stopped_at with a stop reason. The limit store keeps only the count; its paused flag goes away.
  • Check that the Turn after a hold reads the saved skipped Messages; fix it if it does not.
  • Agent invocation blocked and the Add subagent context, lifecycle controls, and execution limits #881 TODO stay invocation results; they do not map to a Conversation status.
  • Archive uses one column; per-person and child archive columns go away, and the legacy column is cleared in the same migration. The list filter rename and the search tool description land with the shared-archive PR in Add Threads: child conversations people can talk to #2792.
  • Each Behavior scenario is covered by an integration test through real wiring, added to the owning scenario.
  • Out of scope: automation and review-item statuses keep their own words. The per-parent invocation limit for spawn → result → spawn loops stays in Add subagent context, lifecycle controls, and execution limits #881.

Background

Today (checked against main 084746384, 5187ebf)
  • Execution status (chat/task-execution/state.ts): pending, running, paused, failed, idle.
    • paused means "needs another slice": requestAnotherSlice sets it on yield, timeout, retry backoff, lost lease, and input that arrives under a lease.
    • failed is set only when retries run out (CONVERSATION_WORK_MAX_RETRIES, pending messages dropped) or work is dead-lettered. The next input of any kind starts a new Turn.
  • Turn records (turn-cursor.ts) hold what execution does not:
    • A sign-in wait is a Turn with state: paused, resumeReason: auth. The worker breaks out and completeConversationWork writes execution idle, so the Conversation shows completed.
    • A Turn that fails on its final attempt is marked failed, but execution goes idle, so the Conversation shows completed.
    • dispatchOutcome: "blocked" records a reportBlocked.
  • API status (conversationReportStatusSchema, MCP api/mcp/conversation.ts): active, completed, failed, stopped. statusFromConversation (api/conversations/projection.ts) reads execution status and stoppedAtMs only. MCP docs tell clients to poll until status is not active.
  • Stopped (fix(conversations): Stop child agents when a person stops the parent #2832, TERMINOLOGY.md, chat/conversations/session-stop.ts): Watch Events are saved as one skipped Message and start no Turn. Other Events received after the stop still run. Only a person's input sent after the stop, or new parent work for a child, clears it for that Conversation's subtree. A stop covers the Conversation and every child below it; a stopped child reports stopped to its parent unless the parent stopped it. A person's stop keeps Watches; stopAgent cancels them. Each skipped Watch Event briefly makes execution pending, so status flickers stopped → active → stopped.
  • Automated-turn limit (chat/services/automated-turn-limit.ts, maxConsecutiveAutomatedTurns = 25): stored outside the Conversation row with a TTL; not in status.
    • At the limit, admitAutomatedTurn drops Watch Events (nothing saved, no Turn) and refuses top-level agent messages. A notice is posted once.
    • Child results bypass it (enqueueAgentInvocationResult) but count toward it.
    • A person's Turn, or a task or message from the parent for a child, resets it.
  • Agent invocations: pending, running, paused, completed, blocked, failed, stopped. A child's sign-in wait becomes a terminal blocked invocation, and the parent wakes with the result. A TODO in agent-invocations/result.ts plans an unbuilt needs_input event (Add subagent context, lifecycle controls, and execution limits #881).
  • Automations: active, blocked, paused, completed; run status blocked, completed, failed. paused means a person paused the automation. Agent dispatch also has blocked.
  • Review items: open, done, dismissed; kind notice or action; can be assigned to everyone, linked to many Conversations, and re-added by dedupe key. An agent may keep working while one is open.
  • Archive has three stores: per-person junior_conversation_participants.archived_at, junior_conversations.child_archived_at, and the legacy junior_conversations.archived_at (legacyArchivedAt, "must not read or write", stale data). Add Threads: child conversations people can talk to #2792 decides that archive applies to everyone and that resolved and archived are the same state.
  • Auto-archive (auto-archive.ts) is per person: each user's default and grace hours, a per-Conversation override on the participant row, "a new human message restores it", and "manual restore turns auto-archive off". It skips any tree that is not execution idle.
  • Unread applies only to completed and stopped (projection.ts).
  • The list API filter is status: "active" | "archived", and the search tool describes it as "not archived", so active also means "not archived".
Prior art

From official docs for Claude Code agent view, Claude Managed Agents, OpenAI Assistants/Responses, Cursor Cloud Agents, Devin, Factory, Jules, LangGraph, Temporal, A2A, MCP tasks and ACP.

  • Long-lived, resumable containers say idle when ready for more input: Claude Code agent view (Working, Needs input, Idle, Completed, Failed, Stopped), Claude Managed Agents ("a session that completes its work goes idle"), Factory, LangGraph threads. completed almost always means one run or task that has ended for good.
  • One "needs input" state covers questions, permission and approval in Claude Code, MCP, Devin and Jules. Only A2A splits AUTH_REQUIRED from INPUT_REQUIRED.
  • Every source keeps a person's stop apart from failure. Protocols say cancelled; Claude Code says Stopped.
  • Archive is a flag everywhere (Cursor ARCHIVED blocks new runs; Devin is_archived; Factory archivedAt). Nobody uses "resolved". Unread and "ready for review" are per-person flags or groups, never a status.

via @dcramer.

--

View Session [Sentry]

Activity

  1. dcramer commented on Nov 7, 2026

    @dcramer
    Member

    I think things like automated turn limit would probably transition to needs_input? like if it interrupts your run because its hit its constraint that's just blocked at that point

  2. sentry-junior commented on Nov 7, 2026

    @sentry-junior
    ContributorAuthor

    Concerns from an implicit-state-machine pass, limited to Conversation status. Checked at 5187ebf.

    The proposal derives status from five inputs with a precedence rule: execution status, stopped_at, the latest Turn record, open action review items, and the automated-turn limit. That only holds up if exactly one place computes it. Today the derivation is already copied, and the inputs live across Redis, SQL and a TTL'd side key.

    1. Status is re-derived in several places, two of them in SQL. statusFromConversation (api/conversations/projection.ts:129), the aggregate active/failed counts (api/conversations/aggregate.ts:80-95), the auto-archive filter (api/conversations/auto-archive.ts:144), plus raw executionStatus passthrough in api/locations/query.ts, api/people/shared.ts and chat/agent-invocations/search-top-level.ts. Adding needs_input (review items) and failed (latest Turn record) to each copy is where drift starts. Suggestion: persist a status column, written only by one deriveConversationStatus() on every write that changes an input (execution write, stop, review item open/close, Turn finish, limit). Feed, counts and auto-archive read the column. This also satisfies the "no per-row query" scope bullet.

    2. "Latest Turn record" is not one thing today, and it expires. Turn state lives in the per-Turn cursor record, a separate TurnSummary index, and the SQL execution copy; readers reconcile them (chat/task-execution/mailbox-turn.ts:136-180, turn-cursor.ts:1029-1050). A terminal cursor record has a 1h TTL (TURN_CURSOR_TERMINAL_TTL_MS, turn-cursor.ts:59), the index 24h. If failed is derived from the Redis record, the status silently flips failed → idle an hour later. Drift between the record and the summary already caused JUNIOR-9M (aaf51a505). Suggestion: the Turn's terminal outcome feeds the persisted status at the moment it is written, not read back later. Related: nothing stops a terminal Turn going back to running (upsertTurnRecordLocked has no terminal or version check; saveRunning in checkpoint.ts:245-257), so a late worker can resurrect a failed Turn.

    3. The hold check runs after the state transition, which is the root cause of the flicker. Appending input moves execution to pending (chat/task-execution/state.ts:1253-1262); the stop check runs later in the worker (chat/conversations/session-stop.ts:139) against stoppedAt in SQL. So "stopped → active → stopped" is built in, and the precedence exception ("held keeps its status when only automated input is pending") patches over the same ordering. Suggestion: decide hold inside the append mutation, under the same lock, so held input becomes a skipped Message and never sets pending. Then the exception can go. That needs the hold (stop, failed marker) readable inside that lock; today stop is spread over a Redis stop key, a stop-only runId, and SQL stoppedAt (state.ts:1966-2058), and conversations/stop.ts:41-57 has to make a sign-in wait runnable just to stop it.

    4. Execution status is itself derived, and the SQL copy is last-writer-wins. About 14 mutators write status directly with their own rules. executionWithPendingMessages / normalizeExecution (state.ts:502-508, 636-650) repair idle+lease into running and idle+pending into pending. failed with pending messages is still runnable (state.ts:623-634), and the duplicate-upgrade append path keeps failed while adding pending input (state.ts:1225-1228). The SQL mirror, which every dashboard status reads, is reconciled by execution.updatedAtMs plus an olderRunFinished metrics lookup (chat/conversations/sql/store.ts:527-547, :873; see 30f8b2cab). So "failed until new input clears it" depends on that race resolving the right way. Suggestions: make failed+pending unrepresentable (input either clears failed or is held), and add a scenario where an older run's terminal write lands after a newer run starts.

    5. paused means three things. Execution: "another slice is due". Turn record: sign-in wait (resumeReason: auth). automated-turn-limit.ts:23: the paused flag, which really means stopped. (Bonus: local stopped in state.ts:2300, :2525 means "retries exhausted → failed".) The proposal already drops the limit's flag; I'd also rename execution paused (e.g. yielded / backoff) so it doesn't leak into status reasoning.

    6. On the limit going to needs_input (comment above). That works if hitting the limit opens an action review item ("hit 25 automated turns, continue?"). Then needs_input keeps one source, and answering it is the person input that resets the count. Mapping the limit to needs_input without an item gives needs_input a second derivation source, which is the implicit-state shape this issue is trying to remove. Either way, the limit state shouldn't live only in a TTL'd key: today both the count and the flag expire with JUNIOR_THREAD_STATE_TTL_MS, which can silently end the hold.

  3. dcramer commented on Nov 9, 2026

    @dcramer
    Member
  4. sentry-junior commented on Nov 17, 2026

    @sentry-junior
    ContributorAuthor

    Input that arrives while a Conversation is stopped, and what runs when the stop ends

    This is the follow-up from #3435. It extends the Held input and Stop rules above with one rule for each input kind and a rule for mixed identities.

    Checked at main 8edf24ddb and at the #3435 head 77c6cf93f (flag child-agents-without-agent-invocations on). Paths are under packages/junior/src/chat/. "Tested" means a throwaway integration test through real wiring (Postgres, Redis, the real worker, a fake runner). I did not commit it. "Inferred" means code reading only.

    Summary

    • The known gap in feat(agents): Spawn and message child agents without Agent invocations #3435 and in the design doc of docs(design): Add the child agents design doc #3597 is wrong as written. A task that waited in a grandchild's mailbox at the stop does not run after the stop ends. That is true on main and with the flag on (tested).
    • With the flag on, the real problem is the opposite: new work is lost. The grandchild's next Turn takes the old task and a new task from after the stop in one batch. A stop request that is left over from the tree stop cancels that Turn. The new task never runs (tested).
    • With the flag on, parent messages from different Actors share one child Turn. The Turn runs as the Actor and with the credentials of the first message (tested). This breaks "input from different people never shares a Turn".
    • Claude and Codex both keep the work of one person after an interrupt. Claude runs it next. Codex gives it back to the person to send again. Neither product joins input from different people into one turn. Neither documents what happens to a grandchild's queue.
    • Proposed rule: a stop cancels all waiting work in the tree when the stop happens. While stopped, automated input is held as context. Only the input that ends the stop starts a Turn, and that Turn acts only for its own Actor.

    Current behavior

    When the stop happens

    • The tree stop sets stopped_at on each Conversation and writes a stop request for each Conversation that has waiting work (agent-invocations/stop.ts:255-268, task-execution/state.ts:2051-2090). The stop request is keyed by the Conversation's run id. It lists only person input, and only that input is removed when a worker clears the stop (state.ts:2066-2071, :2093-2144).
    • On main, the tree stop also marks each open Agent invocation stopped and each unread result skipped (stop.ts:475-523). A worker ends a stopped Agent invocation without a run (agent-invocations/work.ts:756-760).
    • With the flag on, a parent message has no row to mark. The stop ends its subagent_started marker, but the message stays in the mailbox (feat(agents): Spawn and message child agents without Agent invocations #3435 stop.ts, finishStoppedTree).

    While stopped, by input kind

    Input What happens today Evidence
    A person's message sent after the stop Ends the stop for the whole subtree and runs. conversations/session-stop.ts:135-148, :97-118
    A person's message sent before the stop, received after Runs, and the Conversation stays stopped. The code calls this a known gap. session-stop.ts:142-143
    A person's message waiting at the stop Dropped when the worker clears the stop. state.ts:2093-2144
    Watch Event Saved as one skipped Message. No Turn. session-stop.ts:157-186
    Other Event, including a message from a top-level agent Received at or before the stop: dropped. Received after: starts a Turn on the stopped Conversation (inferred, also listed in this issue's Background). The only gate for a top-level agent message is the automated-turn limit. session-stop.ts:194-202, agent-invocations/top-level-message.ts:118-169
    Batch that mixes Events with other input Not filtered. session-stop.ts:150-152
    New work from the parent Ends the stop for the child's subtree, then runs. main: work.ts:168-174. Flag on: drops only the child's own waiting parent messages first. #3435 parent-message.ts:189-214
    Parent message from a parent that is stopped in its current Turn Flag on: saved as a Conversation note, no work, the stop stays. A spawn is refused. main: no such check. #3435 create.ts:583-594, :670, :728
    Child result or reply Skipped by the tree stop, or dropped while the latest Agent invocation is stopped. agent-invocations/child-input.ts:128-133, :160-187
    Child messageAgent to its parent Never skipped. One that arrives after the parent's stop is a non-Watch Event, so it can start a Turn (inferred). child-input.ts:164-166

    When the stop ends: grandchild tasks (root → A → B, A's task waits in B's mailbox)

    Case main (Agent invocation) Flag on
    Stop A, then new parent work for A B's old task does not run. Its Agent invocation is stopped. (tested) B's old task does not run. B's next Turn takes it, sees the left-over stop request, and ends cancelled. (tested)
    B was running at the stop, and a second task waited Not tested. Neither task runs. (tested)
    After the stop ends, A gives B a new task, then B's worker runs The new task runs. (tested) The new task is lost. One Turn takes the old task and the new task, and the left-over stop request cancels it (turn_completed, outcome: cancelled). A gets no result for that task (inferred). (tested)

    The old task is cancelled only because the stop request is left over (TTL 7 days, state/ttl.ts:2). If the request expires first, the old task runs (inferred).

    Mixed identities

    Where "input from different people never shares a Turn" holds:

    • People: a Turn takes one contiguous batch with the same Source and the same author or identity (task-execution/attempt-selection.ts:36-76). Another person's message never joins a running Turn (fix(slack): Keep each Turn to a single Actor #2574).
    • Child results to a parent: the author id comes from the result's Actor, so results for different requesters split (agent-invocations/result.ts, withAgentInvocationResultActors).
    • main children: each Agent invocation gets its own attempt (work.ts:204-235). A message joins a running child Turn only with the same Actor and credentials (work.ts:353-358).
    • Top-level agent messages run as the system Actor, so no Actor crosses.

    Where it does not hold:

    • Flag on, parent messages (tested). Every parent message from one parent has the same author id, parent-agent:{parent}, and the system identity (agent-invocations/parent-message.ts:300-302). So two messages that two different people's parent Turns sent share one child Turn. The Turn takes its Actor from the first entry (task-execution/conversation-turn.ts:249, :274). In the test, the Turn ran as the first person with that person's credentials, with the second person's message in the same instruction.
    • The batch check does not compare the credential subject (attempt-selection.ts:36-47). A batch of Watch Events from timers of different creators shares one Turn with no delegated access (this issue, and Run every agent on one Conversation execution core #2567 part 1).

    A stop does not cause these, but a stop makes them worse: work that waits during a stop all reaches the mailbox before the next Turn.

    Claude and Codex

    Claude Code and the Agent SDK (official docs)

    • Esc stops the current response. "Claude keeps the work done so far. If you have messages queued, Claude Code sends them next." (interactive mode, queue messages)
    • Agent SDK: after interrupt(), "Messages you sent before the interrupt that Claude hadn't read yet still reach Claude once the interrupted response ends." The receipt lists them as still_queued. Claude Code "can merge several into one turn". A client can send cancel_queued: true to cancel them. (streaming input, SDKControlInterruptResponse)
    • Subagents: a message from Claude resumes a subagent that Claude stopped with TaskStop. "A subagent you stopped yourself ... doesn't auto-resume. If Claude sends it a message, the message is refused and Claude is told the agent was cancelled." Only the person can resume it, by typing into its transcript. (resume subagents)
    • Input from another source: a message from another session "never counts as your consent". A session holds such messages for approval when the two sessions have different permission classes. (cross-session messaging)
    • Could not verify: whether stopping a subagent stops its own subagents, what a message from another session does to a stopped session, and what happens to a nested subagent's queue. The docs do not say. Claude Code is closed source.

    Codex (source, openai/codex@0122b12)

    • Op::Interrupt aborts the current task (codex-rs/protocol/src/protocol.rs:725-727). Then the core clears the turn's pending input. It keeps only terminal results from other agents, and puts them back in the mailbox for the next turn (codex-rs/core/src/session/input_queue.rs:364-393). If mail waits, it can start a new turn (codex-rs/core/src/tasks/mod.rs:715-724, :557-575).
    • The TUI puts the person's queued messages back in the composer, joined, and does not send them. "The server has already discarded pending input by the time the interrupted turn reaches the UI" (codex-rs/tui/src/chatwidget/input_restore.rs:391-394, :481-483, :541-546).
    • A parent can interrupt a spawned agent. Root and self cannot be targets (codex-rs/core/src/agent/control/interrupt.rs:15-52).
    • Could not verify: whether interrupting the root interrupts its children, and any case with more than one person. The code I read has one user for each session.

    Both products are single-user tools. The common rule: a stop never silently runs work that the person did not choose again, and it never silently drops the person's own input. Claude runs the person's input next. Codex gives it back to the person.

    Proposed rule

    One stop, one cut. A stop cancels the work that is running and the work that waits, in every Conversation that the stop covers, when the stop happens. Ending a stop never decides what to cancel. This keeps "no work after a stop" from #2567.

    Input While stopped When the stop ends
    A person's message sent after the stop Ends the stop for the subtree and runs as its own Turn, as that person. —
    A person's message waiting at the stop, or sent before the stop Dropped from the mailbox. It stays in history as a skipped Message, so the person and the next Turn can see it. (This is how Codex gives input back.) Does not run. The person sends it again.
    Watch Event Held as a skipped Message. No Turn. Context for the Turn that ends the stop. It never runs as its own Turn.
    Other Event, top-level agent message Held, the same as a Watch Event. Same as a Watch Event.
    New work from the parent Ends the stop for the child's subtree and runs as its own Turn, as the parent Turn's Actor. —
    Parent message waiting at the stop, in any Conversation of the tree Cancelled when the stop happens. Its marker ends. Does not run. The parent sees stopped and can send it again.
    Parent message from a parent that is stopped A Conversation note. No work. The stop stays. (#3435 does this.) Context only.
    Child result, reply, or messageAgent from a stopped child Skipped. A messageAgent that the child sent before the stop is held as context, not run. Context only.

    Mixed identities when a stop ends

    • Only the input that ends the stop starts a Turn. That Turn acts for the Actor of that input, with that input's credentials.
    • Held input from other Actors is context with no authority: a skipped Message or a Conversation note. It never joins the Turn as an instruction, and it never gives approval.
    • Held input never starts a Turn of its own when the stop ends. Work that still matters needs new input from its own source: the person sends it again, or the parent gives it again. This follows Claude's refusal for a subagent that a person stopped.
    • A batch never mixes Actors or credential subjects. This holds for parent messages too.

    Smallest change

    1. Cut at stop time. In finishStoppedTree (agent-invocations/stop.ts:255-268), drop the waiting parent messages of every Conversation that the stop covers, before stopConversationWork. Then an idle grandchild gets no left-over stop request, because stopConversationWork writes one only when work waits (state.ts:2061-2063). This replaces the drop in endStopForParentMessage (feat(agents): Spawn and message child agents without Agent invocations #3435 parent-message.ts:189-214), which covers only the child that got new work. With the flag off, Agent invocations already do this.
    2. One Actor per batch for parent messages. In hasSameOwner (attempt-selection.ts:36-47), compare the Actor and the credential subject of parent messages, not only the author id. This fixes the flag-on case where the first Actor wins.
    3. Hold all automated input while stopped. In isSkippedAfterConversationStop (session-stop.ts:194-202), save every Event as held input, not only Watch Events. Apply the same rule to a child's messageAgent (child-input.ts:164-166). This is the "one hold check" in this issue's Scope.
    4. A person's input sent before the stop does not run. Close the gap at session-stop.ts:142-143: drop it like the person input that waited at the stop, and keep it as a skipped Message.

    Items 1 and 2 are needed before the flag turns on. Items 3 and 4 are already in this issue's Scope.

    What #3435 already does: a parent message from a stopped parent becomes a Conversation note; a spawn from a stopped parent is refused; a late tree stop stops every child that is not stopped yet; the tree stop ends the waiting parent messages' markers; the child drops its own skipped parent messages when new work ends its stop.

    Fix in the design doc (#3597): the gap "When a stop ends, the parent messages to a grandchild that the stop skipped run again" should say that new work after the stop can be lost, and that parent messages from different Actors can share a Turn.

    Not checked

    • Whether the Turn that ends a stop shows held skipped Messages to the model. The context renderer marks them assistant skipped: stopped conversation (services/conversation-memory.ts:57-80). I did not check which Turns include that block. This issue's Scope already lists this check.
    • What A sees for its task that the cancelled Turn lost (inferred: no result).
    • A grandchild that is running when the stop happens, on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions