Repository navigation
feat: record token usage and duration for eval runs - #270
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Dispatching a sample run of one eval per benchmark experiment to demo what the data and UI looks like. |
|
Realizing that the current shape deviates slightly from OTel GenAI conventions, gonna align more closely to that. Same data ultimtately just different derivation. (Edit: pushed that change and kicking off new run) |
There was a problem hiding this comment.
Approved - token/duration usage wiring is solid across all four harnesses (inclusive OTel-style buckets, real fixture-tested math).
Small nits: ai-sdk lacks an usage-extraction test the other three have, and the shipped inclusive inputTokens naming diverges from the plan doc's disjoint design without a reconciliation note. IIRC, we're not running any ai-sdk experiment anymore but for consistency sake, should we also add a test for this to the ai-sdk?
|
Thanks @Rodriguespn , I've added the AI SDK usage extraction test in ebff956. And yes, the |
) (#241) This is stacked on #240. Review that first; this diff is against it. No results are touched. ## Problem We wrote our own system prompt into every eval run, for all four agents: > You are an agent solving a Supabase eval task in a Linux workspace. Use the provided tools to inspect and modify the workspace and run commands. When you are done, end your turn with a short summary of what you did. - Claude Code, Codex and OpenCode ship their own system prompt. Ours was layered on top, and Codex and OpenCode have no system-prompt flag, so for them it went onto the user prompt. - It described `bash` and `files_read`, which only the in-process `ai-sdk` agent has. - "End your turn with a short summary" shapes `agentReport`, which the LLM judge reads. That is a scoring change. - It says Supabase, and "project". An agent that would otherwise pick a database has been handed the answer (#164). ## Changes | Agent | Before | After | |---|---|---| | `ai-sdk` | framing + tool list + skills list | one neutral line + tool list + skills list | | `claude-code` | ours appended to its own | nothing | | `codex` | ours prepended to the user prompt | nothing | | `opencode` | ours prepended to the user prompt | nothing | - CLI agents take no system prompt at all. `createCliAgent` no longer stages a system-prompt file or passes a path to the runner; `--append-system-prompt-file` and the Codex/OpenCode prepend are gone. A non-empty `systemPrompt` for a CLI agent throws. - The `ai-sdk` base prompt is now `You are an agent. Use the provided tools to complete the task.` It is the same in both modes. No Supabase, no project, no stopping instructions. - `buildToolSurfaceAddendum` and `buildSkillsPrompt` return `''` for every CLI agent. The bare sandbox no longer takes an `agent` or returns a `promptAddendum`. - Prompt assembly moves out of `run-eval.ts` into `system-prompt.ts` so it can be unit tested. - `run-eval.ts` only starts a run when it is the entry point. It used to call `main()` on import, which the harness unit tests now trigger. - Each run records `systemPrompt` in its raw `result.json`. `export-results` drops it, so nothing reaches the site. Since the first review: the system-prompt-file plumbing for CLI agents is deleted rather than made optional, and the ai-sdk base prompt is rewritten for #164. The branch is re-applied on the current #240 (the retry loop is gone there), so the commits are new. #240 now has `main` merged in, which brings the usage and duration fields from #270. ## Testing - `pnpm --filter @supabase-evals/core test`, `pnpm --filter @supabase-evals/sandbox test`, `pnpm --filter @supabase-evals/framework test`, `pnpm --filter @supabase-evals/web test`: all pass locally. - `typecheck` for framework, sandbox and web passes. `biome check .` is clean. - Unverified against real CLIs since the deletion. The earlier sandbox runs (Claude Code [32785480269](https://github.com/supabase/evals/actions/runs/32785480269), Codex [32880822811](https://github.com/supabase/evals/actions/runs/32880822811), OpenCode [32880839623](https://github.com/supabase/evals/actions/runs/32880839623)) recorded an empty prompt and still loaded the Supabase skills, and the path they exercised (no flag, task alone) is the one that remains. ## Score movement Full benchmark on both branches before this revision, artifact only, nothing published. Both used `runs=2`. | | #240, no prompt change | #241, prompt removed | | |---|---|---|---| | all pairs | 86.0% | 84.7% | 21 flips, 12 down 9 up | | `claude-code` | 92.3% | 92.3% | no change | | `codex` | 81.5% | 75.0% | down 6.5 points | | `opencode` | 82.6% | 89.1% | up 6.5 points | This looks like run-to-run variability. Once #229 lands and scores average across runs, the numbers should settle. ## Follow-ups - Re-run the benchmark comparison once #229 lands and the numbers can carry attribution. - Drop the "end your turn with a short summary" line from `evals/resolve-performance-001-slow-query-cpu-spike/PROMPT.md:15`, the last one left. It sits in the task text so it hits every agent equally, and removing it invalidates that eval's recorded results, so it should be a separate change. Ref AI-1034 --------- Co-authored-by: Matt Rossman <[email protected]>
Records
usageanddurationMson each result so we can see what a run costs in tokens and how long the agent took. Usage tracks input, cache read, cache write, and output tokens, inspired by OTel GenAI conventions where the cache buckets are subsets of input. All four harnesses report these fields, and from them we can price a run (the two cache buckets each have their own rate, and input minus both is the fresh input billed at the base rate), see OpenAI or Claude pricing.Usage is a list because runs can potentially use multiple models, e.g. by default Claude Code incurs a small amount of Haiku usage for title renames (thread), but we could also see runs that spawn subagents.
The UI details for a run now shows duration and a one-line token total (Preview deep link)
Sanity checked every bucket against raw CLI output for all three sandbox harnesses plus direct OpenAI API calls, and ran one eval per harness end to end. After merge, we can let performance metrics trickle in from nightly regression runs, and optionally trigger a full benchmark refresh when it's convenient.
Closes AI-971