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:
Mathews-Tom
2026-07-02 06:46:17 +05:30
parent 4aac8640fa
commit c1ea6ca7dc
2 changed files with 9 additions and 12 deletions
@@ -285,7 +285,7 @@ describe("azure openai responses streaming", () => {
expect(result.stopReason).toBe("error");
expect(result.errorMessage).toContain("server_error: backend exploded late");
});
it("preserves assistant message phase when rebuilding fallback replay history", async () => {
it("preserves assistant message id and phase when rebuilding fallback replay history", async () => {
const payload = await captureAzurePayload({
messages: [
{ role: "user", content: "first user", timestamp: Date.now() },
@@ -304,13 +304,14 @@ describe("azure openai responses streaming", () => {
role: "assistant",
content: [{ type: "output_text", text: "Commentary answer", annotations: [] }],
status: "completed",
id: "msg_commentary",
phase: "final_answer",
},
{ role: "user", content: [{ type: "input_text", text: "follow-up" }] },
]);
});
it("omits legacy plain-string text signature IDs when rebuilding fallback replay history without reasoning", async () => {
it("preserves legacy plain-string text signature IDs when rebuilding fallback replay history", async () => {
const payload = await captureAzurePayload({
messages: [
{ role: "user", content: "first user", timestamp: Date.now() },
@@ -326,6 +327,7 @@ describe("azure openai responses streaming", () => {
role: "assistant",
content: [{ type: "output_text", text: "Legacy answer", annotations: [] }],
status: "completed",
id: "msg_legacy",
},
{ role: "user", content: [{ type: "input_text", text: "follow-up" }] },
]);
@@ -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;