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
fix(breaker): a live human conversation counts as progress
Snehitha6419bbcc5922
diff --git a/docs/pr-evidence/no-progress-after.png b/docs/pr-evidence/no-progress-after.pngnew file mode 100644index 00000000..c7429312Binary files /dev/null and b/docs/pr-evidence/no-progress-after.png differdiff --git a/docs/pr-evidence/no-progress-before.png b/docs/pr-evidence/no-progress-before.pngnew file mode 100644index 00000000..04d6550dBinary files /dev/null and b/docs/pr-evidence/no-progress-before.png differdiff --git a/src/main/breaker.ts b/src/main/breaker.tsindex a2e9718b..63c8ee45 100644--- a/src/main/breaker.ts+++ b/src/main/breaker.ts@@ -104,6 +104,12 @@ interface AgentBreakerState {* single-call loop never refreshes this; an alternating loop that would is* still backstopped by the velocity trip. */lastDistinctToolAt: number;+ /** When a human last submitted a prompt to this agent (UserPromptSubmit).+ * A live conversation is work that touches neither hive files nor tools —+ * prose in, prose out — so the no-progress arm reads it via this third+ * progress clock (#376). A clock, not an exemption: it expires on its own,+ * and a runaway loop (one prompt, then many tool calls) never refreshes it. */+ lastUserPromptAt: number;/** Consecutive beats the no-progress condition held (debounce counter). */noProgressBeats: number;}@@ -132,7 +138,8 @@ export class CircuitBreaker {if (!s) {s = {level: 'healthy', reason: '', lastSample: null, repeatKey: null, repeatCount: 0,- errorCount: 0, compactingUntil: 0, lastDistinctToolAt: 0, noProgressBeats: 0+ errorCount: 0, compactingUntil: 0, lastDistinctToolAt: 0, lastUserPromptAt: 0,+ noProgressBeats: 0};this.agents.set(agentId, s);}@@ -172,6 +179,14 @@ export class CircuitBreaker {this.get(agentId).errorCount += 1;}+ /** A human submitted a prompt to this agent (UserPromptSubmit hook). Stamps+ * the conversation progress clock the no-progress arm reads (#376). Only+ * that arm gains a way to see this work — the loop, error-storm, velocity+ * and cap arms are unchanged. */+ recordUserPrompt(agentId: string, now = Date.now()): void {+ this.get(agentId).lastUserPromptAt = now;+ }+/** Compaction started (PreCompact hook). Exempt the Δoutput-based trips —* compaction burns output tokens while touching no coordination file, which* is exactly the false-positive shape of upstream issue #109 (the harness's@@ -329,10 +344,16 @@ 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;- if (!input.progressing && !toolActive) {+ const humanActive = nowMs - s.lastUserPromptAt < PROGRESS_TOOL_WINDOW_MS;+ if (!input.progressing && !toolActive && !humanActive) {s.noProgressBeats += 1;if (s.noProgressBeats >= NO_PROGRESS_BEATS) {return { tripping: true, reason: 'no-progress: generating tokens without coordinating (stale log/files)' };diff --git a/src/main/hooks.ts b/src/main/hooks.tsindex f51dfd19..7152e245 100644--- a/src/main/hooks.ts+++ b/src/main/hooks.ts@@ -208,6 +208,16 @@ export class HookServer {this.breaker?.recordToolUse(agentId, p.tool_name, p.tool_input);}+ // A human just spoke to this agent (issue #376): stamp the third progress+ // clock the no-progress arm reads. A conversation is prose in, prose out —+ // no hive file changes, no tool spans — which the arm otherwise reads as+ // "generating tokens without coordinating". A runaway loop is ONE prompt+ // followed by many tool calls, so this clock goes stale exactly when it+ // should and blinds nothing.+ if (event === 'UserPromptSubmit' && agentId) {+ this.breaker?.recordUserPrompt(agentId);+ }+// Compaction exemption (issue #109): PreCompact opens it so the compaction// token burst can't trip the Δoutput arms; PostCompact — or any SessionStart,// since a fresh session makes in-flight compaction state moot — closes itdiff --git a/test/breaker.test.cjs b/test/breaker.test.cjsindex ca08ce3a..5e161e4d 100644--- a/test/breaker.test.cjs+++ b/test/breaker.test.cjs@@ -165,6 +165,58 @@ test('recordCompactEnd without a compaction in flight is a no-op', () => {assert.equal(d.state.level, 'steering', `reason: ${d.state.reason}`); // still trips normally});+// ── #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 ─────────────────test('recent distinct tool calls exempt the no-progress trip', () => {