From 1556b74082e0baee3a347396590ee3614db74696 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 09:57:47 -0500 Subject: [PATCH] fix(core): preserve Vertex billing labels (#43449) Co-authored-by: rekram1-node --- packages/core/src/aisdk-native.ts | 8 ++++++-- packages/core/test/aisdk-native.test.ts | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/core/src/aisdk-native.ts b/packages/core/src/aisdk-native.ts index 859b40661fb..b2d040b4c06 100644 --- a/packages/core/src/aisdk-native.ts +++ b/packages/core/src/aisdk-native.ts @@ -60,7 +60,10 @@ export function map(input: MapInput): Mapping | undefined { ...mapAPIKey(input.settings), ...(typeof input.settings.location === "string" ? { location: input.settings.location } : {}), ...(typeof input.settings.project === "string" ? { project: input.settings.project } : {}), - ...mapGoogleOptions(input.settings), + ...mapGoogleOptions( + input.settings, + isStringRecord(input.settings.labels) ? { labels: input.settings.labels } : {}, + ), }, ...(isStringRecord(input.settings.headers) ? { headers: input.settings.headers } : {}), } @@ -242,7 +245,7 @@ function mapAPIKey(settings: Readonly>) { return typeof settings.apiKey === "string" ? { apiKey: settings.apiKey } : {} } -function mapGoogleOptions(settings: Readonly>) { +function mapGoogleOptions(settings: Readonly>, extra: Readonly> = {}) { const input = settings.thinkingConfig const thinkingConfig = { ...(isRecord(input) && typeof input.thinkingBudget === "number" ? { thinkingBudget: input.thinkingBudget } : {}), @@ -256,6 +259,7 @@ function mapGoogleOptions(settings: Readonly>) { ...(Array.isArray(settings.safetySettings) ? { safetySettings: settings.safetySettings } : {}), ...(typeof settings.serviceTier === "string" ? { serviceTier: settings.serviceTier } : {}), ...(Object.keys(thinkingConfig).length > 0 ? { thinkingConfig } : {}), + ...extra, } if (Object.keys(options).length === 0) return {} return { providerOptions: { gemini: options } } diff --git a/packages/core/test/aisdk-native.test.ts b/packages/core/test/aisdk-native.test.ts index 0fd2ccf6cd2..3dc475924d0 100644 --- a/packages/core/test/aisdk-native.test.ts +++ b/packages/core/test/aisdk-native.test.ts @@ -279,6 +279,7 @@ describe("AISDKNative", () => { accessToken: "vertex-token", baseURL: "https://vertex.example/v1", headers: { "x-test": "value" }, + labels: { component: "opencode", environment: "test" }, location: "eu", project: "vertex-project", thinkingConfig: { thinkingLevel: "high" }, @@ -290,7 +291,12 @@ describe("AISDKNative", () => { baseURL: "https://vertex.example/v1", location: "eu", project: "vertex-project", - providerOptions: { gemini: { thinkingConfig: { thinkingLevel: "high" } } }, + providerOptions: { + gemini: { + labels: { component: "opencode", environment: "test" }, + thinkingConfig: { thinkingLevel: "high" }, + }, + }, }, headers: { "x-test": "value" }, })