diff --git a/src/agents/pi-embedded-runner/run/failover-observation.test.ts b/src/agents/pi-embedded-runner/run/failover-observation.test.ts index 763540f9ca7..71363915b46 100644 --- a/src/agents/pi-embedded-runner/run/failover-observation.test.ts +++ b/src/agents/pi-embedded-runner/run/failover-observation.test.ts @@ -1,21 +1,31 @@ import { describe, expect, it } from "vitest"; import { normalizeFailoverDecisionObservationBase } from "./failover-observation.js"; +function normalizeObservation( + overrides: Partial[0]>, +) { + return normalizeFailoverDecisionObservationBase({ + stage: "assistant", + runId: "run:base", + rawError: "", + failoverReason: null, + profileFailureReason: null, + provider: "openai", + model: "mock-1", + profileId: "openai:p1", + fallbackConfigured: false, + timedOut: false, + aborted: false, + ...overrides, + }); +} + describe("normalizeFailoverDecisionObservationBase", () => { it("fills timeout observation reasons for deadline timeouts without provider error text", () => { expect( - normalizeFailoverDecisionObservationBase({ - stage: "assistant", + normalizeObservation({ runId: "run:timeout", - rawError: "", - failoverReason: null, - profileFailureReason: null, - provider: "openai", - model: "mock-1", - profileId: "openai:p1", - fallbackConfigured: false, timedOut: true, - aborted: false, }), ).toMatchObject({ failoverReason: "timeout", @@ -26,18 +36,13 @@ describe("normalizeFailoverDecisionObservationBase", () => { it("preserves explicit failover reasons", () => { expect( - normalizeFailoverDecisionObservationBase({ - stage: "assistant", + normalizeObservation({ runId: "run:overloaded", rawError: '{"error":{"type":"overloaded_error"}}', failoverReason: "overloaded", profileFailureReason: "overloaded", - provider: "openai", - model: "mock-1", - profileId: "openai:p1", fallbackConfigured: true, timedOut: true, - aborted: false, }), ).toMatchObject({ failoverReason: "overloaded",