an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
merge: the four breaker PRs stacked, 425 resolved by hand
chaitanyagiri32dcc90ddb1d
diff --cc src/main/breaker.tsindex 3cd61f5b,63c8ee45..8edaddb6--- a/src/main/breaker.ts+++ b/src/main/breaker.ts@@@ -366,20 -344,16 +381,27 @@@ export class CircuitBreaker// DISTINCT tool call counts as progress too — background workflows and// interactive sessions do real work that never touches the hive files// (a single-call loop never refreshes that clock, and the loop/velocity- // arms above still backstop). Debounced: fires only after+ // arms above still backstop). A recent HUMAN PROMPT is the third leg+ // (#376): a live conversation is prose in, prose out — neither hive+ // files nor tool spans — and steering into it delivers a breaker+ // message while the operator is typing. Same window as the other legs;+ // a runaway loop is one prompt then many tool calls, so this clock+ // goes stale exactly when it should. Debounced: fires only after// NO_PROGRESS_BEATS consecutive beats, so a one-beat blip never steers.const toolActive = nowMs - s.lastDistinctToolAt < PROGRESS_TOOL_WINDOW_MS;+ // A recently-changed working directory is progress too. The question+ // this arm asks is "is this agent doing anything"; until now it asked+ // "is this agent COORDINATING". The paths behind `progressing` are the+ // inbox, the outbox and memory.md - every one of them messaging or+ // memory, none of them where work lands. An agent that edits, builds+ // and commits touches none of them and reads as wedged. Same window as+ // the tool clock, because it answers the same question over the same+ // span of time.+ const workActive = typeof input.lastWorkAt === 'number' && input.lastWorkAt > 0+ && nowMs - input.lastWorkAt < PROGRESS_TOOL_WINDOW_MS;- if (!input.progressing && !toolActive && !workActive) {++ // #425: a live human conversation is progress too, on the same window.+ const humanActive = nowMs - s.lastUserPromptAt < PROGRESS_TOOL_WINDOW_MS;- if (!input.progressing && !toolActive && !humanActive) {++ if (!input.progressing && !toolActive && !workActive && !humanActive) {s.noProgressBeats += 1;if (s.noProgressBeats >= NO_PROGRESS_BEATS) {return { tripping: true, reason: 'no-progress: generating tokens without coordinating (stale log/files)' };diff --cc test/breaker.test.cjsindex ee5f3819,5e161e4d..3802dfc2--- a/test/breaker.test.cjs+++ b/test/breaker.test.cjs@@@ -165,45 -165,56 +165,95 @@@ test('recordCompactEnd without a compacassert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`); // still trips normally});+// ── #189: the per-agent cap measures work, not cached context ───────────────+// Cached input is re-billed on every request, so the all-kinds total grows with+// the request count against a fixed context, not with what the agent does. The+// measured incidents: two agents crossed a 4M cap 4–6 minutes into a session+// with 98.6% / 99.2% of the counted figure being cacheRead.++test('per-agent cap does not trip on cached context (the #189 incident shape)', () => {+ const b = makeBreaker({ agentTokenCaps: { a: 4_000_000 } });+ // Agent A at its crossing row: 56,884 tokens of work under 4,102,505 of cache reads.+ const s = { ...sample('a', T0, 50_000, 6_884), cacheRead: 4_102_505 };+ const d = beat(b, 'a', s, true, T0);+ assert.equal(d.state.level, 'healthy', `reason: ${d.state.reason}`);+});++test('per-agent cap still trips on work tokens, and the reason names the metric', () => {+ const b = makeBreaker({ agentTokenCaps: { a: 4_000_000 } });+ const s = { ...sample('a', T0, 1_500_000, 2_000_000), cacheCreation: 600_000, cacheRead: 9_000_000 };+ const d = beat(b, 'a', s, true, T0);+ assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`);+ const work = (4_100_000).toLocaleString(), cap = (4_000_000).toLocaleString(), total = (13_100_000).toLocaleString();+ assert.ok(d.state.reason.startsWith(`token limit: ${work} work tokens over the agent cap of ${cap}`), d.state.reason);+ assert.ok(d.state.reason.includes(`${total} total`), d.state.reason); // the display figure is still reported+});++test('cache writes count toward the agent cap; cache reads do not', () => {+ const reads = { ...sample('a', T0, 400, 500), cacheRead: 200 }; // 900 work, 1,100 total+ const writes = { ...sample('a', T0, 400, 500), cacheCreation: 200 }; // 1,100 work+ const b1 = makeBreaker({ agentTokenCaps: { a: 1_000 } });+ assert.equal(beat(b1, 'a', reads, true, T0).state.level, 'healthy');+ const b2 = makeBreaker({ agentTokenCaps: { a: 1_000 } });+ assert.equal(beat(b2, 'a', writes, true, T0).state.level, 'steering');+});++test('the floor-wide token budget still counts all kinds (only the per-agent arm changed)', () => {+ const b = makeBreaker({ costCapTokens: 4_000_000 });+ const s = { ...sample('a', T0, 50_000, 6_884), cacheRead: 4_102_505 };+ const d = beat(b, 'a', s, true, T0);+ assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`);+ assert.ok(d.state.reason.startsWith('token cap: floor total'), d.state.reason);+ // ── #376: a live human conversation counts as progress ──────────────────────+ // A conversation is prose in, prose out — no hive files, no tool spans — and+ // the measured incidents fired 19s and 30s after an operator prompt, while the+ // file-based progress signal had been stale for over an hour.++ test('a recent human prompt exempts the no-progress trip (mid-conversation)', () => {+ const b = makeBreaker();+ beat(b, 'a', sample('a', T0, 0), false, T0);+ // The incident shape: operator prompts ~30s before each beat; the agent+ // answers in prose (Δoutput > 0) and touches nothing else.+ b.recordUserPrompt('a', T0 + BEAT - 30_000);+ beat(b, 'a', sample('a', T0 + BEAT, 800), false, T0 + BEAT);+ b.recordUserPrompt('a', T0 + 2 * BEAT - 19_000);+ const d = beat(b, 'a', sample('a', T0 + 2 * BEAT, 1600), false, T0 + 2 * BEAT);+ assert.equal(d.state.level, 'healthy', `reason: ${d.state.reason}`);+ });++ test('one prompt covers a long answer for the whole progress window', () => {+ const b = makeBreaker();+ beat(b, 'a', sample('a', T0, 0), false, T0);+ b.recordUserPrompt('a', T0 + 1000); // one question, then a long prose answer+ for (let i = 1; i <= 9; i++) { // 9 beats = 4.5 min, inside the 300s window+ const t = T0 + i * BEAT;+ const d = beat(b, 'a', sample('a', t, i * 700), false, t);+ assert.equal(d.state.level, 'healthy', `beat ${i}: ${d.state.reason}`);+ }+ });++ test('the conversation clock EXPIRES: a stale prompt does not blind the arm', () => {+ const b = makeBreaker();+ beat(b, 'a', sample('a', T0, 0), false, T0);+ b.recordUserPrompt('a', T0); // one prompt, then the agent burns tokens alone+ const t1 = T0 + 320_000; // past the 300s window+ const t2 = t1 + BEAT;+ beat(b, 'a', sample('a', t1, 5000), false, t1);+ const d = beat(b, 'a', sample('a', t2, 6000), false, t2);+ assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`);+ });++ test('a human prompt does not exempt the loop, error-storm, or velocity arms', () => {+ const b = makeBreaker();+ b.recordUserPrompt('a', T0 - 1000);+ for (let i = 0; i < 8; i++) b.recordToolUse('a', 'Bash', { cmd: 'same' });+ assert.equal(beat(b, 'a', null, true, T0).state.level, 'steering'); // loop still trips++ const b2 = makeBreaker();+ b2.recordUserPrompt('a', T0 - 1000);+ beat(b2, 'a', sample('a', T0, 0), true, T0);+ const d = beat(b2, 'a', sample('a', T0 + BEAT, 40_000), true, T0 + BEAT); // 80k/min+ assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`); // velocity still trips});// ── fix 2: recent distinct tool activity counts as progress ─────────────────