[Bug] The agent-eval harness runs against the user's real config: it rewrites their saved default model and runs their global hooks
Description
benchmarks/agent/harness.ts starts the CLI for each run with your full environment and no config override (harness.ts:387). Every run saves the provider and model it used to your preferences, so benchmarking changes the default model you use in the app. Your global agents.config.json (hooks, system prompt, MCP servers, formatters) is also active during the measured runs, so results depend on whoever runs them.
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 9d88dda7)
- Provider: Ollama
- Model: qwen2.5:1.5b
Steps to Reproduce
- Use a config dir whose
nanocoder-preferences.jsonhas"lastProvider":"MyOtherProvider","lastModel":"my-favourite-model", and whoseagents.config.jsonhas asession-starthook that writes a marker file. - Run
npx tsx benchmarks/agent/run.ts --fixture single-file-edit --runs 1 --provider Ollama --model qwen2.5:1.5bwithNANOCODER_CONFIG_DIRpointing at that dir. - Read the preferences file and look for the marker file.
Expected Behavior
The benchmark uses its own temporary config (only the provider block) and leaves the user's files untouched.
Actual Behavior
BEFORE: {"lastProvider":"MyOtherProvider","lastModel":"my-favourite-model", ...}
AFTER: {"lastProvider":"Ollama","lastModel":"qwen2.5:1.5b",
"providerModels":{"MyOtherProvider":"my-favourite-model","Ollama":"qwen2.5:1.5b"}, ...}
global hook marker file: my-personal-global-hook-ran
Suggested Fix
- In
runOnce(harness.ts, theexecFileAsync('node', args, {... env ...})call near line 387), setNANOCODER_CONFIG_DIRto a fresh temporary folder per run, copy only the provider block into it, and delete it in the existingfinally. Print a note inbenchmarks/agent/README.md. - Optional:
harness.ts:443stores a missing usage value as0(usage.totalTokens ?? 0);nullwould stop medians from reading as free runs. I could not trigger this now that #1671 is merged. - Add a test with a fake CLI that records the env it receives.
Additional Context
- Harness: #1544 (merged). Open request: #1197.
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder
I confirmed that runOnce currently passes the parent process environment to the CLI without isolating its config directory. I would like to take #1744: I will give each run a fresh config directory, carry over only the provider configuration needed for the selected run, and add an offline stub-CLI regression proving user preferences and hooks are not exposed or changed. I will keep validation local and will not run live model calls.
Thanks for the PR @ducanhnguyen223!
For future contributions, please comment on the issue first and wait to be assigned before opening a PR. This avoids duplicate work. Also include "Closes #