A forked session's alarm says 'compacting…' then goes on in a fresh session: the alarm is emitted before the fork check #378

Closed
opened 2026-11-04 13:20:20 -05:00 by cmoriarty · 1 comment
Owner

What happens
On run 172's agent.visual-check.r2 (2026-11-04 13:16) the coding pane read, in this order:

◯ Context at 202k of 226k: compacting…
  paused for the compaction
◯ Continued session full: going on in a fresh session from Braid's note

and the new session's first thought was "I'm in a new session that has taken over a judge step that was interrupted". It looks as if Braid started a compaction, then changed its mind and handed off. The same sequence appeared on openspec.apply[all] at 08:12. Both steps' sessions were forks (osf.session.forked from agent.visual-check #1 and from agent.revise #1).

Why
In executors.py's alarm handler the verdict is computed as "stop" if refusal else "compact" and the osf.budget.alarm event goes out with action: compact before the fork check. Only after that does if session_id in state.forks: decide, for a forked session (every build step since braid#275), to skip the compaction and go on in a fresh session (reason: forked_compaction, braid#276). The events say so:

13:16:48 osf.budget.alarm     {"action": "compact", "peak_input_tokens": 201655}
13:16:49 osf.budget.respawned {"reason": "forked_compaction", "writer": "braid", "respawn_n": 1}

The UI renders the alarm's action faithfully (ALARM_DOING.compact = 'compacting…' in ui/src/lib/format.ts), so the pane says compacting for a second, then the respawn row says the session was full. No compaction was ever attempted; the alarm's word was wrong.

Fix

  • Decide fork-or-compact before emitting the alarm, so a forked session's alarm carries the action it will take (say action: fresh_session, or respawn) and the pane reads Context at 202k of 226k: going on in a fresh session…. The braid#185 rule that a newer alarm restates the verdict when the bound changes already covers re-emitting.
  • The row that resolves it should then read as the completion of what the alarm said, not as a change of mind: Fresh session from Braid's note (the continued session was full).
  • "paused for the compaction" (the text shown to the agent while it waits) should not be sent when no compaction will happen.
  • The handoff note's first line could tell the new session this is a planned continuation, not an interruption ("taken over a judge step that was interrupted" is how run 172's agent read it).

Done when
A forked session reaching the alarm shows one consistent story in the pane: the alarm names the fresh session, the resolution confirms it, and nothing says compacting. A non-forked session still says compacting and then compacted.

Observed on run 172 (run_01M6K8CA22F0FE8TNG6K6J6PG3), steps openspec.apply[all] 08:12 and agent.visual-check.r2 13:16; source read at origin/main d53f9e9d. Related: braid#185, braid#186, braid#275, braid#276.

**What happens** On run 172's `agent.visual-check.r2` (2026-11-04 13:16) the coding pane read, in this order: ``` ◯ Context at 202k of 226k: compacting… paused for the compaction ◯ Continued session full: going on in a fresh session from Braid's note ``` and the new session's first thought was "I'm in a new session that has taken over a judge step that was interrupted". It looks as if Braid started a compaction, then changed its mind and handed off. The same sequence appeared on `openspec.apply[all]` at 08:12. Both steps' sessions were forks (`osf.session.forked` from `agent.visual-check #1` and from `agent.revise #1`). **Why** In `executors.py`'s alarm handler the verdict is computed as `"stop" if refusal else "compact"` and the `osf.budget.alarm` event goes out with `action: compact` *before* the fork check. Only after that does `if session_id in state.forks:` decide, for a forked session (every build step since braid#275), to skip the compaction and go on in a fresh session (`reason: forked_compaction`, braid#276). The events say so: ``` 13:16:48 osf.budget.alarm {"action": "compact", "peak_input_tokens": 201655} 13:16:49 osf.budget.respawned {"reason": "forked_compaction", "writer": "braid", "respawn_n": 1} ``` The UI renders the alarm's action faithfully (`ALARM_DOING.compact = 'compacting…'` in `ui/src/lib/format.ts`), so the pane says compacting for a second, then the respawn row says the session was full. No compaction was ever attempted; the alarm's word was wrong. **Fix** - Decide fork-or-compact before emitting the alarm, so a forked session's alarm carries the action it will take (say `action: fresh_session`, or `respawn`) and the pane reads `Context at 202k of 226k: going on in a fresh session…`. The braid#185 rule that a newer alarm restates the verdict when the bound changes already covers re-emitting. - The row that resolves it should then read as the completion of what the alarm said, not as a change of mind: `Fresh session from Braid's note (the continued session was full)`. - "paused for the compaction" (the text shown to the agent while it waits) should not be sent when no compaction will happen. - The handoff note's first line could tell the new session this is a planned continuation, not an interruption ("taken over a judge step that was interrupted" is how run 172's agent read it). **Done when** A forked session reaching the alarm shows one consistent story in the pane: the alarm names the fresh session, the resolution confirms it, and nothing says compacting. A non-forked session still says compacting and then compacted. _Observed on run 172 (`run_01M6K8CA22F0FE8TNG6K6J6PG3`), steps `openspec.apply[all]` 08:12 and `agent.visual-check.r2` 13:16; source read at origin/main d53f9e9d. Related: braid#185, braid#186, braid#275, braid#276._
Author
Owner

Shipped in PR #390, production ddd4b6b. An alarm in a continued session now says the step goes on in a fresh session, and the console shows that with no pause row.

Evidence: tests/engine/test_fresh_session_alarm.py, and sims apply-single, apply-auto-plentiful and apply-group-compacts now expect the new action. On a kept sim in a real browser: "Context at 35k of 40k: going on in a fresh session…", then "Fresh session from Braid's note (the continued session was full)".

**Shipped** in PR #390, production ddd4b6b. An alarm in a continued session now says the step goes on in a fresh session, and the console shows that with no pause row. **Evidence:** `tests/engine/test_fresh_session_alarm.py`, and sims `apply-single`, `apply-auto-plentiful` and `apply-group-compacts` now expect the new action. On a kept sim in a real browser: "Context at 35k of 40k: going on in a fresh session…", then "Fresh session from Braid's note (the continued session was full)".
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/braid#378
No description provided.