Skip to content

Commit ea99606

Browse files
committed
feat: implement automated eval asset generation and improvement prompts for failed benchmark traces
1 parent 2e95a53 commit ea99606

7 files changed

Lines changed: 1026 additions & 9 deletions

File tree

.env.example

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,29 @@ AZURE_API_VERSION="..."
4343
VERTEXAI_PROJECT="..."
4444
VERTEXAI_LOCATION="..."
4545
# (Also typically requires GOOGLE_APPLICATION_CREDENTIALS path)
46+
47+
# ----------------------------------------
48+
# 3. Eval Asset Generation (Optional)
49+
# ----------------------------------------
50+
# Score below this threshold triggers automatic eval asset generation.
51+
# Default: 70 (i.e. < 70/100 = failure needing improvement)
52+
EVAL_SCORE_THRESHOLD=70
53+
54+
# ----------------------------------------
55+
# 4. Langfuse Integration (Optional — only needed for cloud eval export)
56+
# ----------------------------------------
57+
# EvalMonkey works perfectly WITHOUT Langfuse.
58+
# Configure this ONLY if you want to automatically push generated improvement
59+
# evals to a Langfuse dataset for team sharing or LLM-as-judge workflows.
60+
#
61+
# Get your keys from: https://cloud.langfuse.com → Settings → API Keys
62+
# Self-hosted: set LANGFUSE_HOST to your instance URL.
63+
#
64+
LANGFUSE_PUBLIC_KEY="pk-lf-..."
65+
LANGFUSE_SECRET_KEY="sk-lf-..."
66+
# LANGFUSE_HOST="https://cloud.langfuse.com" # default; change for self-hosted
67+
68+
# Name of the Langfuse dataset where failing evals are pushed.
69+
# Used by: evalmonkey generate-evals --langfuse-dataset <name>
70+
# demo_rag_app.sh (automatic if keys are set)
71+
# LANGFUSE_DATASET="evalmonkey_failures"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ env/
3737
# Local configuration
3838
.env
3939

40-
# Evalmonkey specific
40+
# EvalMonkey specific
4141
history.json
4242
*.log
4343
demo_run.sh
44+
demo_rag_app.sh
45+
output/

README.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Agents are fundamentally non-deterministic. They rely on external APIs, tool loo
1919
**EvalMonkey** is the ultimate, strictly local, open-source execution harness that enables developers to:
2020
1. 🎯 **Benchmark Capabilities**: Run standard Agent benchmark datasets against your agent endpoints natively!
2121
2. 🔥 **Inject Chaos**: Mutate headers, spike latency, and corrupt schemas dynamically to prove true resilience.
22-
3. 📈 **Track Production Reliability**: Locally store all scores to visualize a single Production Reliability metric that aggregates capability plus chaos-resilience over time!
22+
3. 📈 **Track Production Reliability**: Locally store all scores to visualize a single Production Reliability metric over time!
23+
4. 🛠 **Generate Improvement Evals**: When scores are poor, automatically synthesise targeted test cases using your LLM — then hand them to Claude Code or Cursor to fix your agent.
2324

2425
EvalMonkey natively supports evaluating ANY LLM: **AWS Bedrock**, **Azure**, **GCP**, **OpenAI**, and **Ollama**.
2526

@@ -29,6 +30,7 @@ EvalMonkey natively supports evaluating ANY LLM: **AWS Bedrock**, **Azure**, **G
2930
- **8 Agent Frameworks natively supported**: CrewAI, LangChain, OpenAI Agents, Microsoft AutoGen, AWS Bedrock, Ollama, Strands, and custom HTTP endpoints.
3031
- **20 Standard Benchmarks out-of-the-box**: GSM8K, BIG-Bench Hard, HotpotQA, ToxiGen, MT-Bench, MBPP, and more — all categorised by the agent type they target.
3132
- **23 Chaos Injections ready to run**: 12 client-side payload mutations + 11 server-side middleware injections — all text-based, no GPU or vision dependencies.
33+
- **Automatic Eval Asset Generation**: Poor benchmark scores automatically produce `traces.json`, `evals.json`, and `improvement_prompt.md` — one `cat` command away from Claude Code or Cursor.
3234

3335
## ⚡️ Quick Start
3436

