From 324d4a86f054bc40b8e1ddd0c6bbb3a35c4eb352 Mon Sep 17 00:00:00 2001 From: forrestlinfeng Date: Wed, 25 Nov 2026 22:15:48 +0800 Subject: [PATCH] fix(dsh): give a late recall's Proxy requests the 30 s background window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A host that adds context late (dsh) stops waiting for recall after 6 s and lets the recall finish in the background, but each of its Proxy requests still used the Proxy client's 8 s default. The local Proxy's text recall round trip runs 4.5–7.6 s on a normal day, so a slower one was cut at 8 s and the turn got nothing, not even late. Seen on 2026-11-25: the Hub served the right Gene first (fit 0.99) 3.4 s into the turn, and DSH Desktop injected nothing. With 5 s added to the Proxy's /asset/fetch, the installed 1.0.17 returns nothing at exactly 8.0 s in 4/4 rounds; with this change the strategy lands late in 4/4 rounds at 10–14 s. A late recall is already the background, so it now gets DEFERRED_RECALL_MS, the window the tool-result deferral (ZCode) uses. The test that pinned the 8 s default is changed to the new rule. Co-Authored-By: Claude Opus 5.5 --- lib/app/prompt.js | 7 ++++--- test/app/recall-deadline.test.js | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/app/prompt.js b/lib/app/prompt.js index ef169890..75a9049d 100644 --- a/lib/app/prompt.js +++ b/lib/app/prompt.js @@ -15,7 +15,7 @@ export const CLOSING = 'Apply them where they fit.'; // A Recipe still pending this close to the hook's deadline gives way to the single strategy, which needs the rest to be booked. const RECIPE_MARGIN_MS = 300; const LATE_RECIPE_WAIT_MS = 6_000; -// A recall that missed the prompt goes on in the background for the turn's first tool result, which comes later still. +// A recall that missed the prompt goes on in the background, for the turn's next model step or its first tool result. const DEFERRED_RECALL_MS = 30_000; const DEFER_GRACE_MS = 1_000; @@ -129,8 +129,9 @@ async function recalled(ports, sessionId, { turn, prompt, projectDir, waitMs, ke const context = session.task ? { task: session.task, trigger: 'turn_start' } : null; // Without a late answer the wait cancels every request when it ends anyway, so a request may run for all of it. A host // that sends a missed recall to the background needs the wait to end first: a request cut at or before it (the - // Proxy client's own default is 8 s) settles the recall empty, and it would never be deferred. - const timeoutMs = lateAtToolResult ? waitMs + DEFER_GRACE_MS : keepLate ? 0 : waitMs; + // Proxy client's own default is 8 s) settles the recall empty, and it would never be deferred. A late answer is that + // background already, and the Proxy's text recall alone can take 4–8 s, so its requests get the background window. + const timeoutMs = lateAtToolResult ? waitMs + DEFER_GRACE_MS : keepLate ? DEFERRED_RECALL_MS : waitMs; const { request: proxyFetch, signal, cancel } = recallRequestOf(ports.proxy, { timeoutMs }); const recipeCutoff = ports.clock.sleep(waitMs > 0 ? Math.max(0, waitMs - RECIPE_MARGIN_MS) : LATE_RECIPE_WAIT_MS, signal); const onWithheld = rememberWithheld(ports, sessionId, turn); diff --git a/test/app/recall-deadline.test.js b/test/app/recall-deadline.test.js index 08a44121..90bc2f33 100644 --- a/test/app/recall-deadline.test.js +++ b/test/app/recall-deadline.test.js @@ -67,10 +67,10 @@ test('a recall without a late answer lets each request run as long as the hook m assert.ok(requests.every(({ timeoutMs }) => timeoutMs === 10_000)); }); -test('a recall that may still answer late keeps the Proxy default per request', async () => { +test('a recall that may still answer late gives each request the background window, not the Proxy default of 8 s', async () => { const { ports, requests } = harness(); - const { late } = await promptSubmitted(ports, { sessionId: 's', prompt: PROMPT, waitMs: 0, keepLate: true }); + const { late } = await promptSubmitted(ports, { sessionId: 's', prompt: PROMPT, waitMs: 6_000, keepLate: true }); await late; assert.ok(requests.length > 0); - assert.ok(requests.every(({ timeoutMs }) => timeoutMs === undefined)); + assert.ok(requests.every(({ timeoutMs }) => timeoutMs === 30_000)); });