diff --git a/packages/core/execution/src/jev.test.ts b/packages/core/execution/src/jev.test.ts index 0e1566ac82..1c401d60e3 100644 --- a/packages/core/execution/src/jev.test.ts +++ b/packages/core/execution/src/jev.test.ts @@ -114,6 +114,19 @@ describe("askJev", () => { expect(request?.headers["authorization"]).toBeUndefined(); })); + it.effect("attributes the call in the AI Gateway logs with cf-aig-metadata", () => + Effect.gen(function* () { + const { layer, requests } = yield* recordingClient(); + yield* askJev({ + config: CONFIG, + state: "s", + questions: [{ id: "a", instructions: "q" }], + httpClientLayer: layer, + }); + const [request] = yield* Ref.get(requests); + expect(request?.headers["cf-aig-metadata"]).toBe('{"call_name":"jev","flow":"executor"}'); + })); + it.effect("resolves the token per call, so a rotated secret is picked up without redeploying", () => Effect.gen(function* () { const { layer, requests } = yield* recordingClient(); diff --git a/packages/core/execution/src/jev.ts b/packages/core/execution/src/jev.ts index 0f4d522b31..992e12aa05 100644 --- a/packages/core/execution/src/jev.ts +++ b/packages/core/execution/src/jev.ts @@ -28,6 +28,8 @@ export const JEV_MODEL = "jev-1.13.0"; export const JEV_STATE_CHAR_BUDGET = 32_000 * 3; export const JEV_TOTAL_CHAR_BUDGET = 64_000 * 3; +const JEV_GATEWAY_METADATA = JSON.stringify({ call_name: "jev", flow: "executor" }); + export class JevError extends Data.TaggedError("JevError")<{ readonly message: string; readonly status?: number; @@ -162,6 +164,7 @@ export const askJev = (options: AskJevOptions): Effect.Effect