@@ -339,7 +341,95 @@ Add the following to your MCP configuration file (e.g. `claude_desktop_config.js
339341
}
340342
```
341343

342-
Once connected, your AI assistant will gain the ability to list benchmarks, trigger full evaluation runs, inject chaos payload mutators, and pull historical trends entirely autonomously while helping you write your agent!
344+
Once connected, your AI assistant will gain the ability to list benchmarks, trigger full evaluation runs, inject chaos payload mutators, pull historical trends, and generate improvement eval assets — entirely autonomously while helping you build your agent!
345+
346+
### Available MCP Tools
347+
348+
| Tool | What it does |
349+
|---|---|
350+
| `run_benchmark` | Run a standard benchmark against any HTTP agent URL |
351+
| `run_chaos` | Run a benchmark with a specific chaos profile injected |
352+
| `get_benchmark_history` | Return chronological score history for a scenario |
353+
| `generate_improvement_evals` | Run a benchmark, capture failures, synthesise targeted test cases, save to `output/` |
354+
| `get_eval_assets` | Read saved `traces.json` / `evals.json` / `improvement_prompt.md` directly into context |
355+
| `run_full_pipeline` | **One-shot**: baseline + chaos + eval generation + optional Langfuse export |
356+
357+
**Example Claude Code / Cursor session:**
358+
```
359+
# Ask Claude Code to run the full loop:
360+
"Run the full EvalMonkey pipeline on my agent at http://localhost:8000/solve
361+
using the gsm8k scenario with prompt injection and payload bloat chaos tests.
362+
Then read the improvement prompt and fix my agent."
363+
364+
# Claude Code will call:
365+
# 1. run_full_pipeline(scenario="gsm8k", target_url="...", chaos_profiles="client_prompt_injection,client_payload_bloat")
366+
# 2. get_eval_assets(output_dir="output/gsm8k_...") ← reads the improvement brief
367+
# 3. Edits your agent code to fix the failures
368+
# 4. run_benchmark(...) ← verifies the fix
369+
```
370+
371+
---
372+
373+
### Experience 5: Automatic Improvement Eval Generation
374+
When a benchmark scores poorly (< 70/100 by default), EvalMonkey automatically:
375+
1. Saves all failing traces to `output/<scenario>_<ts>/traces.json`
376+
2. Asks the judge LLM to synthesise targeted improvement test cases → `evals.json`
377+
3. Generates a ready-to-paste coding-agent prompt → `improvement_prompt.md`
378+
379+
```bash
380+
# After a failing benchmark run, EvalMonkey prints:
381+
# ⚠️ 3 sample(s) scored below threshold — eval assets saved.
382+
# Output → output/gsm8k_20260425_212530/
383+
# 🛠 Next steps to improve your agent:
384+
# 1. Regenerate evals anytime:
385+
# evalmonkey generate-evals --traces-file output/gsm8k_.../traces.json
386+
# 2. Pass improvement brief to your coding agent:
387+
# cat output/gsm8k_.../improvement_prompt.md | pbcopy
388+
# 3. Re-run after fixing:
389+
# evalmonkey run-benchmark --scenario gsm8k
390+
391+
# Re-generate evals from saved traces (without re-running the benchmark):
392+
evalmonkey generate-evals --traces-file output/gsm8k_20260425_212530/traces.json
393+
394+
# Push evals to Langfuse for team sharing:
395+
evalmonkey generate-evals \
396+
--traces-file output/gsm8k_20260425_212530/traces.json \
397+
--langfuse-dataset my_agent_failures
398+
```
399+
400+
> **Langfuse is optional.** EvalMonkey works completely without it. Only configure
401+
> `LANGFUSE_PUBLIC_KEY` + `LANGFUSE_SECRET_KEY` in `.env` if you want to push
402+
> generated evals to a Langfuse dataset for cloud storage or LLM-as-judge workflows.
403+
404+
---
405+
406+
### Experience 6: One-Command End-to-End Demo (RAG App)
407+
Run the full benchmark + chaos + eval-generation pipeline against the built-in `rag_app` sample agent:
408+
409+
```bash
410+
# First time setup:
411+
cp .env.example .env # fill in EVAL_MODEL + your LLM provider key
412+
pip install -e .
413+
414+
# Run everything:
415+
./demo_rag_app.sh
416+
```
417+
418+
The script will:
419+
1. 🚀 Start `rag_app` in the background
420+
2. 📊 Run 3 baseline benchmarks (`gsm8k`, `mmlu`, `arc`)
421+
3. 🔥 Run 5 chaos profiles
422+
4. 🛠 Merge all failing traces → generate `output/demo_<ts>/evals.json` + `improvement_prompt.md`
423+
5. 💡 Print the exact `cat` command to paste into Claude Code or Cursor
424+
6. 📈 Show your historical Production Reliability trend
425+
426+
**Output directory structure:**
427+
```
428+
output/demo_20260425_212530/
429+
traces.json ← all failing traces (input, output, score, reasoning)
430+
evals.json ← LLM-synthesised targeted test cases (Langfuse-compatible)
431+
improvement_prompt.md ← paste into Claude Code / Cursor to auto-fix your agent
432+
```
343433

344434
---
345435

0 commit comments

Comments
 (0)