Skip to content

Keep a started message in hand while a command its turn left runs in the background - #6940

Merged
max-sixty merged 3 commits into
mainfrom
agent-ae572680e468ec319
Nov 24, 2026
Merged

max-sixty merged 3 commits into
mainfrom
agent-ae572680e468ec319

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

A message the agent starts now stays in hand after its turn ends while a command that turn left running in the background still runs, as it already does while a background agent works: the page reads it Working and no reminder names it until the command exits or the session's next turn opens. Before, Claude Code's shell status (no turn or agent running, a command still running) read as plain idle, so the message dropped to Stopped and the watch woke the session to remind it of work its command was still doing.

Mapping shell to busy doesn't fix it: Claude Code dates each status by its last change, so shell is dated from the turn's end, after the start. Harness.live_turn now reads shell as idle (which interrupt detection relies on) with command: true, and activity.start_holds holds a start from the claimant's current turn while the record says the session works: idle with command, or a busy that began before the turn's end. The second half also keeps the start through a dialog after it, such as approving the command, which re-dates busy.

To weigh:

  • A command alone doesn't make the page read Working "in the background" the way a background agent does: a dev server or a Monitor reports the same shell.
  • A later turn opened while the command still runs is reminded of the message, since that turn's busy hides the command; the agent starts it again.
  • A start the agent leaves while an unrelated server runs (a leaf-dev preview, say) is reminded at the next turn rather than at once; the page shows it Working, then Gone quiet after 15 minutes.

The restart line in Leaf's reminder and conversation-loop.md now say what holds a start; neither changes a rule.

This extends Max's decision for background agents (#6593) to commands; nobody chose the difference, and Max hasn't decided the command case himself. Tests: a new hook test against Claude Code registry records fails on main; activity tests cover shell after a background agent and an Escape that leaves a command running. The claude-code journey passes all 14 steps.

This was written by Claude Code on behalf of max-sixty

…the background

A message the agent starts now stays in hand after its turn ends while a
command that turn left running in the background still runs, as it already
does while a background agent works: the page reads it Working and no
reminder names it until the command exits or the session's next turn opens.
Before, Claude Code's `shell` status, which it reports when no turn or agent
runs but a command does, read as plain `idle`, so the message dropped to
Stopped and the watch woke the session to remind it of work its command was
still doing.

Mapping `shell` to `busy` doesn't fix it: Claude Code dates each status by its
last change, so `shell` is dated from the turn's end, after the start, and the
date test that keeps a start under `busy` fails. `Harness.live_turn` now reads
`shell` as `idle`, which interrupt detection relies on, with `command: true`.
`activity.start_holds` reads a start from the claimant's current turn as held
while the record says the session works, an `idle` with `command` or a `busy`
that began before the turn's end, since every agent and command the session
runs starts in one of its turns. That also keeps such a start through a dialog
after it, such as approving the command, which re-dates `busy` past the start;
a start from an earlier turn still needs a `busy` dated before it.

What this leaves:
- A command alone doesn't make the page read Working "in the background", as
  a background agent does (`Turn.busy`): a dev server or a Monitor reports the
  same `shell`, and would read as work while the agent waits on the user.
- A later turn opened while the command runs is reminded of the message, since
  that turn's `busy` hides the command; the agent starts it again.
- A start the agent leaves while an unrelated server runs is reminded at the
  next turn rather than at once; the page shows it Working, then Gone quiet
  after 15 minutes.

The Stop and prompt reminder's restart line no longer says a start lapsed "when
its turn ended", which a command now outlasts, and `conversation-loop.md`
corrects what holds a start; neither changes a rule.

Tests: a new hook test against Claude Code registry records fails on the old
code and covers the dialog, the command's exit and a later turn's command;
the activity tests cover `shell` after a background agent ends and an Escape
that leaves a command running. The claude-code journey passes all 14 steps.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent
leaf-agent previously approved these changes Nov 24, 2026
The `start_holds` header said the user asked that a command the session
leaves running hold a start as a background agent does. Nobody chose that;
this change extends the user's decision for background agents to commands, so
the header now says so, with the reason: the command carries on the start's
turn as an agent does, and without the hold the agent is reminded of a message
while the command answering it still runs.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit a931a53 into main Nov 24, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-ae572680e468ec319 branch November 24, 2026 03:45
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.

2 participants