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
feat: nudge TUI sessions halted by a truncated response
Adam Eivy05ad8358a632
diff --git a/docs/features/cos-agent-runner.md b/docs/features/cos-agent-runner.mdindex 90cfc32bfa..0c4fd53da3 100644--- a/docs/features/cos-agent-runner.md+++ b/docs/features/cos-agent-runner.md@@ -43,12 +43,13 @@ A separate `portos-cos` PM2 process that:## Unattended recovery gates-Nobody is watching a CoS TUI session, so nothing types into it when the model stops early. Five gates in `server/services/agentTuiSpawning.js` watch the PTY stream and act on one shared 5s poll. Four of them prefer a nudge into the live session over a kill, because the TUI still holds the whole conversation; only the retry stall ends the run, since a request the provider never answers will not answer the next one either. No gate reaps a run on the clock alone — the wall-clock ceiling was removed deliberately, after it killed agents 30 seconds past a merged PR.+Nobody is watching a CoS TUI session, so nothing types into it when the model stops early. Six gates in `server/services/agentTuiSpawning.js` watch the PTY stream and act on one shared 5s poll. Five of them prefer a nudge into the live session over a kill, because the TUI still holds the whole conversation; only the retry stall ends the run, since a request the provider never answers will not answer the next one either. No gate reaps a run on the clock alone — the wall-clock ceiling was removed deliberately, after it killed agents 30 seconds past a merged PR.| Gate | What it sees | What it does || --- | --- | --- || Self-clearing provider signal | agy's "verifying your account eligibility" banner, which REJECTS the submission | Re-pastes the whole prompt while a grace window is open, then fails over || Local-runtime OOM | a Metal/CUDA out-of-memory box that killed the turn | Pastes `continue` once the session is quiet; fails over to a fallback provider after 3 |+| Truncated response | a harness banner that the response was cut off mid-generation (pi's TUI halts the whole session on it) | Pastes `continue` once the session is quiet; fails over to a fallback provider after 3 || Retry stall | the TUI retrying one request past attempt 3, ten minutes on | Fails the run over to a fallback provider || Tool-permission dialog | Claude Code asking to approve a call nobody can approve | Declines it, then explains why and sends the session back to work || **Stall** | **nothing at all — the session went quiet with the task unfinished** | **Pastes a `continue` nudge after 3 minutes of silence, up to 3 times; then badges the agent card `Stalled`** |diff --git a/server/lib/aiToolkit/errorDetection.js b/server/lib/aiToolkit/errorDetection.jsindex a335fab6d1..e47948ff5c 100644--- a/server/lib/aiToolkit/errorDetection.js+++ b/server/lib/aiToolkit/errorDetection.js@@ -589,6 +589,66 @@ export function createLocalRuntimeOomDetector({ maxBuffer = 512 } = {}) {};}+// A TUI harness that cut the model's response off mid-generation. pi's TUI+// halts the whole session on `Response was truncated before completion.` —+// the turn is dead, but the session still holds the whole conversation, and a+// human typing `continue` (Enter) resumes it every time. Unattended, nothing+// ever types that word: the run sits at the halted screen until the generic+// stall gate's ten-minute silence threshold, if it fires at all.+//+// The wording is vendor chrome, but it is English rather than a vendor error+// constant, so the pattern spells the whole sentence with `\s+` joins — a TUI+// hard-wraps at spaces, and the join lets a wrap survive where a literal+// space would not. The residual false-positive surface (an agent QUOTING the+// banner) is bounded by the consumer exactly as the OOM gate bounds its own:+// the nudge fires only once the session has already gone quiet, and the run+// fails over only after the truncations outlast every nudge+// (createTruncationNudgeGate in ../tuiHandshake.js).+//+// Deliberately NOT an entry in IMMEDIATE_FALLBACK_SIGNALS, for the same reason+// detectLocalRuntimeOom is not: that list arms the self-clearing gate in the+// one-shot runner too, whose remedy (re-pasting the whole prompt) would restart+// the task on top of work already done. The remedy here is a one-word+// continuation, and only `agentTuiSpawning` consults this.+//+// `category` reuses the agent-analysis `output-length` vocabulary on purpose:+// a truncated response is a response-ceiling failure, so it inherits that+// category's entire downstream policy — the SCHEMA_TYPE fix tier with its+// compaction hints, and no provider bench (a provider that truncates one+// over-long response serves every other prompt fine; see+// isRequestSpecificCategory in lib/providerCooldown.js).+const TRUNCATED_RESPONSE_PATTERN = /response\s+was\s+truncated\s+before\s+completion/i;++export function detectTruncatedResponse(text) {+ if (!text) return null;+ if (!TRUNCATED_RESPONSE_PATTERN.test(String(text))) return null;+ return {+ hasError: true,+ category: 'output-length',+ // A FIXED sentence, deliberately not the banner wording — the message+ // becomes the run's error string, which a CoS task description can quote+ // back through this very detector (same reasoning as detectLocalRuntimeOom).+ message: 'Provider cut the response off before completion',+ waitTime: null,+ requiresFallback: true,+ actionable: false,+ graceMs: 0,+ suggestedFix: 'The provider truncated the response mid-generation. A continue nudge resumes the session; if it keeps truncating, route the task to a fallback provider or reduce the requested response size.',+ origin: 'provider',+ };+}++export function createTruncatedResponseDetector({ maxBuffer = 512 } = {}) {+ let buffer = '';+ const cap = Number.isFinite(maxBuffer) && maxBuffer > 0 ? maxBuffer : 512;++ return (chunk) => {+ if (!chunk) return null;+ buffer = `${buffer}${String(chunk)}`.slice(-cap);+ return detectTruncatedResponse(buffer);+ };+}+// Claude Code's in-TUI retry banner, painted while it re-sends a failed request:// `API error · Retrying in 0s · attempt 1/10` (the prefix varies — `Request timed// out`, `Overloaded` — so only the retry suffix is matched). The whitespace isdiff --git a/server/lib/aiToolkit/errorDetection.test.js b/server/lib/aiToolkit/errorDetection.test.jsindex 8f08a7acd0..39412073d2 100644--- a/server/lib/aiToolkit/errorDetection.test.js+++ b/server/lib/aiToolkit/errorDetection.test.js@@ -7,10 +7,12 @@ import {createImmediateFallbackSignalDetector,createTerminalModelErrorDetector,createLocalRuntimeOomDetector,+ createTruncatedResponseDetector,createTerminalRequestTimeoutDetector,detectImmediateFallbackSignal,detectClaudeSessionLimitBanner,detectLocalRuntimeOom,+ detectTruncatedResponse,detectTerminalModelError,detectTerminalRequestTimeout,detectTuiRetryBanner,@@ -710,6 +712,49 @@ describe('Error Detection', () => {});});+ describe('detectTruncatedResponse', () => {+ // pi's TUI halt banner, as the ANSI-stripped screen renders it — the+ // sentence a halted session sits on until somebody types `continue`.+ const TRUNCATION_BANNER = 'Response was truncated before completion.';++ it('detects the truncation banner', () => {+ expect(detectTruncatedResponse(TRUNCATION_BANNER)).toMatchObject({+ category: 'output-length',+ requiresFallback: true,+ // Nobody has to fix anything — the session just needs a turn.+ actionable: false,+ // Nudge-then-fail-over is the caller's policy, not a grace window here.+ graceMs: 0,+ origin: 'provider',+ });+ });++ it('survives the TUI hard-wrapping the sentence at a space', () => {+ expect(detectTruncatedResponse('Response was truncated before\ncompletion.'))+ .toMatchObject({ category: 'output-length' });+ });++ it('leaves ordinary prose about truncation alone', () => {+ expect(detectTruncatedResponse('the log was truncated for brevity')).toBeNull();+ expect(detectTruncatedResponse('truncated before saving')).toBeNull();+ expect(detectTruncatedResponse('')).toBeNull();+ });++ it('buffers the banner across stream chunks', () => {+ const detect = createTruncatedResponseDetector();+ expect(detect('...(00000008: Response was truncated')).toBeNull();+ expect(detect(' before completion.')).toMatchObject({ category: 'output-length' });+ });++ it('reports a message that cannot re-match the detector', () => {+ // Same reasoning as detectLocalRuntimeOom: the message becomes the run's+ // error string, which a CoS task description can quote back through this+ // very detector via the TUI's prompt echo.+ const { message } = detectTruncatedResponse(TRUNCATION_BANNER);+ expect(detectTruncatedResponse(message)).toBeNull();+ });+ });+describe('detectTuiRetryBanner', () => {it('reads Claude Code\'s retry banner as it comes off the ANSI-stripped screen', () => {// Verbatim shape from agent-e057cca7's raw.txt (2026-09-04), afterdiff --git a/server/lib/tuiHandshake.js b/server/lib/tuiHandshake.jsindex 2e6c78c1b2..dbf587d25e 100644--- a/server/lib/tuiHandshake.js+++ b/server/lib/tuiHandshake.js@@ -1293,6 +1293,48 @@ export function createOomNudgeGate() {};}+// ─── Truncation nudge — "the harness cut the response off mid-generation" ────+//+// pi's TUI halts the whole session on `Response was truncated before+// completion.` — the turn is dead, but the session still holds the whole+// conversation, and the only thing that resumes it is somebody typing+// `continue` and pressing Enter. Unattended, nothing ever does: the run sits+// at the halted screen holding its lane. Same shape as the OOM gate above+// (a dead turn, an intact session), so it rides the same silence policy and+// the same budget — only the detector differs+// (detectTruncatedResponse in ../aiToolkit/errorDetection.js).++// Reuses the OOM gate's timing wholesale. The truncation banner, like the OOM+// box, keeps repainting for chunks after the event, so the cooldown and the+// wait-for-silence window are the same load-bearing details; and a response+// that truncates three times in one run is not going to complete on the+// fourth, for the same reason an OOM that outlasts three nudges isn't.+export const TRUNCATION_NUDGE_MAX_ATTEMPTS = OOM_NUDGE_MAX_ATTEMPTS;+// What gets pasted. The literal word a human typed, for the literal reason it+// worked: the TUI still holds the conversation and the model just needs a turn.+export const TRUNCATION_NUDGE_TEXT = 'continue';++/**+ * State machine for "nudge a TUI session a truncated response left halted".+ * Identical policy to `createOomNudgeGate` — see `createSilenceNudgeGate` for+ * the semantics of `arm` / `takeNudge`.+ *+ * @returns {{ arm: (analysis: object, nowMs: number) => 'armed'|'exhausted'|null,+ * takeNudge: (nowMs: number, lastOutputAtMs: number) => number }}+ */+export function createTruncationNudgeGate() {+ const gate = createSilenceNudgeGate({+ cooldownMs: OOM_NUDGE_COOLDOWN_MS,+ settleMs: OOM_NUDGE_SETTLE_MS,+ armWindowMs: OOM_NUDGE_ARM_WINDOW_MS,+ maxAttempts: TRUNCATION_NUDGE_MAX_ATTEMPTS,+ });+ return {+ arm: (analysis, nowMs) => (analysis ? gate.arm(nowMs) : null),+ takeNudge: gate.takeNudge,+ };+}+/*** The "wait for silence, then nudge" policy the OOM gate and the* tool-permission gate share: dedupe sightings inside `cooldownMs` (a TUIdiff --git a/server/lib/tuiHandshake.test.js b/server/lib/tuiHandshake.test.jsindex 220d61eb1a..127e303632 100644--- a/server/lib/tuiHandshake.test.js+++ b/server/lib/tuiHandshake.test.js@@ -14,6 +14,8 @@ import {OOM_NUDGE_ARM_WINDOW_MS,OOM_NUDGE_COOLDOWN_MS,OOM_NUDGE_MAX_ATTEMPTS,+ createTruncationNudgeGate,+ TRUNCATION_NUDGE_MAX_ATTEMPTS,createStallNudgeGate,STALL_NUDGE_MAX_TOTAL,STALL_NUDGE_IDLE_MS,@@ -1917,6 +1919,68 @@ describe('createOomNudgeGate', () => {});});+describe('createTruncationNudgeGate', () => {+ // Same shape as the OOM gate: a dead turn, an intact session. These pin the+ // policy is truly shared rather than drifting from createOomNudgeGate.+ const analysis = { category: 'output-length', message: 'Provider cut the response off before completion' };++ it('nudges only once the session has actually gone quiet', () => {+ const gate = createTruncationNudgeGate();+ const t0 = 1_000_000;+ expect(gate.arm(analysis, t0)).toBe('armed');+ // The banner is still on screen — nudging here lands on chrome, not on an+ // idle composer.+ expect(gate.takeNudge(t0 + OOM_NUDGE_SETTLE_MS, t0 + 5_000)).toBe(0);+ expect(gate.takeNudge(t0 + OOM_NUDGE_SETTLE_MS + 5_001, t0 + 5_000)).toBe(1);+ // Fired once; the arm is spent until the next distinct truncation.+ expect(gate.takeNudge(t0 + 60_000, t0 + 5_000)).toBe(0);+ });++ it('treats repaints of the same banner as one truncation', () => {+ const gate = createTruncationNudgeGate();+ const t0 = 0;+ expect(gate.arm(analysis, t0)).toBe('armed');+ expect(gate.arm(analysis, t0 + 100)).toBeNull();+ expect(gate.takeNudge(t0 + OOM_NUDGE_SETTLE_MS + 1, t0)).toBe(1);+ // Disarmed, but still inside the dedupe cooldown — a repaint must not+ // spend a second nudge on the same event.+ expect(gate.arm(analysis, t0 + OOM_NUDGE_COOLDOWN_MS - 1)).toBeNull();+ expect(gate.arm(analysis, t0 + OOM_NUDGE_COOLDOWN_MS)).toBe('armed');+ });++ it('drops a stale arm the session never went quiet for', () => {+ const gate = createTruncationNudgeGate();+ const t0 = 0;+ gate.arm(analysis, t0);+ // Output kept flowing for the whole window: the session recovered on its+ // own, so the arm expires rather than firing into the next quiet spell.+ expect(gate.takeNudge(t0 + OOM_NUDGE_ARM_WINDOW_MS + 1, t0 + OOM_NUDGE_ARM_WINDOW_MS)).toBe(0);+ const t1 = t0 + OOM_NUDGE_COOLDOWN_MS;+ expect(gate.arm(analysis, t1)).toBe('armed');+ expect(gate.takeNudge(t1 + OOM_NUDGE_SETTLE_MS + 1, t1)).toBe(1);+ });++ it('hands back an exhausted verdict once the nudge budget is spent', () => {+ const gate = createTruncationNudgeGate();+ let t = 0;+ for (let i = 1; i <= TRUNCATION_NUDGE_MAX_ATTEMPTS; i += 1) {+ expect(gate.arm(analysis, t)).toBe('armed');+ t += OOM_NUDGE_SETTLE_MS + 1;+ expect(gate.takeNudge(t, t - OOM_NUDGE_SETTLE_MS - 1)).toBe(i);+ t += OOM_NUDGE_COOLDOWN_MS;+ }+ // Truncated again after the budget: this provider is not going to finish+ // the response, so the caller fails over instead of nudging again.+ expect(gate.arm(analysis, t)).toBe('exhausted');+ });++ it('ignores a null analysis', () => {+ const gate = createTruncationNudgeGate();+ expect(gate.arm(null, 0)).toBeNull();+ expect(gate.takeNudge(OOM_NUDGE_SETTLE_MS + 1, 0)).toBe(0);+ });+});+// The four modals a TUI can paint before its prompt can be delivered used to// be four booleans in spawnTuiAgent's closure plus four inline arms in its// 300ms poll. They are one table here now, so these pin the contract thediff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.jsindex 0a066888a8..c2b0e95de0 100644--- a/server/services/agentTuiSpawning.test.js+++ b/server/services/agentTuiSpawning.test.js@@ -264,6 +264,8 @@ import {OOM_NUDGE_COOLDOWN_MS,OOM_NUDGE_MAX_ATTEMPTS,OOM_NUDGE_TEXT,+ TRUNCATION_NUDGE_MAX_ATTEMPTS,+ TRUNCATION_NUDGE_TEXT,STALL_NUDGE_IDLE_MS,STALL_NUDGE_MAX_ATTEMPTS,STALL_NUDGE_TEXT,@@ -1889,6 +1891,95 @@ describe('spawnTuiAgent runtime', () => {);});+ // ── Truncated response: a nudge, not a verdict ─────────────────────────────+ // pi's TUI halts the whole session on `Response was truncated before+ // completion.` — the turn is dead, the session holds the whole conversation,+ // and the only resume is somebody typing `continue` and pressing Enter.+ // Unattended, nothing ever does. Same shape as the OOM gate above, so the+ // same three behaviors are pinned: nudge without re-sending the prompt,+ // leave a session that carried on alone, fail over once the truncations+ // outlast every nudge.+ const TRUNCATION_BANNER = 'Response was truncated before completion.';++ it('nudges a session a truncated response halted, without re-sending the prompt', async () => {+ await driveAgyToSubmittedPrompt();+ vi.mocked(shellService.pasteToSession).mockClear();++ await capturedOnData(Buffer.from(TRUNCATION_BANNER));+ await flushMicrotasks();+ // The banner is still repainting — nudging into that lands on chrome,+ // not on an idle composer.+ await vi.advanceTimersByTimeAsync(5000);+ await flushMicrotasks();+ expect(shellService.pasteToSession).not.toHaveBeenCalled();++ await vi.advanceTimersByTimeAsync(PAST_SETTLE_MS);+ await flushMicrotasks();+ expect(shellService.pasteToSession).toHaveBeenCalledWith(+ SESSION_ID,+ TRUNCATION_NUDGE_TEXT,+ expect.objectContaining({ label: expect.stringContaining('truncated-response') }),+ );+ // Exactly one nudge, and the run is left alone to carry on.+ expect(shellService.pasteToSession).toHaveBeenCalledTimes(1);+ expect(agentLifecycle.finalizeAgent).not.toHaveBeenCalled();+ });++ it('leaves a session that kept working after the truncation alone', async () => {+ await driveAgyToSubmittedPrompt();+ vi.mocked(shellService.pasteToSession).mockClear();++ await capturedOnData(Buffer.from(TRUNCATION_BANNER));+ await flushMicrotasks();+ // The TUI never goes quiet — it recovered on its own — so the arm has to+ // expire rather than wait around to fire into the next quiet stretch.+ for (let elapsed = 0; elapsed <= OOM_NUDGE_ARM_WINDOW_MS; elapsed += 5000) {+ await capturedOnData(Buffer.from('still working\n'));+ await flushMicrotasks();+ await vi.advanceTimersByTimeAsync(5000);+ await flushMicrotasks();+ }+ await vi.advanceTimersByTimeAsync(PAST_SETTLE_MS);+ await flushMicrotasks();++ expect(shellService.pasteToSession).not.toHaveBeenCalled();+ });++ it('falls back once the truncations outlast every nudge', async () => {+ let resolveComplete;+ const completeDone = new Promise((r) => { resolveComplete = r; });+ vi.mocked(agentLifecycle.finalizeAgent).mockImplementation(async () => { resolveComplete(); });++ await driveAgyToSubmittedPrompt();+ vi.mocked(shellService.pasteToSession).mockClear();++ for (let i = 0; i < TRUNCATION_NUDGE_MAX_ATTEMPTS; i += 1) {+ await capturedOnData(Buffer.from(TRUNCATION_BANNER));+ await flushMicrotasks();+ await vi.advanceTimersByTimeAsync(PAST_SETTLE_MS);+ await flushMicrotasks();+ // Clear the dedupe cooldown so the next banner reads as a NEW truncation+ // rather than a repaint of the one just nudged.+ await vi.advanceTimersByTimeAsync(OOM_NUDGE_COOLDOWN_MS);+ await flushMicrotasks();+ }+ expect(shellService.pasteToSession).toHaveBeenCalledTimes(TRUNCATION_NUDGE_MAX_ATTEMPTS);++ // The budget is spent and it truncated again: this provider is not going+ // to finish the response, so the task goes to a fallback provider.+ await capturedOnData(Buffer.from(TRUNCATION_BANNER));+ vi.useRealTimers();+ await completeDone;++ expect(agentLifecycle.finalizeAgent).toHaveBeenCalledWith(+ expect.objectContaining({+ success: false,+ completionReason: 'fallback-signal',+ error: expect.stringContaining('cut the response off'),+ })+ );+ });+// ── Retry stall: the provider keeps failing the same request ───────────────// agent-e057cca7 (2026-09-04): a Stage 3 prefill the harness cancelled every// ~6 minutes and re-sent verbatim. The screen repaints on every attempt, sodiff --git a/server/services/agentTuiSpawning/sessionController.js b/server/services/agentTuiSpawning/sessionController.jsindex 8a9934b177..e5b6c1ddf8 100644--- a/server/services/agentTuiSpawning/sessionController.js+++ b/server/services/agentTuiSpawning/sessionController.js@@ -37,7 +37,7 @@ import { SENTINEL_COMPLETION_MARKER } from '../../lib/agentOutputMarkers.js';import { prClaimWasVerified } from '../../lib/prDisposition.js';import { resolveMergeGateVerdict, buildMergeGateReprompt } from '../../lib/mergeGateContract.js';import { createStreamingAnsiStripper, stripAnsi } from '../../lib/ansiStrip.js';-import { createClaudeSessionLimitBannerDetector, createImmediateFallbackSignalDetector, createLocalRuntimeOomDetector } from '../../lib/aiToolkit/errorDetection.js';+import { createClaudeSessionLimitBannerDetector, createImmediateFallbackSignalDetector, createLocalRuntimeOomDetector, createTruncatedResponseDetector } from '../../lib/aiToolkit/errorDetection.js';import { isAntigravityCommand } from '../../lib/antigravity.js';import { isCodexCommand } from '../../lib/codex.js';import { isClaudeCommand } from '../../lib/providerModels.js';@@ -54,6 +54,9 @@ import {TOOL_PERMISSION_NUDGE_TEXT,OOM_NUDGE_MAX_ATTEMPTS,OOM_NUDGE_TEXT,+ createTruncationNudgeGate,+ TRUNCATION_NUDGE_MAX_ATTEMPTS,+ TRUNCATION_NUDGE_TEXT,createStallNudgeGate,STALL_NUDGE_MAX_ATTEMPTS,STALL_NUDGE_TEXT,@@ -537,6 +540,12 @@ export function createTuiSessionController({// createOomNudgeGate for why this is a separate mechanism from the gate above.const detectLocalRuntimeOom = createLocalRuntimeOomDetector();const oomNudgeGate = createOomNudgeGate();+ // A harness that cut the response off mid-generation (pi's TUI halts the+ // whole session on its truncation banner). Same shape as the OOM gate — a+ // dead turn, an intact session — so it nudges rather than re-prompts. See+ // createTruncationNudgeGate.+ const detectTruncatedResponse = createTruncatedResponseDetector();+ const truncationNudgeGate = createTruncationNudgeGate();// A request the TUI keeps retrying and the provider never answers. Every// reaper reads such a session as busy (the retry ladder repaints the screen),// so without this the run holds its lane until the max-runtime ceiling — see@@ -1298,6 +1307,24 @@ export function createTuiSessionController({}}+ // A truncated response. Same shape as the OOM above — the turn is dead,+ // the session is intact — so it arms a nudge instead of killing the run;+ // the provider-signal timer sends it once the session has actually gone+ // quiet. Same promptSubmittedAt gating: before the prompt is in there is+ // no response of ours to have been truncated.+ const truncationSignal = promptSubmittedAt ? detectTruncatedResponse(stripped) : null;+ if (truncationSignal) {+ const armed = truncationNudgeGate.arm(truncationSignal, now);+ if (armed === 'armed') {+ appendLine('⏳ Response was truncated before completion — will nudge the session to continue if it goes quiet');+ } else if (armed === 'exhausted') {+ // The truncations outlasted every nudge: this provider is not going+ // to finish this response, so hand the task to a fallback provider.+ await failOverToFallback(truncationSignal);+ return;+ }+ }+// Same gating as the OOM nudge above: before the prompt is in there is no// request of ours for the provider to be retrying. Acted on by the// provider-signal timer, on its own poll, like the other gates.@@ -1648,6 +1675,15 @@ export function createTuiSessionController({}return;}+ // Nudge a session a truncated response halted — the pi-TUI case where the+ // only resume is somebody typing `continue`. Same timer, same reasoning.+ const truncationNudge = truncationNudgeGate.takeNudge(now, lastOutputAt);+ if (truncationNudge) {+ if (pasteController?.resubmit({ text: TRUNCATION_NUDGE_TEXT, label: 'truncated-response nudge' })) {+ appendLine(`🔁 Response was truncated before completion — nudged the session to continue (attempt ${truncationNudge}/${TRUNCATION_NUDGE_MAX_ATTEMPTS})`);+ }+ return;+ }// Last, and only once no gate above has a say: every one of them describes a// session stalled for a KNOWN reason, and their own silence tests would be// pre-empted by a nudge sent on plain quiet.