Build a lightweight model benchmarking harness that tests multiple LLM models across megaplan phases to find the best model for each role.
Goal: Run 3 representative evals (simple, medium, hard) through each of ~10 models, scoring each model on each phase independently, to produce a matrix of model×phase scores.
What to build:
A benchmark runner (evals/benchmark.py) that:
Takes a list of models and a list of eval names
For each model, runs it through each phase type independently (not full pipeline):
a. PLAN test: Give the model a plan prompt for each eval. Score: did it return valid JSON with required keys? Did it use web search? Quality of plan (has success criteria, assumptions, concrete steps)?
b. CRITIQUE test: Give it a plan to critique. Score: valid JSON? Found real issues vs zero flags?
c. EXECUTE test: Give it a finalized task list. Score: did it use write_file/patch to modify code? Did the build pass? Did it produce valid task_updates JSON?
d. REVIEW test: Give it execution evidence. Score: valid JSON with verdict and task_verdicts?
Each test is independent (not a full pipeline) — we're measuring per-phase capability
Tests run in parallel across models (concurrent subprocess calls)
Results stored as a matrix: model × phase × eval → score
Scoring dimensions per phase:
json_valid: 0/1 — did the response parse as valid JSON matching the schema?
json_in_content: 0/1 — was the JSON in the content field (not reasoning/think tags)?
required_keys: 0/1 — does it have all required keys?
tool_use: 0/1 — did it use appropriate tools (file read for plan/critique, file write for execute)?
web_search: 0/1 — did it use web_search (bonus for plan/critique)?
build_pass: 0/1 — execute only: does npm run build succeed?
eval_pass: 0/1 — execute only: do EVAL.ts assertions pass?
Models to test (all via OpenRouter):
minimax/minimax-m2.7
z-ai/glm-5
anthropic/claude-sonnet-4.6
openai/gpt-4.1-mini
google/gemini-2.5-flash
meta-llama/llama-4-maverick
deepseek/deepseek-chat-v3-0324
qwen/qwen3-235b-a22b
mistralai/mistral-medium-3
cohere/command-a
Evals to use:
Assistant
Simple: agent-025-prefer-next-link (add 3 Link components)
Medium: agent-022-prefer-server-actions (convert to server action pattern)
Run all models concurrently (each in its own subprocess)
Each model runs sequentially through the 3 evals × 4 phases = 12 tests
Total: ~120 model-phase tests, but only 10 concurrent at a time
The harness should reuse the existing hermes worker infrastructure but bypass the full megaplan pipeline — it calls the hermes worker directly for each phase test with pre-prepared prompts and scores the result.
code
Plan:
# Implementation Plan: Model Benchmarking Harness
Overview
The hermes-agent repo has a mature eval pipeline in evals/ that orchestrates megaplan phases (plan → critique → gate → finalize → execute → review) via subprocess calls to the megaplan binary. Each phase runs a Hermes worker session with a specific model, producing JSON artifacts in .megaplan/plans/<name>/.
The benchmark harness needs to test each model on each phase independently — not a full pipeline run. This means: for each (model, eval, phase) triple, we init a megaplan workspace, run just that one phase, and score the output. The existing run_megaplan_loop() handles the full pipeline; we'll reuse _megaplan_command(), _megaplan_env(), config_phase_model_args(), prepare_workspace(), and check_build() but bypass the loop.
Key constraint: The megaplan binary requires init before any phase can run, and later phases (critique, execute, review) require artifacts from earlier phases. We can't truly run phases in isolation without providing their input artifacts. The plan below addresses this with canned fixtures — pre-generated artifacts from a reference model run.
@dataclass
class PhaseScore:
json_valid: int # 0/1 — response parses as JSON
json_in_content: int # 0/1 — JSON in content, not reasoning
required_keys: int # 0/1 — all required keys present
tool_use: int # 0/1 — used appropriate tools
web_search: int # 0/1 — used web_search (bonus)
build_pass: int | None # 0/1 or None — execute only
eval_pass: int | None # 0/1 or None — execute only
phase: str
model: str
eval_name: str
duration_seconds: float
cost_usd: float
error: str | None
Implement phase-specific validators:
score_plan(response, trace) → PhaseScore — checks for success_criteria, assumptions, plan markdown, file_read tool usage
score_critique(response, trace) → PhaseScore — checks for open_flags list, severity on each flag, file_read tool usage
score_execute(response, trace, workspace) → PhaseScore — checks for file_write/edit tool calls, runs check_build() and run_eval_ts()
score_review(response, trace) → PhaseScore — checks for review_verdict/verdict, task_verdicts list
Required keys per phase (derived from _read_phase_artifact at evals/run_evals.py:1053-1105 and _phase_summary at :48-76):
plan: success, state + plan markdown file exists
critique: open_flags, success, next_step
execute: success, state (+ tool calls for file modifications)
Prepare a workspace via prepare_workspace() (reuse from evals/run_evals.py:242)
Run megaplan init with the model assigned to the target phase
Inject fixture artifacts for prerequisite phases (copy plan files for critique, finalize.json for execute, etc.)
Run megaplan <phase> via _run_megaplan_json() pattern (subprocess with JSON parsing)
Collect trace via collect_phase_trace() from evals/audit.py:188
Score the result using the appropriate score_* function from Step 2
Clean up workspace
Key detail — fixture injection: Before running a later phase, copy the reference fixtures into .megaplan/plans/<plan_name>/ so megaplan finds them. For execute, also apply the reference diff to set up the workspace state. This is the trickiest part — we need to ensure megaplan's state.json reflects the expected phase progression.
"version": 1,
"timestamp": "2026-03-26T18:57:57Z",
"hash": "sha256:ea43d73b02088e08ad1e41b8b43f086f9df4705315bdc6ba8a6f12f0ef1ac39d",
"questions": [
"Fixture generation: Should I run a full pipeline with Claude Opus now to generate the reference fixtures, or do you already have completed eval runs (in results/) I can harvest artifacts from? This is the critical-path dependency.",
"Phase scope: The spec mentions 4 phases (plan, critique, execute, review). Should we also test revise, gate, and finalize? These are simpler phases but still part of the pipeline. Excluding them keeps the matrix smaller (120 vs 210 tests).",
"Execute phase realism: For the execute phase, models need a real workspace with npm dependencies installed. Each execute test requires ~60s for workspace prep (npm install) + the model's execution time + build/eval scoring. With 10 models \u00d7 3 evals = 30 execute tests, that's potentially hours. Should we start with plan+critique only (cheap, fast) and add execute+review later?",
"Megaplan binary availability: The benchmark calls the megaplan binary via subprocess. Is it installed and on PATH, or do we need a specific path/setup? The existing config uses megaplan_bin: 'megaplan'.",
"Cost budget: Running 10 models \u00d7 3 evals \u00d7 4 phases through OpenRouter will have non-trivial API costs (especially execute phases with tool calling loops). Is there a cost ceiling? Should we add cost tracking and abort if cumulative spend exceeds a threshold?"
],
"success_criteria": [
"Running python -m evals.benchmark --dry-run validates config, checks fixtures exist, and prints the test matrix without calling any APIs.",
"Running a single-cell test (--model openai/gpt-4.1-mini --eval agent-025-prefer-next-link --phase plan) produces a PhaseScore with all dimensions filled.",
"The full benchmark produces a JSON results file at evals/benchmark/results/<timestamp>/results.json with the complete model \u00d7 phase \u00d7 eval matrix.",
"Console output shows a readable table with per-phase scores for each model and a TOTAL column.",
"Each PhaseScore correctly captures: json_valid, required_keys, tool_use, and phase-specific dimensions (build_pass/eval_pass for execute).",
"The benchmark handles model failures gracefully \u2014 timeouts, API errors, and malformed responses result in zero scores with error details, not crashes.",
"Concurrent execution runs up to 10 models in parallel without resource contention.",
"Unit tests for scoring functions pass with mock data (no API calls needed)."
],
"assumptions": [
"We'll test 4 phases (plan, critique, execute, review) as specified, skipping revise/gate/finalize since they're intermediate pipeline phases that don't independently demonstrate model capability.",
"All 10 models are accessible via OpenRouter with the existing OPENROUTER_API_KEY environment variable.",
"The megaplan binary is available on PATH (consistent with existing eval configs).",
"Fixture generation will be done as a separate preliminary step before the benchmark can run \u2014 the benchmark itself won't generate fixtures on the fly.",
"For the execute phase, we'll use the existing prepare_workspace() function which runs npm install \u2014 this is slow but necessary for realistic scoring (build_pass, eval_pass).",
"The benchmark runs locally (not CI) since it requires API keys, the megaplan binary, and significant compute time.",
"We don't need external dependencies beyond what's already in the repo \u2014 console tables will use built-in string formatting.",
"Phase tests are truly independent: a model's critique score is based on critiquing a reference plan, not its own plan. This is intentional \u2014 it isolates per-phase capability.",
"The next-evals-oss repo is already cloned locally or can be fetched via the existing setup_evals_repo() mechanism."
],
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[]
Known accepted debt grouped by subsystem:
{
"config-reproducibility": [
{
"id": "DEBT-008",
"concern": "openrouter_params (temperature, top_p) are recorded in config but cannot be applied because neither hermes aiagent nor the megaplan cli expose inference parameter controls.",
"occurrence_count": 1,
"plan_ids": [
"hermes-evals-orchestrator"
]
}
],
"hermes-config": [
{
"id": "DEBT-004",
"concern": "availability check references ~/.hermes/config.yaml for api keys, but hermes stores them in /.hermes/.env.",
"occurrence_count": 1,
"plan_ids": [
"hermes-megaplan-integration"
]
}
],
"module-layout": [
{
"id": "DEBT-003",
"concern": "hermes_worker.py importing workerresult from workers.py while workers.py imports run_hermes_step from hermes_worker.py creates a circular import.",
"occurrence_count": 1,
"plan_ids": [
"hermes-megaplan-integration"
]
}
],
"scoring-diffing": [
{
"id": "DEBT-007",
"concern": "git diff head1 fails when the workspace has only one initial commit before execution begins.",
"occurrence_count": 1,
"plan_ids": [
"hermes-evals-orchestrator"
]
}
],
"trace-collection": [
{
"id": "DEBT-006",
"concern": "session log path is ~/.hermes/sessions/ not ~/.hermes/logs/, and sessions are reused across megaplan phases, so naive reads return cumulative history rather than phase-isolated snapshots.",
"occurrence_count": 1,
"plan_ids": [
"hermes-evals-orchestrator"
]
}
],
"trace-instrumentation": [
{
"id": "DEBT-005",
"concern": "the plan captures normalized session logs and aggregate cost/token counters from run_conversation(), not raw http request/response payloads or openrouter response headers.",
"occurrence_count": 1,
"plan_ids": [
"hermes-evals-orchestrator"
]
}
],
"worker-contract": [
{
"id": "DEBT-001",
"concern": "plan's sample workerresult constructor uses non-existent fields (output, input_tokens, output_tokens) instead of actual fields (payload, raw_output).",
"occurrence_count": 1,
"plan_ids": [
"hermes-megaplan-integration"
]
}
],
"worker-dispatch": [
{
"id": "DEBT-002",
"concern": "plan's sample function signature (phase, prompt, schema_dir, model) doesn't match the actual worker signature (step, state, plan_dir, *, root, ...).",
"occurrence_count": 1,
"plan_ids": [
"hermes-megaplan-integration"
]
}
]
}
code
Escalated debt subsystems:
[]
Debt guidance:
- These are known accepted limitations. Do not re-flag them unless the current plan makes them worse, broadens them, or fails to contain them.
- Prefix every new concern with a subsystem tag followed by a colon, for example `Timeout recovery: retry backoff remains brittle`.
- When a concern is recurring debt that still needs to be flagged, prefix it with `Recurring debt:` after the subsystem tag, for example `Timeout recovery: Recurring debt: retry backoff remains brittle`.
Requirements:
- Consider whether the plan is at the right level of abstraction.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids` should list previously addressed flags that now appear resolved.
- Focus on concrete issues that would cause real problems.
- Robustness level: light. Be pragmatic. Only flag issues that would cause real failures. Ignore style, minor edge cases, and issues the executor will naturally resolve.
- Verify that the plan remains aligned with the user's original intent.
- Verify that the plan follows the expected structure: one H1 title, `## Overview`, numbered step sections (`### Step N:` under `## Phase` headers, or flat `## Step N:`) with file references and numbered substeps, plus `## Execution Order` or `## Validation Order`.
- Missing required sections or step coverage (for example: no H1, no `## Overview`, or no step sections at all) should be flagged as category `completeness` with severity_hint `likely-significant`.
- Structural formatting within steps (for example: prose instead of numbered substeps, or a missing file reference inside an otherwise actionable step) should usually be category `completeness` with severity_hint `likely-minor` because the executor can still follow the instructions.
- Ask whether the plan is the simplest approach that solves the stated problem, whether it could use fewer steps or less machinery, and whether it introduces unnecessary complexity.
- Over-engineering concerns should use category `maintainability`, should usually prefix the concern with "Over-engineering:", and should scale severity_hint to the practical impact.
- Flag scope creep explicitly when the plan grows beyond the original idea or recorded user notes. Use the phrase "Scope creep:" in the concern.
- Assign severity_hint carefully. Implementation details the executor will naturally resolve should usually be `likely-minor`.
{"flags":[{"id":"benchmark-workspace-isolation","concern":"Eval workspace isolation: Parallel model runs will clobber each other's workspaces because prepare_workspace() always uses workspace_dir/<eval_name> and deletes that directory before copying. Running the same eval for multiple models concurrently will race and corrupt results.","category":"correctness","severity_hint":"likely-significant","evidence":"/Users/user_c042661f/Documents/hermes-agent/evals/run_evals.py:255 sets destination = workspace_root / eval_name, and /Users/user_c042661f/Documents/hermes-agent/evals/run_evals.py:256-258 unconditionally removes and recreates it."},{"id":"benchmark-execute-fixture-contamination","concern":"Execute fixtures: The plan says to apply a reference diff before the execute phase, but the current eval flow reaches execute from a clean prepared workspace plus finalize.json. Pre-applying code changes would invalidate the core execute metrics (tool_use, modified files, build/eval pass) because the benchmark would no longer measure the tested model's edits.","category":"correctness","severity_hint":"likely-significant","evidence":"The normal flow is clean workspace setup in /Users/user_c042661f/Documents/hermes-agent/evals/run_evals.py:242-280, then finalize -> execute in /Users/user_c042661f/Documents/hermes-agent/evals/run_evals.py:517-520. Execute scoring derives file modifications from git diff in /Users/user_c042661f/Documents/hermes-agent/evals/scoring.py:156-186."},{"id":"benchmark-phase-bootstrap","concern":"Megaplan state bootstrapping: Later-phase isolation is not actually specified tightly enough for this repo. critique, execute, and review depend on init-created .megaplan state, session ids, and history metadata; copying a few artifact files is unlikely to be sufficient to make single-phase commands runnable.","category":"completeness","severity_hint":"likely-significant","evidence":"run_megaplan_loop() creates a plan via init, then reads state.json, session mappings, history entries, and message offsets before every phase in /Users/user_c042661f/Documents/hermes-agent/evals/run_evals.py:312-416 and /Users/user_c042661f/Documents/hermes-agent/evals/run_evals.py:978-1043. The only example of phase bootstrapping in-repo is the test fake that manually synthesizes state.json and session logs in /Users/user_c042661f/Documents/hermes-agent/tests/test_evals/test_run_evals.py:42-57."},{"id":"DEBT-005","concern":"Trace instrumentation: Recurring debt: json_in_content is not reliably measurable with the data this harness would have. The repo captures parsed megaplan JSON plus normalized Hermes session logs, but not raw provider responses or think-tag boundaries, so the benchmark cannot confidently tell whether the final JSON came from content vs reasoning.","category":"correctness","severity_hint":"likely-significant","evidence":"Megaplan stdout is parsed to JSON in /Users/user_c042661f/Documents/hermes-agent/evals/run_evals.py:880-898. Phase traces come from normalized session logs in /Users/user_c042661f/Documents/hermes-agent/evals/audit.py:188-201. The audit explicitly documents that raw provider HTTP payloads are not captured in /Users/user_c042661f/Documents/hermes-agent/evals/audit.py:241-243."}],"verified_flag_ids":[],"disputed_flag_ids":[]}