diff --git a/nodejs/test/e2e/session.test.ts b/nodejs/test/e2e/session.test.ts index dbcbed8bb..fef358f39 100644 --- a/nodejs/test/e2e/session.test.ts +++ b/nodejs/test/e2e/session.test.ts @@ -15,7 +15,9 @@ describe("Sessions", async () => { }); expect(session.sessionId).toMatch(/^[a-f0-9-]+$/); - expect(await session.getMessages()).toMatchObject([ + const allEvents = await session.getMessages(); + const sessionStartEvents = allEvents.filter((e) => e.type === "session.start"); + expect(sessionStartEvents).toMatchObject([ { type: "session.start", data: { sessionId: session.sessionId, selectedModel: "fake-test-model" }, diff --git a/test/harness/replayingCapiProxy.ts b/test/harness/replayingCapiProxy.ts index 7481bc2f7..a41b93d78 100644 --- a/test/harness/replayingCapiProxy.ts +++ b/test/harness/replayingCapiProxy.ts @@ -308,6 +308,22 @@ export class ReplayingCapiProxy extends CapturingHttpProxy { } } + // Beyond this point, we're only going to be able to supply responses in CI if we have a snapshot, + // and we only store snapshots for chat completion. For anything else (e.g., custom-agents fetches), + // return 404 so the CLI treats them as unavailable instead of erroring. + if (options.requestOptions.path !== chatCompletionEndpoint) { + const headers = { + "content-type": "application/json", + "x-github-request-id": "proxy-not-found", + }; + options.onResponseStart(404, headers); + options.onData( + Buffer.from(JSON.stringify({ error: "Not found by test proxy" })), + ); + options.onResponseEnd(); + return; + } + // Fallback to normal proxying if no cached response found // This implicitly captures the new exchange too const isCI = process.env.GITHUB_ACTIONS === "true";