test: fix azure msg-id preservation and retry-diagnostics log shape
Second upstream merge (upstream/main advanced 24 more commits) pulled
in two independent behavior changes that broke tests I'd already
touched or that existed:
- packages/ai: commits cda6df81d/d7f070d44 added
preserveAssistantMessageIds for Azure specifically (azure sets it
true), so the earlier fix stripping msg ids in
azure-openai-responses-stream.test.ts is now wrong for Azure — it
should preserve them, unlike the plain OpenAI path. Restored the
id/phase assertions and renamed both tests to describe the
preserve-not-omit contract.
- packages/coding-agent: commit 0e2feab74 (refactor: reduced session
log footprint) deleted the
'#agentContinueState'/'agent.continue failed state after
scheduling' debug diagnostics and changed
'agent active context assistant removal' to fire only on a miss,
renamed to 'agent active context assistant removal missed' with a
smaller payload (no more removed/beforeLength/afterLength/etc).
agent-session-retry-diagnostics.test.ts still asserted the old
shape and waited on a debug call that no longer exists, so it hung
for the full 5s timeout. Updated to match the new log name/payload
and dropped the removed diagnostic assertion; the retry-recovery
behavior itself is unchanged and still exercised end to end.
This commit is contained in:
@@ -74,11 +74,11 @@ async function waitFor(predicate: () => boolean, timeoutMs = 500): Promise<void>
|
||||
function isRemovalMissDebugCall(call: unknown[]): boolean {
|
||||
const payload = call[1];
|
||||
return (
|
||||
call[0] === "agent active context assistant removal" &&
|
||||
call[0] === "agent active context assistant removal missed" &&
|
||||
typeof payload === "object" &&
|
||||
payload !== null &&
|
||||
"removed" in payload &&
|
||||
payload.removed === false
|
||||
"reason" in payload &&
|
||||
payload.reason === "auto-retry"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -143,15 +143,10 @@ describe("AgentSession retry diagnostics", () => {
|
||||
|
||||
const promptPromise = session.prompt("trigger transient error").catch(() => undefined);
|
||||
await waitFor(() => debugSpy.mock.calls.some(isRemovalMissDebugCall));
|
||||
await waitFor(() => debugSpy.mock.calls.some(call => call[0] === "agent.continue failed state after scheduling"));
|
||||
|
||||
expect(debugSpy.mock.calls).toContainEqual([
|
||||
"agent active context assistant removal",
|
||||
expect.objectContaining({ reason: "auto-retry", removed: false, lastRole: "assistant" }),
|
||||
]);
|
||||
expect(debugSpy.mock.calls).toContainEqual([
|
||||
"agent.continue failed state after scheduling",
|
||||
expect.objectContaining({ lastRole: "assistant", messageCount: 2 }),
|
||||
"agent active context assistant removal missed",
|
||||
expect.objectContaining({ reason: "auto-retry", lastRole: "assistant" }),
|
||||
]);
|
||||
await session.abort();
|
||||
await promptPromise;
|
||||
|
||||
Reference in New Issue
Block a user