From 056e67b7366f52f7dfcc04d17afbe25c8d7d87b6 Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 31 Oct 2026 01:43:27 +0000 Subject: [PATCH] fix: gateway benchmark runs load no Claude Code settings A settings.json env block's ANTHROPIC_API_KEY was sent to the OpenRouter base URL as x-api-key; --setting-sources '' loads no settings source. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- benchmark-models/SKILL.md | 2 +- benchmark-models/SKILL.md.tmpl | 2 +- test/gateway-provider.test.ts | 11 +++++++++++ test/helpers/providers/gateway.ts | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/benchmark-models/SKILL.md b/benchmark-models/SKILL.md index 0ff3045ed5..0f34447186 100644 --- a/benchmark-models/SKILL.md +++ b/benchmark-models/SKILL.md @@ -203,7 +203,7 @@ Show the dry-run output. The "Adapter availability" section tells the user which If every provider shows NOT READY: stop with a clear message — benchmark can't run without at least one authed provider. Suggest `claude login`, `codex login`, `gemini login` / `export GOOGLE_API_KEY`, or `export OPENROUTER_API_KEY` for particle and deepseek (they run in Claude Code, so they also need the `claude` CLI). -particle and deepseek send the prompt, the working directory's files the model reads, and the user's Claude Code context (CLAUDE.md, MCP servers, settings) to OpenRouter and the model vendor, and run with the user's environment minus Anthropic credentials. Say so before including them. +particle and deepseek send the prompt and the working directory's files the model reads to OpenRouter and the model vendor. They load no Claude Code settings files (so a key in a settings.json `env` block is never sent) and run with the user's environment minus Anthropic credentials. Say so before including them. If at least one is OK: AskUserQuestion: - **Simplify:** "Which models should we include? The dry-run above showed which are authed. Unauthed ones will be skipped cleanly — they won't abort the batch." diff --git a/benchmark-models/SKILL.md.tmpl b/benchmark-models/SKILL.md.tmpl index 92e9e34954..dbc447bb5a 100644 --- a/benchmark-models/SKILL.md.tmpl +++ b/benchmark-models/SKILL.md.tmpl @@ -79,7 +79,7 @@ Show the dry-run output. The "Adapter availability" section tells the user which If every provider shows NOT READY: stop with a clear message — benchmark can't run without at least one authed provider. Suggest `claude login`, `codex login`, `gemini login` / `export GOOGLE_API_KEY`, or `export OPENROUTER_API_KEY` for particle and deepseek (they run in Claude Code, so they also need the `claude` CLI). -particle and deepseek send the prompt, the working directory's files the model reads, and the user's Claude Code context (CLAUDE.md, MCP servers, settings) to OpenRouter and the model vendor, and run with the user's environment minus Anthropic credentials. Say so before including them. +particle and deepseek send the prompt and the working directory's files the model reads to OpenRouter and the model vendor. They load no Claude Code settings files (so a key in a settings.json `env` block is never sent) and run with the user's environment minus Anthropic credentials. Say so before including them. If at least one is OK: AskUserQuestion: - **Simplify:** "Which models should we include? The dry-run above showed which are authed. Unauthed ones will be skipped cleanly — they won't abort the batch." diff --git a/test/gateway-provider.test.ts b/test/gateway-provider.test.ts index 76ae01f6ff..cd5c6f9af9 100644 --- a/test/gateway-provider.test.ts +++ b/test/gateway-provider.test.ts @@ -23,6 +23,7 @@ function fakeClaude(): string { const script = path.join(tmp, 'fake-claude.js'); fs.writeFileSync(script, [ "const fs = require('fs');", + "if (process.env.FAKE_ARGS_OUT) fs.writeFileSync(process.env.FAKE_ARGS_OUT, JSON.stringify(process.argv.slice(2)));", "fs.writeFileSync(process.env.FAKE_ENV_OUT, Object.entries(process.env).map(([k, v]) => k + '=' + v).join('\\n') + '\\n');", "if (process.env.FAKE_ERROR) { process.stdout.write(JSON.stringify({ type: 'result', subtype: 'error_during_execution', is_error: true, result: '' })); process.exit(0); }", "const modelUsage = JSON.parse('{' + (process.env.FAKE_MODELS || '') + '}');", @@ -71,6 +72,16 @@ describe('gateway provider', () => { expect(foreignModels('particle-ai/particle-1', ['particle-1', 'PARTICLE-AI/particle-1'])).toEqual([]); }); + test('gateway runs load no Claude Code settings, so a settings.json key never reaches the gateway', async () => { + process.env.GSTACK_CLAUDE_BIN = fakeClaude(); + const argsOut = path.join(tmp, 'args.json'); + await new GatewayAdapter('particle', { PATH: process.env.PATH, HOME: tmp, OPENROUTER_API_KEY: 'sk-or', FAKE_ENV_OUT: path.join(tmp, 'env-args.txt'), FAKE_ARGS_OUT: argsOut, FAKE_MODELS: '"particle-ai/particle-1":{}' }).run({ prompt: 'hi', workdir: tmp, timeoutMs: 10_000 }); + const argv: string[] = JSON.parse(fs.readFileSync(argsOut, 'utf-8')); + const at = argv.indexOf('--setting-sources'); + expect(at).toBeGreaterThan(-1); + expect(argv[at + 1]).toBe(''); + }); + test('an error envelope from the gateway is an error, not a benchmark result', async () => { process.env.GSTACK_CLAUDE_BIN = fakeClaude(); const adapter = new GatewayAdapter('particle', { PATH: process.env.PATH, HOME: tmp, OPENROUTER_API_KEY: 'sk-or', FAKE_ENV_OUT: path.join(tmp, 'env-err.txt'), FAKE_ERROR: '1' }); diff --git a/test/helpers/providers/gateway.ts b/test/helpers/providers/gateway.ts index abc8e27e9a..47e4a9146d 100644 --- a/test/helpers/providers/gateway.ts +++ b/test/helpers/providers/gateway.ts @@ -85,7 +85,7 @@ export class GatewayAdapter implements ProviderAdapter { if (opts.csoProducer) { return { output: '', tokens: { input: 0, output: 0 }, durationMs: 0, toolCalls: 0, modelUsed: this.model, error: { code: 'unknown', reason: 'gateway providers do not run CSO producers' } }; } - const result = await this.harness.run({ ...opts, model: this.model }); + const result = await this.harness.run({ ...opts, model: this.model, extraArgs: [...(opts.extraArgs ?? []), '--setting-sources', ''] }); const foreign = foreignModels(this.model, result.modelsBilled); if (!result.error && foreign.length) { return { ...result, error: { code: 'unknown', reason: `MODEL_MIX: the run also billed ${foreign.join(', ')}` } };