Skip to content

Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.

TypeScript

fix(byoa): stop retrying an engine only the operator can fix

yetonef29edba8066a
diff --git a/server/src/__tests__/agents-computer-operator-fix-backoff.test.ts b/server/src/__tests__/agents-computer-operator-fix-backoff.test.ts
new file mode 100644
index 0000000..f13b673
--- /dev/null
+++ b/server/src/__tests__/agents-computer-operator-fix-backoff.test.ts
@@ -0,0 +1,48 @@
+/**
+ * An engine failure only the operator can clear must stop spinning.
+ *
+ * Measured on 2026-09-01, after the codex config fix had landed: nine computers
+ * whose Claude was signed out produced 1,988 failed turns in forty minutes —
+ * roughly one every twelve seconds each, indefinitely, with no backoff and
+ * nothing telling their operator why. Retrying a signed-out CLI cannot succeed;
+ * it only burns the fleet's error budget and hides real failures underneath.
+ *
+ * Run: node --import tsx --test server/src/__tests__/agents-computer-operator-fix-backoff.test.ts
+ */
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+
+process.env.CUMORA_RUNTIME_CLIENT = 'http'
+process.env.OPENAI_API_KEY ??= 'test-key'
+
+const { needsOperatorFix } = await import('../agents/computer/daemon.js')
+
+test('the failures actually seen in production are recognised', () => {
+ for (const err of [
+ 'local claude failed (exit 1): engine turn error (success): Not logged in · Please run /login',
+ 'local claude failed (exit 1): engine turn error (success): Credit balance is too low',
+ 'Invalid API key provided',
+ 'unauthorized',
+ ]) {
+ assert.equal(needsOperatorFix(err), true, `should pause on: ${err}`)
+ }
+})
+
+test('transient and unknown failures keep retrying', () => {
+ for (const err of [
+ undefined,
+ null,
+ '',
+ // A throttle clears itself — that is the rate-limit path, not this one.
+ 'Server is temporarily limiting requests',
+ // A broken install is real, but the message is not unambiguous enough to
+ // stop a whole agent for fifteen minutes on.
+ 'Missing optional dependency @openai/codex-darwin-arm64',
+ 'process exited with code 1',
+ 'engine turn error (error_during_execution): see log',
+ // Must not fire on a message that merely mentions logging in.
+ 'the user asked how to run /login later',
+ ]) {
+ assert.equal(needsOperatorFix(err), false, `should keep retrying: ${err}`)
+ }
+})
diff --git a/server/src/agents/computer/daemon.ts b/server/src/agents/computer/daemon.ts
index a3aaaf3..cee0082 100644
--- a/server/src/agents/computer/daemon.ts
+++ b/server/src/agents/computer/daemon.ts
@@ -225,6 +225,25 @@ const TRIAGE_CONCURRENCY = Math.max(1, Number(process.env.CUMORA_BYOA_MAX_CONCUR
// — that's where the 130 rate-limit log lines came from. A 60s cooldown
// lets the provider's short-window limit reset before we try again.
const ENGINE_BACKOFF_AFTER_RATE_LIMIT_MS = 60_000
+/** Cooldown after an engine failure only the OPERATOR can clear — a signed-out
+ * CLI, an exhausted credit balance. Far longer than the rate-limit window,
+ * because retrying changes nothing until a human logs in or tops up.
+ *
+ * Measured before this existed: nine computers with a signed-out Claude
+ * produced 1,988 failed turns in forty minutes — about one every twelve
+ * seconds each, forever, with no backoff and nothing telling their operator
+ * why. That is most of what a fleet-wide "97% failure rate" actually was. */
+const ENGINE_BACKOFF_AFTER_OPERATOR_FIX_MS = 15 * 60_000
+
+/** Engine failures that will recur identically until a human intervenes.
+ * Deliberately narrow: only errors whose remedy is unambiguous and whose
+ * retry has no chance of succeeding. Anything uncertain stays on the normal
+ * path and keeps retrying. */
+const OPERATOR_FIX_RE = /not logged in|please run \/login|credit balance is too low|insufficient (credit|quota)|invalid api key|unauthorized/i
+
+export function needsOperatorFix(err: string | null | undefined): boolean {
+ return !!err && OPERATOR_FIX_RE.test(err)
+}
// Neutral cwd for LOCAL small-brain triage: no persona CLAUDE.md / skills / MCP,
// so the cerebellum completion is fast and tool-free.
const TRIAGE_DIR = join(CONFIG_DIR, 'triage')
@@ -2892,6 +2911,14 @@ class AgentRunner {
// what is really a transient provider throttle. Persist a quieter
// signal to the run row instead so it shows up in observability.
const rateLimited = engineError ? isRateLimited(engineError) : false
+ // An engine nobody has logged into will fail the same way on the next
+ // poll, and the one after that. Cool down like a rate limit so the
+ // machine stops spinning, but tell the user — a silent backoff on a
+ // fixable problem is just a slower way of never working.
+ if (engineError && !rateLimited && needsOperatorFix(engineError)) {
+ this.engineBackoffUntil = Date.now() + ENGINE_BACKOFF_AFTER_OPERATOR_FIX_MS
+ console.warn(`[computer] ${this.agent.id} engine needs operator action — pausing ${Math.round(ENGINE_BACKOFF_AFTER_OPERATOR_FIX_MS / 60000)}min: ${engineError.slice(0, 160)}`)
+ }
if (engineError && !rateLimited) {
await this.publishEngineFailure({
token,