Compact in place at the alarm for every step, and drop the handoff the agent writes #186

Closed
opened 2026-10-17 10:58:47 -04:00 by cmoriarty · 1 comment
Owner

Decided by the operator on 2026-10-17, after the #172 comparison.

Why

At the context alarm, steps take one of two routes today:

  • The single apply step (#172) compacts in place: Braid stops the turn, calls opencode's own compaction (POST /api/session/{id}/compact), and the same session continues from the summary with Braid's continuation brief.
  • Every other step (#60) hands off: Braid asks the agent to write a handoff note ("Stop working: this session is nearly out of context. Write a handoff…"), then starts a fresh session from that note. A Braid-triggered compaction is only a backstop, at most twice an attempt.

The handoff depends on the agent stopping, writing a good note, and the next session trusting it, and it has gone wrong in practice. In run_01M55284MNP9F2CE8NK5D3D96A (context per agent 90,000, alarm 67,500), openspec.apply[all] compacted in place three times (69k → 9k, 72k → 10k, 73k → 10k, about two minutes each), kept its session, tools and variant, and finished the whole change cleanly. The same run's agent.code-review then went the handoff route at the same alarm.

What changes

  • Every agent step compacts in place at the alarm, with the compacting policy's rules: one deadline per attempt, subagents waited for, Stop honoured, the progress bound where the step has tasks (and a sensible bound where it has none), and the settle that follows the stream.
  • No handoff written by the agent. The "write a handoff" brief and the respawn from an agent's note go.
  • The fallback does not depend on the agent: when a compaction fails or does not shrink the context, the step continues in a fresh session seeded by Braid's own note (the step's brief and the state of the work: git status, git diff --stat, tasks.md), as osf/free/note.py already writes for #164's switch.
  • #164's switch between model families keeps working (it may use Braid's own note only, for the same reason).
  • The console and osfd transcript read the same for every step (#185's lines).

Done when

  • Unit tests and sims for a non-apply step compacting at the alarm, a failed compaction falling back to Braid's note, and no agent-written handoff left anywhere.
  • One real run on production where a step other than apply compacts.
Decided by the operator on 2026-10-17, after the #172 comparison. ## Why At the context alarm, steps take one of two routes today: - **The single apply step (#172)** compacts in place: Braid stops the turn, calls opencode's own compaction (`POST /api/session/{id}/compact`), and the same session continues from the summary with Braid's continuation brief. - **Every other step (#60)** hands off: Braid asks the agent to write a handoff note ("Stop working: this session is nearly out of context. Write a handoff…"), then starts a fresh session from that note. A Braid-triggered compaction is only a backstop, at most twice an attempt. The handoff depends on the agent stopping, writing a good note, and the next session trusting it, and it has gone wrong in practice. In run_01M55284MNP9F2CE8NK5D3D96A (context per agent 90,000, alarm 67,500), `openspec.apply[all]` compacted in place three times (69k → 9k, 72k → 10k, 73k → 10k, about two minutes each), kept its session, tools and variant, and finished the whole change cleanly. The same run's `agent.code-review` then went the handoff route at the same alarm. ## What changes - **Every agent step compacts in place at the alarm**, with the compacting policy's rules: one deadline per attempt, subagents waited for, Stop honoured, the progress bound where the step has tasks (and a sensible bound where it has none), and the settle that follows the stream. - **No handoff written by the agent.** The "write a handoff" brief and the respawn from an agent's note go. - **The fallback does not depend on the agent:** when a compaction fails or does not shrink the context, the step continues in a fresh session seeded by Braid's own note (the step's brief and the state of the work: `git status`, `git diff --stat`, `tasks.md`), as `osf/free/note.py` already writes for #164's switch. - #164's switch between model families keeps working (it may use Braid's own note only, for the same reason). - The console and `osfd transcript` read the same for every step (#185's lines). ## Done when - Unit tests and sims for a non-apply step compacting at the alarm, a failed compaction falling back to Braid's note, and no agent-written handoff left anywhere. - One real run on production where a step other than apply compacts.
Author
Owner

Archived in OpenSpec as compact-every-step (5a953a0), after free-profile whose requirements it modifies. Shipped and verified on production on 2026-10-17: run 74 against run 73, 79.3 vs 109.9 min, 5.98M vs 10.75M prompt tokens, 0 handoffs vs 3, and the code review compacted at its alarm (69,753 to 7,216). Its open timing task (10.4) is in #205. Closing.

Archived in OpenSpec as `compact-every-step` (5a953a0), after `free-profile` whose requirements it modifies. Shipped and verified on production on 2026-10-17: run 74 against run 73, 79.3 vs 109.9 min, 5.98M vs 10.75M prompt tokens, 0 handoffs vs 3, and the code review compacted at its alarm (69,753 to 7,216). Its open timing task (10.4) is in #205. Closing.
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#186
No description provided.