fix(consult): 窗口溢出重试保留预跑证据包,回填修复版本 SHA
Independent Staging Quality Gate / validate (push) Successful in 10m28s
Independent Staging Quality Gate / publish (push) Successful in 10m58s

This commit is contained in:
jesse-ux
2026-09-18 18:47:01 +08:00
parent 9ccb65b71f
commit e760b1d610
5 changed files with 24 additions and 16 deletions
+6 -1
View File
@@ -895,6 +895,7 @@ export async function POST(request: Request) {
];
};
let baseMessages = consultationBaseMessages(false);
let windowPacketMessage: string | null = null;
const agentAbortSignal = AbortSignal.timeout(AGENT_TIMEOUT_MS);
const streamOptions = {
runId: requestId,
@@ -930,6 +931,9 @@ export async function POST(request: Request) {
// clients cannot parse rectification `attempt.reset`, so the retry stays
// server-side and never opens a second user-visible wait.
baseMessages = consultationBaseMessages(true);
if (windowPacketMessage) {
baseMessages = [...baseMessages, { role: "user" as const, content: windowPacketMessage }];
}
const overflow = await agent.stream(baseMessages, options);
usages.push(overflow.totalUsage);
return overflow;
@@ -1111,9 +1115,10 @@ export async function POST(request: Request) {
},
},
});
windowPacketMessage = windowPrecomputedPacketMessage(packet);
baseMessages = [
...baseMessages,
{ role: "user" as const, content: windowPrecomputedPacketMessage(packet) },
{ role: "user" as const, content: windowPacketMessage },
];
} catch {
// Leave the contract red; the model may still call the tool.
@@ -368,6 +368,9 @@ test("window calculation is precomputed on the agent context cache (BUG-957)", (
assert.match(windowBranch, /precomputeWindowConsultation/);
assert.match(windowBranch, /warmup:/);
assert.match(windowBranch, /windowPrecomputedPacketMessage/);
assert.match(route, /let windowPacketMessage: string \| null = null/);
assert.match(route, /if \(windowPacketMessage\) \{/);
assert.match(route, /content: windowPacketMessage/);
assert.doesNotMatch(windowBranch, /toolChoice:\s*"required"/);
assert.doesNotMatch(natalBranch, /precomputeWindowConsultation/);
assert.doesNotMatch(natalBranch, /warmup:/);