diff --git a/src/infra/outbound/session-context.test.ts b/src/infra/outbound/session-context.test.ts index c24ede1f3e8..a62c47fb998 100644 --- a/src/infra/outbound/session-context.test.ts +++ b/src/infra/outbound/session-context.test.ts @@ -20,6 +20,19 @@ describe("buildOutboundSessionContext", () => { expect(resolveSessionAgentIdMock).not.toHaveBeenCalled(); }); + it("returns only the explicit trimmed agent id when no session key is present", () => { + expect( + buildOutboundSessionContext({ + cfg: {} as never, + sessionKey: " ", + agentId: " explicit-agent ", + }), + ).toEqual({ + agentId: "explicit-agent", + }); + expect(resolveSessionAgentIdMock).not.toHaveBeenCalled(); + }); + it("derives the agent id from the trimmed session key when no explicit agent is given", () => { resolveSessionAgentIdMock.mockReturnValueOnce("derived-agent");