Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/app/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 next model step or its first tool result.
// A recall that missed the prompt goes on in the background for the turn's first tool result, which comes later still.
const DEFERRED_RECALL_MS = 30_000;
const DEFER_GRACE_MS = 1_000;

Expand Down Expand Up @@ -129,9 +129,8 @@ 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. 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;
// 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;
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);
Expand Down
6 changes: 3 additions & 3 deletions test/app/recall-deadline.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 gives each request the background window, not the Proxy default of 8 s', async () => {
test('a recall that may still answer late keeps the Proxy default per request', async () => {
const { ports, requests } = harness();
const { late } = await promptSubmitted(ports, { sessionId: 's', prompt: PROMPT, waitMs: 6_000, keepLate: true });
const { late } = await promptSubmitted(ports, { sessionId: 's', prompt: PROMPT, waitMs: 0, keepLate: true });
await late;
assert.ok(requests.length > 0);
assert.ok(requests.every(({ timeoutMs }) => timeoutMs === 30_000));
assert.ok(requests.every(({ timeoutMs }) => timeoutMs === undefined));
});
Loading