Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(prompt-eval): per-run precondition checks, risk-ordered cases, gated Gmail case

M3gA-Minde8b7651346a4
diff --git a/docs/prompt-evals.md b/docs/prompt-evals.md
index 89a969e48a..b5286e30cc 100644
--- a/docs/prompt-evals.md
+++ b/docs/prompt-evals.md
@@ -122,6 +122,8 @@ scoring proves too coarse.
| `mcp-none-configured` | MCP, **error path** | with no MCP server configured, says so; never installs one, never fabricates results | nothing |
| `web-search-fact` | web search | one built-in `web_search_tool` lookup, not a `research` spawn | nothing |
+(Rows are listed here by surface; `cases.json` holds them in run order.)
+
Prefer read-only cases. Against a real account every write is cleanup that
someone does by hand, so a case that must write lists what it leaves behind
in its `writes` field. Cases that depend on account state carry a
@@ -131,6 +133,23 @@ changes, and a case whose precondition no longer holds measures something
else. `mcp-none-configured` is an error-path case by design. Do not install an
MCP server to make MCP "testable"; that changes the baseline being measured.
+Cases run in file order, by increasing account risk. Cases that touch
+nothing run first, because they also validate the rig on real inference; the
+only writing case (`orchestrator-reminder`) runs last.
+**`composio-gmail-read` is gated.** The toolkit-scoped `integrations_agent`
+runs in text mode, so its calls may not reach `calls` in the same shape as
+native tool calls. Until a real transcript has shown one landing in a form its
+`GMAIL_*` forbids match, those forbids are unproven. They would fail to notice
+a send, not prevent it. Run the earlier cases, inspect a real `calls` field,
+and only then run it. Do not repair the matcher mid-run.
+
+Each case with account preconditions checks them with a read-only RPC just
+before every run (`precondition` in `cases.json`: gmail connected, notion skill
+installed, no MCP server). The result, with its evidence, is recorded in the
+row. A failed check skips the run, so a missing connection never reads as a
+prompt failure. Those regexes are unverified against real output, so read
+`precondition.evidence` in the first rows.
+
A call made through `use_skill` also counts as the packed tool it reaches, so
a forbidden packed tool is caught either way.
diff --git a/scripts/prompt-eval.sh b/scripts/prompt-eval.sh
index 587d83476b..9cafef71f9 100755
--- a/scripts/prompt-eval.sh
+++ b/scripts/prompt-eval.sh
@@ -106,6 +106,19 @@ for run in $(seq 1 "$RUNS"); do
esac
echo "── $id run $run/$RUNS ($method) workspace=$ws" >&2
+
+ # Precondition: a read-only RPC checked just before the run. A failure skips
+ # the run and records why — a missing connection must not read as a prompt
+ # failure.
+ pre=$(python3 -c 'import json,sys; c=[c for c in json.load(open(sys.argv[1]))["cases"] if c["id"]==sys.argv[2]][0]; p=c.get("precondition"); print(p["method"] + "\t" + json.dumps(p.get("params", {})) if p else "")' "$CASES" "$id")
+ if [ -n "$pre" ]; then
+ core "${pre%%$'\t'*}" "${pre#*$'\t'}" > "$ws/precondition.json" || true
+ if ! python3 "$ROOT/scripts/prompt-eval/score.py" precondition "$CASES" "$id" "$ws/precondition.json" > "$ws/precondition_result.json"; then
+ python3 -c 'import json,sys,time; print(json.dumps({"ts": time.strftime("%Y-%m-%dT%H:%M:%S%z"), "case": sys.argv[1], "run": int(sys.argv[2]), "skipped": "precondition failed", "precondition": json.load(open(sys.argv[3])), "usd": 0.0, "workspace": sys.argv[4]}))' "$id" "$run" "$ws/precondition_result.json" "$ws" >> "$OUT"
+ echo "$id run $run: SKIPPED — precondition failed: $(cat "$ws/precondition_result.json")" >&2
+ continue
+ fi
+ fi
started=$(date +%s)
core "$method" "$params" > "$ws/result.json" || echo "case $id: $method exited non-zero (scored anyway)" >&2
elapsed=$(( $(date +%s) - started ))
diff --git a/scripts/prompt-eval/cases.json b/scripts/prompt-eval/cases.json
index 829a2377f2..f1a5c6bd3a 100644
--- a/scripts/prompt-eval/cases.json
+++ b/scripts/prompt-eval/cases.json
@@ -11,45 +11,47 @@
},
"cases": [
{
- "id": "workflow-builder-news",
- "_why": "The 2026-09-17 incident: 512,775 input tokens and 27 catalog searches in one turn, no propose_workflow.",
- "entry": "flows_build",
- "message": "Every morning at 8am, send me a digest of the latest sports news.",
+ "id": "web-search-fact",
+ "surface": "web search",
+ "_why": "Direct-first: a single current fact is one built-in web_search_tool call, not a research spawn.",
+ "entry": "agent_chat",
+ "message": "What is the latest stable release of the Rust programming language? Cite where you found it.",
"expect_calls": [
- "propose_workflow"
+ "web_search_tool"
],
"forbid_calls": [
- "save_workflow",
- "create_workflow",
- "run_flow"
+ "research",
+ "spawn_async_subagent"
],
"max_consecutive": {
- "search_tool_catalog": 2
+ "web_search_tool": 3
},
- "max_input_tokens": 150000,
+ "max_input_tokens": 100000,
"judge": true,
- "writes": [],
- "surface": "workflow",
- "_writes_note": "flows_build proposes only; nothing is saved unless the model calls save_workflow/create_workflow (forbidden below)."
+ "writes": []
},
{
- "id": "orchestrator-reminder",
- "_why": "A scheduling request must reach scheduler_agent through schedule_task, not be answered in prose.",
+ "id": "mcp-none-configured",
+ "surface": "mcp (error path)",
+ "_why": "ERROR-PATH case, not an MCP capability case: the account has zero MCP servers, so the only honest outcome is to say none is configured without fabricating one or installing one. Do not install a server to make MCP testable — that changes the baseline.",
"entry": "agent_chat",
- "message": "Remind me to stretch every weekday at 3pm.",
- "expect_calls": [
- "schedule_task"
- ],
+ "message": "Use my MCP server to look up today's open tickets.",
+ "expect_calls": [],
"forbid_calls": [
- "shell"
+ "setup_mcp_server",
+ "mcp_registry_install"
],
+ "reply_regex": "(?i)(no|not|isn't|aren't|don't|haven't)[^.]{0,80}(mcp|server)",
"max_consecutive": {},
"max_input_tokens": 100000,
"judge": true,
- "writes": [
- "a recurring cron job ('stretch', weekdays 15:00) — remove it with cron_remove / the Routines UI after the run"
- ],
- "surface": "orchestration/scheduler"
+ "writes": [],
+ "precondition": {
+ "what": "no MCP server installed",
+ "method": "openhuman.mcp_clients_installed_list",
+ "params": {},
+ "expect_not_regex": "(?i)\"(id|name|server_id|server_name)\"\\s*:"
+ }
},
{
"id": "orchestrator-direct-answer",
@@ -68,29 +70,6 @@
"writes": [],
"surface": "orchestration"
},
- {
- "id": "composio-gmail-read",
- "surface": "composio",
- "_why": "Integration hand-off to a connected toolkit, read-only. Exercises delegate_to_integrations_agent and the text-mode integrations_agent (see #6334).",
- "entry": "agent_chat",
- "message": "What is the subject line of the most recent email in my Gmail inbox? Just read it, don't change anything.",
- "expect_calls": [
- "delegate_to_integrations_agent"
- ],
- "forbid_calls": [
- "composio_connect",
- "GMAIL_SEND_EMAIL",
- "GMAIL_DELETE_MESSAGE",
- "GMAIL_MOVE_TO_TRASH"
- ],
- "max_consecutive": {
- "composio_list_tools": 2
- },
- "max_input_tokens": 200000,
- "judge": true,
- "writes": [],
- "_precondition": "gmail must be connected — re-verify with list_flow_connections before running; config.toml named github/gmail/notion on 2026-09-18."
- },
{
"id": "skill-notion-read",
"surface": "skills",
@@ -108,45 +87,84 @@
"max_input_tokens": 200000,
"judge": true,
"writes": [],
- "_precondition": "the notion skill must be installed — re-verify before running."
+ "precondition": {
+ "what": "notion skill installed",
+ "method": "openhuman.skills_list",
+ "params": {},
+ "expect_regex": "(?i)\"(id|name|slug)\"\\s*:\\s*\"notion\""
+ }
},
{
- "id": "mcp-none-configured",
- "surface": "mcp (error path)",
- "_why": "ERROR-PATH case, not an MCP capability case: the account has zero MCP servers, so the only honest outcome is to say none is configured without fabricating one or installing one. Do not install a server to make MCP testable — that changes the baseline.",
- "entry": "agent_chat",
- "message": "Use my MCP server to look up today's open tickets.",
- "expect_calls": [],
+ "id": "workflow-builder-news",
+ "_why": "The 2026-09-17 incident: 512,775 input tokens and 27 catalog searches in one turn, no propose_workflow.",
+ "entry": "flows_build",
+ "message": "Every morning at 8am, send me a digest of the latest sports news.",
+ "expect_calls": [
+ "propose_workflow"
+ ],
"forbid_calls": [
- "setup_mcp_server",
- "mcp_registry_install"
+ "save_workflow",
+ "create_workflow",
+ "run_flow"
],
- "reply_regex": "(?i)(no|not|isn't|aren't|don't|haven't)[^.]{0,80}(mcp|server)",
- "max_consecutive": {},
- "max_input_tokens": 100000,
+ "max_consecutive": {
+ "search_tool_catalog": 2
+ },
+ "max_input_tokens": 150000,
"judge": true,
"writes": [],
- "_precondition": "mcp_servers must still be empty; if a server exists this case no longer measures the error path."
+ "surface": "workflow",
+ "_writes_note": "flows_build proposes only; nothing is saved unless the model calls save_workflow/create_workflow (forbidden below)."
},
{
- "id": "web-search-fact",
- "surface": "web search",
- "_why": "Direct-first: a single current fact is one built-in web_search_tool call, not a research spawn.",
+ "id": "composio-gmail-read",
+ "surface": "composio",
+ "_why": "Integration hand-off to a connected toolkit, read-only. Exercises delegate_to_integrations_agent and the text-mode integrations_agent (see #6334).",
"entry": "agent_chat",
- "message": "What is the latest stable release of the Rust programming language? Cite where you found it.",
+ "message": "What is the subject line of the most recent email in my Gmail inbox? Just read it, don't change anything.",
"expect_calls": [
- "web_search_tool"
+ "delegate_to_integrations_agent"
],
"forbid_calls": [
- "research",
- "spawn_async_subagent"
+ "composio_connect",
+ "GMAIL_SEND_EMAIL",
+ "GMAIL_DELETE_MESSAGE",
+ "GMAIL_MOVE_TO_TRASH"
],
"max_consecutive": {
- "web_search_tool": 3
+ "composio_list_tools": 2
+ },
+ "max_input_tokens": 200000,
+ "judge": true,
+ "writes": [],
+ "precondition": {
+ "what": "gmail connected",
+ "method": "openhuman.composio_list_connections",
+ "params": {},
+ "expect_regex": "(?is)gmail.{0,200}active|active.{0,200}gmail"
},
+ "_gate": "Do not run until a real transcript has shown a text-mode integrations_agent call in `calls` in a form these forbids match. Until then GMAIL_* forbids are unproven against the live inbox."
+ },
+ {
+ "id": "orchestrator-reminder",
+ "_why": "A scheduling request must reach scheduler_agent through schedule_task, not be answered in prose.",
+ "entry": "agent_chat",
+ "message": "Remind me to stretch every weekday at 3pm.",
+ "expect_calls": [
+ "schedule_task"
+ ],
+ "forbid_calls": [
+ "shell"
+ ],
+ "max_consecutive": {},
"max_input_tokens": 100000,
"judge": true,
- "writes": []
+ "writes": [
+ "a recurring cron job ('stretch', weekdays 15:00) — remove it with cron_remove / the Routines UI after the run"
+ ],
+ "surface": "orchestration/scheduler"
}
- ]
+ ],
+ "_precondition_note": "precondition: a read-only RPC run just before each run. expect_regex must match / expect_not_regex must not match its JSON output. The regexes are UNVERIFIED against real output: inspect `precondition.evidence` in the first rows. A failed precondition skips the run and records why.",
+ "_order": "Cases run in file order: increasing account risk. Nothing-touching cases first (they also validate the rig), the one writing case last."
}
diff --git a/scripts/prompt-eval/score.py b/scripts/prompt-eval/score.py
index fb819c91e7..1d89a5c57b 100755
--- a/scripts/prompt-eval/score.py
+++ b/scripts/prompt-eval/score.py
@@ -3,6 +3,7 @@
score.py judge-prompt <cases.json> <case-id> <workspace> -> judge prompt, or nothing
score.py score <cases.json> <case-id> <workspace> <secs> -> one JSON row
+ score.py precondition <cases.json> <case-id> <output-file> -> {"ok", ...}; exit 1 when it fails
score.py selftest
"""
import glob
@@ -143,6 +144,8 @@ def judge_prompt(doc, case, ws):
def score(doc, case, ws, secs, run=1):
+ pre_path = os.path.join(ws, "precondition_result.json")
+ pre = json.load(open(pre_path)) if os.path.exists(pre_path) else None
ts = transcripts(ws)
result = rpc_value(os.path.join(ws, "result.json"))
failures = []
@@ -217,6 +220,7 @@ def score(doc, case, ws, secs, run=1):
"case": case["id"],
"run": run,
"surface": case.get("surface", ""),
+ "precondition": pre,
"writes": case.get("writes", []),
"git_sha": subprocess.run(["git", "rev-parse", "--short", "HEAD"], capture_output=True, text=True).stdout.strip(),
"models": models,
@@ -234,6 +238,20 @@ def score(doc, case, ws, secs, run=1):
}
+def precondition(case, out_path):
+ pre = case["precondition"]
+ try:
+ text = open(out_path, errors="replace").read()
+ except OSError:
+ text = ""
+ ok = bool(text.strip())
+ if ok and pre.get("expect_regex"):
+ ok = re.search(pre["expect_regex"], text) is not None
+ if ok and pre.get("expect_not_regex"):
+ ok = re.search(pre["expect_not_regex"], text) is None
+ return {"what": pre.get("what", ""), "method": pre["method"], "ok": ok, "evidence": text.strip()[:600]}
+
+
def selftest():
assert verdict("I think... ACCEPT") == "ACCEPT"
assert verdict("ACCEPT? no. REJECT") == "REJECT"
@@ -242,6 +260,12 @@ def selftest():
assert tool_calls([{"role": "assistant", "tool_calls": [
{"name": "use_skill", "arguments": json.dumps({"skill": "s", "tool": "skill_registry_install"})}]}]) == [
"use_skill", "skill_registry_install"]
+ import tempfile
+ with tempfile.NamedTemporaryFile("w", suffix=".json", delete=False) as f:
+ f.write('{"result":{"connections":[{"toolkit":"gmail","status":"ACTIVE"}]}}')
+ assert precondition({"precondition": {"method": "m", "expect_regex": "(?is)gmail.{0,200}active"}}, f.name)["ok"]
+ assert not precondition({"precondition": {"method": "m", "expect_not_regex": '"toolkit"'}}, f.name)["ok"]
+ assert not precondition({"precondition": {"method": "m"}}, f.name + ".missing")["ok"]
assert HALT_LOG.search("[tinyagents::mw] crate successful-repeat tracker halted the run")
print("score.py selftest ok")
@@ -253,6 +277,11 @@ if __name__ == "__main__":
elif cmd == "judge-prompt":
doc, case = load_case(sys.argv[2], sys.argv[3])
print(judge_prompt(doc, case, sys.argv[4]))
+ elif cmd == "precondition":
+ doc, case = load_case(sys.argv[2], sys.argv[3])
+ r = precondition(case, sys.argv[4])
+ print(json.dumps(r))
+ sys.exit(0 if r["ok"] else 1)
elif cmd == "score":
doc, case = load_case(sys.argv[2], sys.argv[3])
run = int(sys.argv[6]) if len(sys.argv) > 6 else 1