Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep timeout failures out of quota benches

[._.]/ Adam Eivy3e477832436d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 6e9e95595d..1b816f2744 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -28,6 +28,8 @@
## Fixed
+- **A timed-out creative stage no longer benches its provider as “quota exceeded.”** TUI finalization previously classified a hard timeout by scanning the whole terminal response, which includes the story prompt; ordinary narrative words such as “credit,” “payment,” or “billing” could therefore override exit 124 and sideline a healthy provider for an hour. The host's timeout signal is now authoritative, while non-timeout failures continue to use provider-output analysis for real usage, auth, model, and network banners.
+
- **Quality-first AI stages are no longer forced off at 30 minutes.** Provider, prompt-stage, and one-off run timeouts may now be configured up to 12 hours, matching the existing long-running TUI safety ceiling. The default stays five minutes and every provider keeps its own explicit cap, but an opted-in, high-effort story-planning or repair pass can be given enough wall time to finish instead of being killed while active and then repeated from scratch on a fallback.
- **An arc auto-resolve round that makes the draft worse is now undone instead of kept.** Autonomous mode's arc-verification gate hands the resolver the blocking findings it must clear and re-verifies afterwards — but whatever the resolver wrote was committed unconditionally, including a rewrite that cleared nothing and broke more than it touched. One run went 1 blocking finding → 3 → 5 that way: the loop noticed it had stopped converging and paused (correctly), but by then it had paused *on its own damage*, handing back an arc four findings further from the gate than the one the round started with. A round is now snapshotted before it runs — the arc, the volume list, each episode's planning synopsis and the volume it sits under — and if the next verification comes back with more blocking findings while the ones it was given are still standing, the round's edits are reverted and the run pauses on the original residual, labelled **round reverted**. The rollback is deliberately narrow: a round that genuinely closed everything it targeted is kept even when it surfaces findings that were latent underneath, since that's progress, and a round that merely stalls is still the existing non-convergence guard's business. Findings are matched by a normalized fingerprint rather than raw prose, so the verifier re-wording itself between calls can't disguise a finding as newly fixed. Volume ids, locked episodes, and the never-delete-a-volume guarantee survive the rollback, and no extra AI call is spent to detect it.
diff --git a/server/services/runner.js b/server/services/runner.js
index ae3f85426c..37a6ada3fc 100644
--- a/server/services/runner.js
+++ b/server/services/runner.js
@@ -109,7 +109,14 @@ export async function finalizeRunRecord({ runId, output, exitCode, success, erro
if (extras && typeof extras === 'object') Object.assign(metadata, extras);
if (!success && toolkit.services.errorDetection) {
- const errorAnalysis = toolkit.services.errorDetection.analyzeError(output, exitCode);
+ // Exit 124 is the host's authoritative wall-clock timeout. Do not scan the
+ // model's entire TUI screen/prompt for a competing category in that case:
+ // story text can legitimately contain words such as "credit" or
+ // "billing", which used to turn a plain timeout into quota-exceeded and
+ // bench a healthy provider for an hour. Other failures still analyze the
+ // output because their provider banner is often the only useful signal.
+ const analysisInput = exitCode === 124 ? (error || 'Process timed out') : output;
+ const errorAnalysis = toolkit.services.errorDetection.analyzeError(analysisInput, exitCode);
metadata.error = metadata.error || errorAnalysis.message || `Process exited with code ${exitCode}`;
metadata.errorCategory = errorAnalysis.category;
metadata.errorAnalysis = errorAnalysis;
diff --git a/server/services/runner.test.js b/server/services/runner.test.js
index 2f536b5a4f..721b35db0f 100644
--- a/server/services/runner.test.js
+++ b/server/services/runner.test.js
@@ -56,7 +56,7 @@ const { writeFile, readFile } = await import('fs/promises');
const { atomicWrite } = await import('../lib/fileUtils.js');
const runner = await import('./runner.js');
const { analyzeError, ERROR_CATEGORIES } = await import('../lib/aiToolkit/errorDetection.js');
-const { setAIToolkit, executeCliRun, buildCliArgs, hasModelFlag, extractBakedModel, emitRunStarted } = runner;
+const { setAIToolkit, executeCliRun, buildCliArgs, hasModelFlag, extractBakedModel, emitRunStarted, finalizeRunRecord } = runner;
// Minimal toolkit stub that satisfies executeCliRun's expectations. Mirrors the
// real toolkit runner's declared external-run registry (registerExternalRun /
@@ -96,6 +96,27 @@ beforeEach(() => {
setAIToolkit(fakeToolkit(), { dataDir: '/tmp/test-runner' });
});
+describe('finalizeRunRecord — authoritative timeout classification', () => {
+ it('does not let story text misclassify exit 124 as a provider quota failure', async () => {
+ setAIToolkit(fakeToolkit({ analyzeError }), { dataDir: '/tmp/test-runner' });
+
+ const metadata = await finalizeRunRecord({
+ runId: 'run-story-timeout',
+ output: 'A character debates billing, payment, and insufficient credit.',
+ exitCode: 124,
+ success: false,
+ error: 'TUI run timed out after 600000ms',
+ startTime: Date.now(),
+ });
+
+ expect(metadata).toMatchObject({
+ success: false,
+ errorCategory: ERROR_CATEGORIES.TIMEOUT,
+ errorAnalysis: expect.objectContaining({ category: ERROR_CATEGORIES.TIMEOUT }),
+ });
+ });
+});
+
describe('executeCliRun — Codex sentinel suppression', () => {
it('omits --model when defaultModel is codex-configured-default', async () => {
const child = makeChild();