From 592f6fc66bb886c6cfc2157cf962ea94a3a6a794 Mon Sep 17 00:00:00 2001 From: Luis Pater Date: Wed, 12 Nov 2025 08:43:02 +0800 Subject: [PATCH] feat(vertex): add usage source resolution for Vertex projects Extend `resolveUsageSource` to support Vertex projects by extracting and normalizing `project_id` or `project` from the metadata for accurate source resolution. --- internal/runtime/executor/usage_helpers.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/runtime/executor/usage_helpers.go b/internal/runtime/executor/usage_helpers.go index 1f81c048..e0df5f3e 100644 --- a/internal/runtime/executor/usage_helpers.go +++ b/internal/runtime/executor/usage_helpers.go @@ -129,6 +129,21 @@ func apiKeyFromContext(ctx context.Context) string { func resolveUsageSource(auth *cliproxyauth.Auth, ctxAPIKey string) string { if auth != nil { + provider := strings.TrimSpace(auth.Provider) + if strings.EqualFold(provider, "vertex") { + if auth.Metadata != nil { + if projectID, ok := auth.Metadata["project_id"].(string); ok { + if trimmed := strings.TrimSpace(projectID); trimmed != "" { + return trimmed + } + } + if project, ok := auth.Metadata["project"].(string); ok { + if trimmed := strings.TrimSpace(project); trimmed != "" { + return trimmed + } + } + } + } if _, value := auth.AccountInfo(); value != "" { return strings.TrimSpace(value) }