The Open Framework for Building Agents
fix(eve): agent info - restrict provider options (#3810)
Andrew Barba0cd423996906
diff --git a/.changeset/safe-agent-info-provider-options.md b/.changeset/safe-agent-info-provider-options.mdnew file mode 100644index 000000000..91bbe2603--- /dev/null+++ b/.changeset/safe-agent-info-provider-options.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Limit `/eve/v1/info` model provider options to the priority tier indicator. Other provider options no longer appear in the inspection response, so credentials stored under unexpected keys cannot be exposed there.diff --git a/packages/eve/src/internal/nitro/routes/agent-info/build-agent-info-response.test.ts b/packages/eve/src/internal/nitro/routes/agent-info/build-agent-info-response.test.tsindex 25cbb028d..fae19d46c 100644--- a/packages/eve/src/internal/nitro/routes/agent-info/build-agent-info-response.test.ts+++ b/packages/eve/src/internal/nitro/routes/agent-info/build-agent-info-response.test.ts@@ -155,7 +155,7 @@ describe("buildAgentInfoResponse", () => {);});- it("never serializes BYOK or credential-shaped providerOptions values", async () => {+ it("only exposes the priority tier from providerOptions", async () => {const { manifest } = await compileFromMemory({model: "openai/gpt-5.4",name: "info-agent",@@ -173,6 +173,7 @@ describe("buildAgentInfoResponse", () => {apiKey: "sk-canary-direct",headers: { authorization: "Bearer canary-header" },reasoningEffort: "high",+ metadata: { workspace: "sk-canary-unrecognized" },},};@@ -188,14 +189,21 @@ describe("buildAgentInfoResponse", () => {expect(serialized).not.toContain("sk-canary-byok");expect(serialized).not.toContain("sk-canary-direct");expect(serialized).not.toContain("canary-header");+ expect(serialized).not.toContain("sk-canary-unrecognized");// Non-secret options survive for the dev TUI (`gateway.serviceTier`).expect(response.agent.model.providerOptions).toEqual({gateway: { serviceTier: "priority" },- openai: {- apiKey: "[redacted]",- headers: "[redacted]",- reasoningEffort: "high",- },});++ model.providerOptions = { gateway: { serviceTier: "sk-canary-tier" } };+ const customTierResponse = buildAgentInfoResponse(+ { manifest, schedules: [] },+ {+ gatewayCredentials: { apiKey: false, oidc: false },+ mode: "production",+ },+ );+ expect(customTierResponse.agent.model.providerOptions).toBeUndefined();+ expect(JSON.stringify(customTierResponse)).not.toContain("sk-canary-tier");});});diff --git a/packages/eve/src/internal/nitro/routes/agent-info/build-agent-info-response.ts b/packages/eve/src/internal/nitro/routes/agent-info/build-agent-info-response.tsindex 142a7038a..2cff1a261 100644--- a/packages/eve/src/internal/nitro/routes/agent-info/build-agent-info-response.ts+++ b/packages/eve/src/internal/nitro/routes/agent-info/build-agent-info-response.ts@@ -15,7 +15,7 @@ import {resolveModelEndpointStatus,} from "#internal/resolve-model-endpoint-status.js";import type { ChatGptAuthState } from "#public/models/openai/chatgpt/token-broker.js";-import type { JsonObject, JsonValue } from "#shared/json.js";+import type { JsonObject } from "#shared/json.js";export type AgentInfoResponse = AgentInfoResult;@@ -61,9 +61,7 @@ export function buildAgentInfoResponse(toChatGptEndpoint(input.chatgptAuth),),id: manifest.config.model.id,- providerOptions: sanitizeProviderOptionsForInfo(- manifest.config.model.providerOptions,- ),+ providerOptions: projectProviderOptionsForInfo(manifest.config.model.providerOptions),reasoning: manifest.config.reasoning,routing: manifest.config.model.routing,source:@@ -210,62 +208,12 @@ export function buildAgentInfoResponse(};}-/**- * `providerOptions` can carry deployment-owner credentials: the shipped BYOK- * scaffold places the provider `apiKey` under `gateway.byok`, and custom- * providers may accept credential-bearing fields such as `headers`. The info- * route is served to every caller the application's channel auth admits, so- * the inspection payload must never serialize credential material. Drop the- * BYOK block (its provider slug is already reported via `routing.byok`) and- * redact credential-shaped keys recursively, while keeping non-secret options- * such as `gateway.serviceTier` that the dev TUI reads.- */-const CREDENTIAL_OPTION_KEY =- /^(api[-_]?key|access[-_]?token|auth|authorization|bearer|client[-_]?secret|credentials?|headers|password|private[-_]?key|secret|token)$/i;--const REDACTED_CREDENTIAL = "[redacted]";--function sanitizeProviderOptionsForInfo(+/** Only the literal priority tier is needed by the dev TUI; other options may contain secrets. */+function projectProviderOptionsForInfo(providerOptions: Record<string, JsonObject> | undefined,): Record<string, JsonObject> | undefined {- if (providerOptions === undefined) return undefined;- const sanitized: Record<string, JsonObject> = {};- for (const [provider, options] of Object.entries(providerOptions)) {- sanitized[provider] = redactCredentialOptions(options);- }- return sanitized;-}--function redactCredentialOptions(value: JsonValue): JsonObject {- if (value === null || typeof value !== "object" || Array.isArray(value)) {- return {};- }- const redacted: Record<string, JsonValue> = {};- for (const [key, entry] of Object.entries(value)) {- if (key === "byok") {- // BYOK entries are `{ apiKey }` credential objects; the provider slug is- // already exposed through `routing.byok`.- continue;- }- if (CREDENTIAL_OPTION_KEY.test(key)) {- redacted[key] = REDACTED_CREDENTIAL;- continue;- }- if (entry !== null && typeof entry === "object") {- if (Array.isArray(entry)) {- redacted[key] = entry.map((item) =>- item !== null && typeof item === "object" && !Array.isArray(item)- ? redactCredentialOptions(item)- : item,- );- } else {- redacted[key] = redactCredentialOptions(entry);- }- continue;- }- redacted[key] = entry;- }- return redacted;+ if (providerOptions?.gateway?.serviceTier !== "priority") return undefined;+ return { gateway: { serviceTier: "priority" } };}function toModuleSource(