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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
judge a layered-intelligence idle-out by its missing payload, not by its clean worktree
[._.]/ Adam Eivy6aa477bc1110
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 32cc3a44b1..e4b7d1927b 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -4,4 +4,6 @@- Series Pipeline and Manuscript Editor pages can now scroll through their full content on mobile.+- A Layered Intelligence run that ends badly now says what actually went wrong. Its whole job is to return JSON that a deterministic step files as one tracker issue — its prompt *forbids* touching the repo — yet the idle reaper judged it by the same "is there a file change or a commit?" question it asks a coding agent, and reported `idle-no-changes`: "the agent did not modify files", on a task told not to modify files. The real miss was one question away and is now the one asked: the `.agent-done` payload never landed, so nothing was filed. Failures on this task type read `idle-no-deliverable` and point at the missing payload (a smaller model answering in the terminal instead of writing the file — see #3640), and a run that did write its payload just before the reaper is now correctly rescued rather than failed for a clean tree. Code-editing task types are unchanged.+- CoS agents whose deliverable is a **commit** are no longer scored as failures. The idle reaper's "did this agent do anything?" gate read only *uncommitted* changes, so a `/do:release` or `/do:pr` run that committed, pushed, and opened its PR — leaving a clean tree *because it succeeded* — was recorded as `idle-no-changes` and retried. Two consecutive release runs on 2026-08-08 each did their whole job (cut the release commit, opened the release PR, then repaired it against review findings) and were both reported failed, holding the release for two days. The gate now counts commits made inside the run window as evidence of work, alongside a dirty tree. The report-shaped half of the same problem (`/do:review`, `/do:scan`, `/do:plan-task`, `/do:replan`, whose deliverable lands outside the repo) is tracked in #3636, and the unsatisfiable `[task-<id>]` success criterion one layer up in #3637.diff --git a/server/services/agentErrorAnalysis.js b/server/services/agentErrorAnalysis.jsindex 0f42838c0d..8bbb820314 100644--- a/server/services/agentErrorAnalysis.js+++ b/server/services/agentErrorAnalysis.js@@ -588,6 +588,18 @@ export const COMPLETION_REASON_ANALYSES = {message: 'Agent idled out with no file changes',suggestedFix: 'The agent stopped producing output without writing any files OR committing anything during the run. Check the raw transcript for where it stalled — a provider retry loop or a long-running command can outlast the idle reaper.'},+ // The programmatic-I/O counterpart of the above: a layered-intelligence run+ // delivers a `.agent-done` JSON payload, never a file change, so "no file+ // changes" was both the wrong measurement and the wrong advice. Same+ // `no-changes` category on purpose — the downstream taxonomies keep+ // classifying it without a new token — but the prose names what actually+ // went missing.+ 'idle-no-deliverable': {+ category: 'no-changes',+ actionable: false,+ message: 'Agent idled out without writing its structured output',+ suggestedFix: 'This task type is judged by the `.agent-done` payload an output hook consumes, not by file changes. The transcript often ENDS with the JSON the agent should have written to that file — a smaller model answering in the terminal instead of using a tool. Check the tail of the raw transcript, and prefer a model that reliably follows the write-the-file instruction.'+ },'idle-no-activity': {category: 'startup-failure',actionable: false,diff --git a/server/services/agentErrorAnalysis.test.js b/server/services/agentErrorAnalysis.test.jsindex a2e62107b6..1faac6ab18 100644--- a/server/services/agentErrorAnalysis.test.js+++ b/server/services/agentErrorAnalysis.test.js@@ -750,6 +750,22 @@ describe('analyzeAgentFailure — runner completion reason (COMPLETION_REASON_ANexpect(analysis.snippet).toContain('idled out');});+ // A programmatic-I/O run (layered-intelligence) is told NOT to touch the repo,+ // so "no file changes" was the wrong diagnosis and the wrong advice. Same+ // `no-changes` category so the downstream taxonomies keep classifying it, but+ // the prose has to name the payload that never landed.+ it('explains a programmatic-I/O idle-out as a missing payload, not a clean tree', () => {+ const analysis = analyzeAgentFailure(noisyTranscript, { id: 't' }, 'x', {+ completionReason: 'idle-no-deliverable',+ completionError: 'TUI agent idled out without writing its .agent-done payload',+ });+ expect(analysis.category).toBe('no-changes');+ expect(analysis.origin).toBe('runner');+ expect(analysis.completionReason).toBe('idle-no-deliverable');+ expect(analysis.message).toBe(COMPLETION_REASON_ANALYSES['idle-no-deliverable'].message);+ expect(analysis.suggestedFix).toContain('.agent-done');+ });+it('still yields to a STRUCTURED provider signal in the transcript', () => {const analysis = analyzeAgentFailure(withLead('API Error: 429 Too Many Requests — backing off'), { id: 't' }, 'x', {completionReason: 'idle-no-changes',diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.jsindex 9e39079c20..ca734f0bd1 100644--- a/server/services/agentTuiSpawning.js+++ b/server/services/agentTuiSpawning.js@@ -16,6 +16,7 @@ import { createOutputSpooler } from './agentTuiSpawning/outputSpooler.js';import { captureWorktreeDiff, worktreeHasWorkEvidence, resolveErrorAnalysis } from './agentTuiSpawning/finalizeHelpers.js';import { finalizeAgent, releaseAgentLane } from './agentFinalization.js';import { activeAgents, userTerminatedAgents, pausedAgents, isFalsyMeta, registerSpawnedAgent, unregisterSpawnedAgent } from './agentState.js';+import { isProgrammaticIoTaskType, resolveTaskHookType } from './taskTypeHooks.js';import { PATHS } from '../lib/fileUtils.js';import { DONE_SENTINEL_NAME, parseSentinelPayload } from '../lib/agentSentinel.js';import { shouldAbandonForHostShutdown, HOST_SHUTDOWN_REASON } from '../lib/hostShutdown.js';@@ -1456,18 +1457,43 @@ export async function spawnTuiAgent({// on today's behavior; the `workActivity.active` signal above still// distinguishes "prompt never submitted" → idle-no-activity either way.const worktreeChangesExpected = !isFalsyMeta(task?.metadata?.worktreeChangesExpected);+ // A PROGRAMMATIC-I/O run answers a DIFFERENT question, not a relaxed+ // version of this one. Its deliverable is the structured `.agent-done`+ // payload an output hook consumes — a layered-intelligence run reasons+ // over the app's goals and returns JSON that a deterministic step files as+ // one tracker issue — and its prompt FORBIDS touching the repo, so+ // worktree evidence measures nothing about it. Asking anyway blamed the+ // run for exactly the thing it was told not to do ("zero file changes"),+ // while the honest question is right there: did the payload land?+ // Usually it hasn't — the sentinel watcher below finalizes within+ // DONE_POLL_INTERVAL_MS of `.agent-done` appearing, so a run that reached+ // the reaper is normally one whose payload never materialized (the model+ // printed its JSON into the TUI instead of writing the file, #3640).+ // `sentinelPresent()` and not `false` because the two timers CAN land on+ // the same tick, and this one is registered first: an agent that wrote its+ // sentinel in the last idle window would otherwise be failed for a clean+ // tree by the interval that happened to run before the watcher.+ //+ // Deliberately NOT folded into `worktreeChangesExpected`: exempting it+ // from the gate would score that same run a PASS with no proposal filed,+ // trading a misleading failure for a silent one.+ const programmaticIo = isProgrammaticIoTaskType(resolveTaskHookType(task));(async () => {- const hasChanges = !worktreeChangesExpected || await worktreeHasWorkEvidence(cwd, startedAt);+ const delivered = programmaticIo+ ? sentinelPresent()+ : !worktreeChangesExpected || await worktreeHasWorkEvidence(cwd, startedAt);// Capture any uncommitted changes for post-mortem analysis regardless// of outcome — the diff is useful even on success for debugging, and is// a no-op on a clean tree.await captureWorktreeDiff(cwd, agentDir).catch(() => {});- if (!hasChanges) {+ if (!delivered) {finish({success: false,exitCode: 1,- error: 'TUI agent idled out with zero uncommitted file changes and no new commits — the model may have processed but produced no work.',- reason: 'idle-no-changes',+ error: programmaticIo+ ? 'TUI agent idled out without writing its .agent-done payload — this task type delivers structured output, not file changes, and nothing was left for the output hook to consume.'+ : 'TUI agent idled out with zero uncommitted file changes and no new commits — the model may have processed but produced no work.',+ reason: programmaticIo ? 'idle-no-deliverable' : 'idle-no-changes',}).catch(err => {emitLog('error', `Failed to finalize TUI agent ${agentId}: ${err.message}`, { agentId });});diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.jsindex 8e65bd50b9..5861266f6c 100644--- a/server/services/agentTuiSpawning.test.js+++ b/server/services/agentTuiSpawning.test.js@@ -78,15 +78,17 @@ vi.mock('./codeReview.js', () => ({})}));-vi.mock('./agentState.js', () => ({+// Only the mutable registries are stubbed; the module's pure predicates+// (isFalsyMeta et al., which the worktreeChangesExpected opt-out reads through)+// come from the real module — it is import-free, so there is nothing to isolate,+// and a hand-written copy would silently drift from the real metadata coercion.+vi.mock('./agentState.js', async (importOriginal) => ({+ ...await importOriginal(),activeAgents: new Map(),userTerminatedAgents: new Set(),pausedAgents: new Map(),registerSpawnedAgent: vi.fn(),unregisterSpawnedAgent: vi.fn(),- // Mirrors the real predicate (covers the TASKS.md string round-trip) — the- // worktreeChangesExpected opt-out reads through it.- isFalsyMeta: (value) => value === false || value === 'false',}));vi.mock('./git.js', () => ({@@ -1020,6 +1022,71 @@ describe('spawnTuiAgent runtime', () => {);});+ // ── 1a-sexies. A programmatic-I/O run is judged by its PAYLOAD, not the tree ──+ // A layered-intelligence run reasons over the app's goals and returns JSON that+ // a deterministic step files as one tracker issue; its prompt FORBIDS touching+ // the repo. Measuring it by worktree evidence blamed it for exactly the thing it+ // was told not to do — the failure read "zero file changes" on a task that must+ // change no files — and buried the real miss: no `.agent-done` payload landed,+ // so nothing was filed.+ const liTask = (metadata = {}) => ({+ id: 'task-1',+ description: 'do the thing',+ taskType: 'internal',+ metadata: { analysisType: 'layered-intelligence', useWorktree: true, openPR: false, discardWorktree: true, ...metadata },+ });++ it('idle-no-deliverable: a programmatic-I/O run with no sentinel fails on its OWN criterion', async () => {+ await driveIdleWithWorkOnCleanTree({ task: liTask() });++ expect(agentLifecycle.finalizeAgent).toHaveBeenCalledWith(+ expect.objectContaining({ success: false, completionReason: 'idle-no-deliverable' })+ );+ // The worktree question is never asked — it measures nothing about this run.+ expect(gitService.getStatus).not.toHaveBeenCalled();+ });++ it('idle-no-deliverable: the failure names the missing payload, not missing file changes', async () => {+ await driveIdleWithWorkOnCleanTree({ task: liTask() });++ const { error } = vi.mocked(agentLifecycle.finalizeAgent).mock.calls.at(-1)[0];+ expect(error).toContain('.agent-done');+ expect(error).not.toContain('zero uncommitted file changes');+ });++ // A DIRTY tree doesn't rescue it either: this type ships a payload, and stray+ // edits in a worktree that is discarded unmerged are not the deliverable.+ it('idle-no-deliverable: a dirty worktree does not substitute for the payload', async () => {+ vi.mocked(gitService.getStatus).mockResolvedValue({ clean: false, files: [{ path: 'f.txt', status: 'M' }] });+ let resolveComplete;+ const completeDone = new Promise((r) => { resolveComplete = r; });+ vi.mocked(agentLifecycle.finalizeAgent).mockImplementation(async () => { resolveComplete(); });++ await driveToSubmittedAndWorking({ task: liTask() });+ await vi.advanceTimersByTimeAsync(21000);+ vi.useRealTimers();+ await completeDone;++ expect(agentLifecycle.finalizeAgent).toHaveBeenCalledWith(+ expect.objectContaining({ success: false, completionReason: 'idle-no-deliverable' })+ );+ });++ // The type-derived question must not leak to a code-editing task that merely+ // carries the same worktree-disposal metadata: a quota-burn job can want a+ // scratch checkout it builds in and never lands, and it declares that shape via+ // `worktreeChangesExpected` instead.+ it('idle-no-changes: a code-editing task keeps the worktree criterion', async () => {+ await driveIdleWithWorkOnCleanTree({+ task: { id: 'task-1', description: 'do the thing', metadata: { analysisType: 'security', discardWorktree: true } },+ });++ expect(agentLifecycle.finalizeAgent).toHaveBeenCalledWith(+ expect.objectContaining({ success: false, completionReason: 'idle-no-changes' })+ );+ expect(gitService.getStatus).toHaveBeenCalled();+ });+// ── 1a-quinquies. A COMMIT during the run is evidence of work ────────────────// The #2191 gate above read only UNCOMMITTED changes, so a job whose// deliverable is a commit — `/do:release`, `/do:pr` — idled out on a clean