Skip to content

Eval-driven prompt optimization for small local models (measured on the #69 harness) #177

Description

@hellices

Why

PR #172 fixed the worst observed small-model failure modes (composite namespace/name 404 loops, idle screen), but the prompts have still never been tuned against measured results — the #69 harness landed after the prompt wording did, and no eval-driven prompt iteration has happened since. The wording in agent/prompts.py is best-effort, not evidence-backed.

Industry check (verified 2026-08, across aider, Cline, OpenHands, smolagents, Goose, RA.Aid, Continue.dev, opencode): no product maintains separate per-model system prompts. The dominant pattern is one shared prompt template plus per-model settings (tool-call format, temperature, capability flags) — aider's model-settings.yml is the clearest expression. korvid's full/small capability-profile design (#71) is already the right architecture; what's missing is closing the loop between eval failures and prompt wording.

What

An eval-driven prompt optimization pass, measured before/after on the #69 harness with the bundled 24-scenario pack (≥3 reps), against at least two small models (e.g. qwen3:4b, qwen3:8b — current BFCL open-weight FC leaders at these sizes).

  1. Baseline: run python -m korvid.evals --profile small (and full on the larger model) per model; commit the reports as the "before" numbers.
  2. Failure-mode analysis: classify failed runs from the event streams — wrong tool, wrong arguments, gave up early, answered without evidence, misdiagnosis keyword, iteration exhaustion.
  3. Targeted prompt edits in agent/prompts.py (SMALL_SYSTEM_PROMPT, SMALL_TOOL_DESCRIPTIONS, and the shared clauses where evidence points there), one failure mode at a time. Candidate levers, each only if the eval shows the failure:
    • worked-example coverage (the single OOM example may over-anchor answers toward OOM),
    • explicit stop-condition wording ("answer once the evidence names the cause; do not keep exploring"),
    • negative-control handling ("say the resource is healthy when checks pass" — the pack has 3 healthy scenarios),
    • diagnose_pod-first routing strength.
  4. After: re-run the same matrix; a change lands only with a non-regressing overall success rate and an improved target metric. Numbers go into the PR description and the scoreboard (companion issue).

Invariants

Out of scope

  • Per-model prompt files (anti-pattern per the industry check; capability tiers are the unit of prompt variation).
  • New profile tiers or automatic capability detection (revisit only if the eval shows the two-tier split is insufficient).
  • Tool-format fallbacks for models without native tool calling (e.g. Gemma 3) — separate concern, needs its own design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: agentEmbedded agent runtime, tools, prompts, and providersconcern: testingTest infrastructure, evaluation, and quality measurementenhancementNew feature or requestpriority: highShould be scheduled ahead of normal-priority work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions