fix(consult): 窗口溢出重试保留预跑证据包,回填修复版本 SHA
This commit is contained in:
@@ -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:/);
|
||||
|
||||
Reference in New Issue
Block a user