Skip to content

fix: keep Claude notification turns separate when init beats queued - #334

Merged
xxchan merged 1 commit into
mainfrom
fix/claude-init-before-queued
Oct 10, 2026
Merged

xxchan merged 1 commit into
mainfrom
fix/claude-init-before-queued

Conversation

@xxchan

@xxchan xxchan commented Oct 10, 2026

Copy link
Copy Markdown
Member

When a host writes a Claude prompt just before a background notification starts its own turn, system/init can arrive before the prompt's command_lifecycle queued. The view previously attached the notification's text to that prompt. Retain the unclaimed root init and emit input_queued followed by anonymous turn_active on the queued frame, so the notification and the prompt's answer stay in separate turns.

The adapter uses that projected start for its busy state too. Repeated init/queue receipts do not create another turn, and cancelling the pending prompt leaves the notification turn running. No public types or observation-layer logic change.

Validation:

  • Two Claude 2.1.292/aimock recordings (20 ms init-first and 0 ms queued-first), an earlier-write control, and 13 regressions covering live/pure/JSON replay agreement, input-scoped waits, cancellation, duplicates, and root/child ownership.
  • Claude 2.1.296: 40 native vendor tests and all 17 applicable behavior cases passed, using a local provider and no account.
  • CI=1 pnpm run check passed (1,638 tests plus the mock behavior suite); pnpm run build passed.

Fixes #326.

@xxchan
xxchan merged commit f108482 into main Oct 10, 2026
17 checks passed
@xxchan
xxchan deleted the fix/claude-init-before-queued branch October 10, 2026 10:54
@xxchan xxchan mentioned this pull request Oct 10, 2026
xxchan added a commit that referenced this pull request Oct 10, 2026
Release OAR and CLI 0.54.3. This PR changes only the two package version
fields.

**Fixed: claude's own turn stays separate from a prompt written just
before it** (#326, #334)
- When a background task finishes, claude starts a turn of its own to
report it. A host prompt written a few milliseconds after the task's
notification could see that turn's root `system/init` arrive before the
prompt's `command_lifecycle queued` receipt. OAR could not yet tell that
the init was not the prompt's, and did not correct it when `queued`
arrived. `SessionView` then put claude's report inside the prompt's turn
("» What is 2+2?" → "The background command finished…" → "4" in a second
turn with no input), and status followed it. `promptAndWait` and
`awaitTurnEnd(…, inputId)` already returned the right answer.
- OAR now keeps such an init unclaimed until the receipt arrives. When
`queued` proves the prompt has not started, the same frame carries
`input_queued` followed by `turn_active` without an `inputId`, so
claude's report is its own turn and the prompt sits before the turn that
answers it. Only an init seen since that write, with no native turn
already running and not claimed by `started`, counts; a repeated init or
`queued` reports nothing again. Live views and record replay agree.
- While claude's own turn runs, status stays running instead of dropping
to waiting when the prompt is queued.

**Behavior changes**
- In that timing, a `turn_active` without `inputId` now follows
`input_queued` in the queued frame. Records written by 0.54.2 and
earlier replay as before.

Validation: #334 passed all 17 checks on its final head, and its merged
tree equals its CI tree. Its regressions replay two recordings of real
claude 2.1.292 with a scripted provider (a prompt written 20 ms after a
background task's notification, which saw init first, and 0 ms, which
saw `queued` first), plus a prompt written while the task still runs and
cancellation while claude's turn continues. Lookout swept the delay live
with no account: on claude 2.1.292 seven runs from 15 to 30 ms and on
2.1.296 fifteen runs from 15 to 45 ms, catching the init-first order
three to four times on each version. Every run gave the right view and
`promptAndWait` returned "4". Ferryman's recording from Ferry on 0.53.0
showed the same order. After this PR passes CI and merges, tag its exact
squash commit as `v0.54.3` to trigger npm trusted publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan added a commit that referenced this pull request Oct 12, 2026
Weekly docs and consistency pass (2026-10-12).

**Added**
- `docs/spec/runtime-matrix.md`: **Custom model endpoints**, how to
point each runtime at another endpoint through its own configuration
(the recipes the behavior backends use against a scripted provider, so
each runs in CI). Promised to Rower earlier.
- `docs/runtimes/antigravity.md`: its own `view_file` also allows
`$GEMINI_HOME`, where the server keeps its stored login (agy_acp_server
1.3.0 source), so give a session its own `GEMINI_HOME` when the agent
should not see your login.

**Fixed, from an audit of the docs against this week's code**
- Runtime matrix: grok child ledgers stay native-only and `withChildren`
is absent; opencode v2 children report context only (both rows said
children are added by `withChildren`).
- Runtime matrix: claude's tool arguments stream as
`tool_call_input_delta` (phase `writing`), not "raw activity until the
full call arrives".
- `docs/runtimes/README.md`: the runtime-check link points at the dated
reports, not 2026-10-06.
- `docs/runtimes/inventory.md`: four inventory readers, not three.
- `docs/runtimes/claude.md`: a spontaneous turn's start is reported with
the prompt's `queued` when a host prompt was written just before
claude's init (#334); the old sentence said always immediately.
- `CatalogProvider.configured` comment: an entry as the runtime counts
it, not a key known to work (matches pi.md).

**Shortened**
- README: the structured-output scope paragraph is now a link to the
runtime matrix.
- `session-graph-and-cursor.md`: the `withChildren` rule is now a link;
the rule lives in `attribution.md` (which gained the two details the
copy had: reports before lineage, repeated cumulative reports).

Other duplicated passages (claude's `input_queued` semantics in three
places, the command inventory in README and spec) are left for next
week's pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

claude: a prompt written between a task_notification and claude's own system/init is placed above that turn (no spontaneous turn_active, 0.53)

2 participants