Skip to content

feat: close the evaluation loop — hard golden set, router optimization, activation path#40

Merged
KostasCherv merged 1 commit into
mainfrom
feat/prompt-optimization-loop
Jul 14, 2026
Merged

feat: close the evaluation loop — hard golden set, router optimization, activation path#40
KostasCherv merged 1 commit into
mainfrom
feat/prompt-optimization-loop

Conversation

@KostasCherv

Copy link
Copy Markdown
Owner

Context

Review finding: DeepEval and DSPy were integrated but non-evidentiary — the 5-case golden set scored 1.0 everywhere, the committed pipeline report showed 0.0 improvement on every template, and optimized prompts had no path into production.

What changed

Golden set (5 → 20 cases) — added conflicting-source, unanswerable-from-context, distractor-heavy, partial-answer, and numeric/temporal cases. The set now discriminates:

Model Faithfulness Relevancy p50 latency
gemma4:31b-cloud 1.000 0.972 1.6 s
gpt-4o-mini 0.953 0.917 2.6 s

Router prompt optimization (scripts/optimize_router_prompt.py) — targets the actual production router prompt (hardcoded in rag_chat_helpers.py, not a Jinja2 template) using the real teacher-labeled dataset (429 train / 103 held-out). Before/after is scored through the production prompt + parse_chat_action_json path, not DSPy's adapter.

Result (honest null): baseline scores 92.2% held-out teacher agreement; MIPROv2 at light and medium budgets returned the existing prompt as the best program. Residual disagreement concentrates in search_finance_tools (78.9%) / asset_price (89.5%) — consistent with teacher-label ambiguity. Labels are unverified Qwen3-30B teacher labels; the caveat is embedded in the artifact and docs.

Activation pathROUTER_PROMPT_PATH setting; classify_chat_action loads an optimized artifact's system_prompt with logged fallback to the built-in prompt. 4 new tests.

Harness fixesmodel_comparison.py records per-case failures (error column) instead of aborting; removed dead web_search_decision/followup_answer/web_search_repair specs (templates no longer exist) and the stale zero-improvement artifacts.

Verification

  • ruff, mypy clean; 579 tests pass; AI regression gate 20/20
  • DeepEval comparison re-run end-to-end on the 20-case set (results.csv committed)
  • Router optimization run at light and medium budgets; artifact committed as the record

Test plan

  • uv run python -m pytest tests/ -q — 579 passed
  • uv run python -m src.evals.regression_gate — 100%
  • uv run python scripts/optimize_router_prompt.py --eval-only — 92.2% baseline reproduced
  • uv run python src/evals/model_comparison.py — 40 rows, no aborts

…mization, activation path

- Expand golden_set.json from 5 to 20 cases with hard classes (conflicting
  sources, unanswerable context, distractors, numeric/temporal synthesis)
  so DeepEval metrics discriminate instead of saturating at 1.0
- Add scripts/optimize_router_prompt.py: MIPROv2 over the teacher-labeled
  router dataset, scored before/after on held-out through the production
  prompt + parser path; artifact records both scores and the teacher-label
  caveat
- Add ROUTER_PROMPT_PATH activation: classify_chat_action loads an
  optimized prompt artifact with fallback to the built-in prompt (tested)
- Make model_comparison.py record per-case failures instead of aborting
- Remove dead router/followup/repair specs from the template pipeline and
  the stale zero-improvement artifacts they produced
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cortex Ready Ready Preview, Comment Jul 14, 2026 3:22pm

@KostasCherv
KostasCherv merged commit be30b19 into main Jul 14, 2026
5 checks passed
@KostasCherv
KostasCherv deleted the feat/prompt-optimization-loop branch July 14, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant