From 1a8a62cb109c8e8cbb46eb740f5629f49183633f Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 31 Oct 2026 01:25:38 +0000 Subject: [PATCH] fix: pre-landing review fixes 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 ++ bin/gstack-model-benchmark | 6 +++++- test/benchmark-cli.test.ts | 7 +++++++ test/gateway-provider.test.ts | 13 ++++++++++++- test/helpers/model-panel-harness.ts | 5 +++-- test/helpers/periodic-exclude-data.ts | 4 ++++ test/helpers/providers/gateway.ts | 11 +++++++---- 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/benchmark-models/SKILL.md b/benchmark-models/SKILL.md index b8435d7eaa..0ff3045ed5 100644 --- a/benchmark-models/SKILL.md +++ b/benchmark-models/SKILL.md @@ -203,6 +203,8 @@ 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. + 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." - **RECOMMENDATION:** A (all authed providers) because running as many as possible gives the richest comparison. diff --git a/benchmark-models/SKILL.md.tmpl b/benchmark-models/SKILL.md.tmpl index 9cfda39349..92e9e34954 100644 --- a/benchmark-models/SKILL.md.tmpl +++ b/benchmark-models/SKILL.md.tmpl @@ -79,6 +79,8 @@ 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. + 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." - **RECOMMENDATION:** A (all authed providers) because running as many as possible gives the richest comparison. diff --git a/bin/gstack-model-benchmark b/bin/gstack-model-benchmark index 2f849b0d6a..dfcb226937 100755 --- a/bin/gstack-model-benchmark +++ b/bin/gstack-model-benchmark @@ -78,7 +78,11 @@ function parseProviders(s: string | undefined): ProviderName[] { console.error(`WARN: unknown provider '${p}' — skipping. Valid: ${PROVIDER_NAMES.join(', ')}.`); } } - return seen.size ? Array.from(seen) : ['claude']; + if (!seen.size) { + console.error(`No valid provider in --models '${s}'. Valid: ${PROVIDER_NAMES.join(', ')}.`); + process.exit(1); + } + return Array.from(seen); } function parsePositiveIntegerFlag(name: string, def: string): number { diff --git a/test/benchmark-cli.test.ts b/test/benchmark-cli.test.ts index ca50b2062a..d6e92e0ea8 100644 --- a/test/benchmark-cli.test.ts +++ b/test/benchmark-cli.test.ts @@ -61,6 +61,13 @@ describe('gstack-model-benchmark --dry-run', () => { expect(r.stdout).not.toContain('gpt-42-fake'); }); + test('a --models list with no valid provider is an error, never a claude run', () => { + const r = run(['--prompt', 'hi', '--models', 'Particle', '--dry-run']); + expect(r.status).toBe(1); + expect(r.stderr).toContain("No valid provider in --models 'Particle'"); + expect(r.stdout).not.toContain('providers: claude'); + }); + test('empty --models list falls back to claude default', () => { const r = run(['--prompt', 'hi', '--models', '', '--dry-run']); expect(r.status).toBe(0); diff --git a/test/gateway-provider.test.ts b/test/gateway-provider.test.ts index 2b813e3dfa..76ae01f6ff 100644 --- a/test/gateway-provider.test.ts +++ b/test/gateway-provider.test.ts @@ -4,6 +4,7 @@ import * as os from 'os'; import * as path from 'path'; import { GatewayAdapter, GATEWAY_MODELS, gatewayEnvironment, foreignModels } from './helpers/providers/gateway'; import { PROVIDER_NAMES, isProviderName } from './helpers/providers/registry'; +import { PANEL_ARMS, cellCostUsd } from './helpers/model-panel-harness'; import { familyConflict, modelFamily } from '../lib/outside-voice-runner'; import { estimateCostUsd, hasPricing } from '../lib/pricing'; @@ -23,6 +24,7 @@ function fakeClaude(): string { fs.writeFileSync(script, [ "const fs = require('fs');", "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 || '') + '}');", "process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', is_error: false, result: 'ok', num_turns: 2, usage: { input_tokens: 1000, output_tokens: 10, cache_read_input_tokens: 50, cache_creation_input_tokens: 7 }, modelUsage }));", ].join('\n') + '\n'); @@ -56,7 +58,9 @@ describe('gateway provider', () => { const childEnv = fs.readFileSync(envOut, 'utf-8'); expect(childEnv).not.toContain('sk-ant-real'); expect(childEnv).toContain('ANTHROPIC_AUTH_TOKEN=sk-or'); - expect(adapter.estimateCost(result.tokens, result.modelUsed)).toBe(+((1000 * 0.25 + 10 * 1.0 + 50 * 0.03) / 1e6).toFixed(6)); + expect(adapter.estimateCost(result.tokens, result.modelUsed)).toBeCloseTo((1000 * 0.25 + 10 * 1.0 + 50 * 0.03 + 7 * 0.25) / 1e6, 5); + const particleArm = PANEL_ARMS.find(a => a.id === 'particle')!; + expect(adapter.estimateCost(result.tokens, result.modelUsed)).toBe(cellCostUsd(particleArm, { input: 1000, output: 10, cached: 50, cacheWrite: 7, modelsBilled: [], isError: false, apiErrorStatus: null, turns: 2 })); }); test('a run that billed another model is a MODEL_MIX error, not a result', async () => { @@ -67,6 +71,13 @@ describe('gateway provider', () => { expect(foreignModels('particle-ai/particle-1', ['particle-1', 'PARTICLE-AI/particle-1'])).toEqual([]); }); + 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' }); + const result = await adapter.run({ prompt: 'hi', workdir: tmp, timeoutMs: 10_000 }); + expect(result.error?.reason).toMatch(/empty or invalid output/); + }); + test('available() names the missing key with a fix', async () => { process.env.GSTACK_CLAUDE_BIN = fakeClaude(); const check = await new GatewayAdapter('particle', { PATH: process.env.PATH }).available(); diff --git a/test/helpers/model-panel-harness.ts b/test/helpers/model-panel-harness.ts index da2b340ea9..4516d65ae3 100644 --- a/test/helpers/model-panel-harness.ts +++ b/test/helpers/model-panel-harness.ts @@ -185,8 +185,9 @@ export type CellVerdict = 'pass' | 'fail' | 'infra'; * INFRA cells are excluded from pass rates, reported, and never rerun to * change a verdict: no result event, a CLI or API error before the model * produced a turn, a 402/429/5xx from the API, a startup timeout, or a run - * that billed any model besides the arm's (MODEL_MIX). Everything else is - * scored by the hidden check, including a run that timed out after working. + * that billed any model besides the arm's (MODEL_MIX). A CLI killed at the + * timeout writes no result event, so it is INFRA too. Everything else is + * scored by the hidden check. */ export function classifyCell(arm: PanelArm, exitReason: string, usage: CellUsage | null): { verdict: 'infra'; reason: string } | { verdict: 'scored' } { if (exitReason === 'timeout_startup') return { verdict: 'infra', reason: 'startup timeout' }; diff --git a/test/helpers/periodic-exclude-data.ts b/test/helpers/periodic-exclude-data.ts index 14cb3fdb39..98b637b84c 100644 --- a/test/helpers/periodic-exclude-data.ts +++ b/test/helpers/periodic-exclude-data.ts @@ -19,6 +19,10 @@ export const PERIODIC_CI_EXCLUDE: Record