Skip to content

Commit a337863

Browse files
authored
Split benchmark backend workflows (#45)
1 parent f1d9af8 commit a337863

10 files changed

Lines changed: 336 additions & 223 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
name: run-api-benchmark
3+
description: Configure and run this problem-reductions benchmark through a model API using the containerized mini-swe/LiteLLM backend. Use when the caller chooses an API, provider endpoint, gateway, hosted model, or container run. Guides provider configuration without collecting secrets, detects the container engine, runs preflight, produces submission.json, validates it, and uploads only when explicitly requested.
4+
---
5+
6+
# Run the API benchmark
7+
8+
Run one whole-repository mini-swe session. The agent chooses rules, search depth, and when to
9+
stop. Do not add a step, turn, cost, or rule-count limit. The evaluation-owned `submit`
10+
command is the only scored certificate channel; `SUBMIT_LIMIT` defaults to 100.
11+
12+
Read [references/provider-config.md](references/provider-config.md) when configuring the
13+
provider or diagnosing API/preflight failures. Use `scripts/detect-engine.sh` before build.
14+
15+
## Ask the API questions
16+
17+
Ask only for information the caller has not already supplied. Ask in this order and wait at
18+
each numbered stage when its answer determines the next question. Use the product's
19+
structured user-input UI when available; otherwise ask the quoted question in plain text.
20+
Do not dump every configuration question into one message.
21+
22+
1. Ask:
23+
24+
> Which API model should run the benchmark? Give its provider/model identifier, for
25+
> example `openai/gpt-...`, `anthropic/claude-...`, or `openrouter/...`.
26+
27+
2. Ask:
28+
29+
> Does this model use the provider's standard endpoint, or a custom OpenAI-compatible
30+
> endpoint/gateway?
31+
32+
For a custom endpoint, ask for `API_BASE` and any non-secret `MODEL_KWARGS`. Never ask the
33+
caller to paste an API key into chat. Tell them exactly which key variable to set locally
34+
in the gitignored `submission.env`, then wait for confirmation that it is configured.
35+
36+
3. Ask:
37+
38+
> Is this a local/test submission, or should the completed file be uploaded to the
39+
> official intake?
40+
41+
Default to local/test only when the caller explicitly delegates the choice. Do not ask
42+
for intake credentials unless upload is selected.
43+
44+
4. Resolve `PR_REF` (default `v0.6.0`), `SUBMIT_LIMIT` (default 100), authoritative output
45+
path, and log path. Offer defaults and ask the caller whether to accept them rather than
46+
demanding paths one at a time.
47+
48+
## Configure safely
49+
50+
Create `submission.env` from `submission.env.example` when absent. It is gitignored. Set or
51+
guide the caller to set:
52+
53+
- `MODEL_NAME`;
54+
- one provider-specific key or `API_KEY`;
55+
- `API_BASE` and `MODEL_KWARGS` only when needed;
56+
- `SUBMIT_LIMIT` when non-default.
57+
58+
Do not expose secret values in command output or the final response. Do not add removed
59+
`AGENT_MODE`, `MAX_RULES`, or max-turn settings.
60+
61+
## Prepare and preflight
62+
63+
1. Run `scripts/detect-engine.sh` and parse its `KEY=VALUE` output. Read
64+
[references/engines.md](references/engines.md) only if no engine is available or the RAM
65+
hint is low.
66+
2. Build with one consistent ref:
67+
68+
```bash
69+
make runner-build PR_REF=v0.6.0
70+
```
71+
72+
For Podman, use the equivalent command from `references/engines.md`.
73+
3. Before the preflight's real API call, show the resolved model, backend `mini-swe`, API
74+
endpoint with secrets redacted, `PR_REF`, submit limit, output path, and log path. Ask for
75+
explicit confirmation.
76+
4. Run `make preflight`. It checks `pred`, rule sources, and one tiny LiteLLM call. Stop on
77+
any failure; never proceed to a full run after a failed preflight.
78+
79+
## Run and validate
80+
81+
After preflight passes, state that the full session can consume substantial time and API
82+
credits and ask for explicit confirmation to start it. Then run `make run` or the equivalent
83+
Podman command using the detector's `RUN_FLAGS`.
84+
85+
Confirm the authoritative `submission.json` exists. Always validate it:
86+
87+
```bash
88+
python -m benchmark.submit --predictions <submission.json> --dry-run
89+
```
90+
91+
Report `bugs_found`, `total_tokens_k`, submit attempts, any `run_error`, and absolute output
92+
and log paths. A `run_error` means partial salvage, not a clean zero-bug completion.
93+
94+
Upload only when the caller explicitly selected official intake and provided
95+
`PRB_SUBMIT_URL` plus `PRB_API_KEY` locally:
96+
97+
```bash
98+
python -m benchmark.submit --predictions <submission.json>
99+
```
100+
101+
Add `--test` only when the caller requests an end-to-end intake test excluded from the
102+
public board. Never upload merely because the run completed.
103+
104+
An exit code 137 means the engine needs more memory. Preserve partial outputs and read
105+
actual command errors before recommending changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface:
2+
display_name: "Run API Benchmark"
3+
short_description: "Configure and run the benchmark through a model API"
4+
default_prompt: "Use $run-api-benchmark to configure and run an API-backed benchmark."
File renamed without changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# API provider configuration
2+
3+
Use `submission.env.example` as the source of truth. Keep secrets in the gitignored
4+
`submission.env`; never ask the caller to paste them into chat.
5+
6+
## Variables
7+
8+
| Variable | Purpose |
9+
|---|---|
10+
| `MODEL_NAME` | LiteLLM-routable provider/model identity |
11+
| provider key or `API_KEY` | authentication |
12+
| `API_BASE` | custom gateway or OpenAI-compatible endpoint |
13+
| `MODEL_KWARGS` | JSON object for provider-specific LiteLLM arguments |
14+
| `MAX_TOKENS` | per-response output ceiling, not a run/turn limit |
15+
| `SUBMIT_LIMIT` | run-wide certificate attempts |
16+
| `AGENT_CONFIG` | full prompt override |
17+
| `AGENT_STRATEGY_FILE` | extra strategy injected into the shared prompt |
18+
| `SUBMITTED_BY` | optional submitter metadata |
19+
20+
Do not use removed `AGENT_MODE`, `MAX_RULES`, or max-turn variables.
21+
22+
## Standard provider
23+
24+
Set `MODEL_NAME` and the provider's documented key variable, for example
25+
`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `OPENROUTER_API_KEY`, or `GEMINI_API_KEY`.
26+
27+
## Custom endpoint
28+
29+
```ini
30+
MODEL_NAME=openai/my-model
31+
API_BASE=https://my-gateway.example/v1
32+
API_KEY=...
33+
MODEL_KWARGS={"custom_llm_provider":"openai"}
34+
```
35+
36+
## Failure decoding
37+
38+
| Symptom | Action |
39+
|---|---|
40+
| `pred binary` or rule-source preflight fails | rebuild the image at the intended `PR_REF` |
41+
| tiny model call fails | correct model routing, endpoint, key variable, or kwargs |
42+
| build exits 137 | provision at least about 8 GB for the engine VM/host |
43+
| `run_error` | preserve the partial submission and logs; do not call it a clean zero |
44+
| submit channel not probed | treat as runner infrastructure failure |

.agents/skills/run-benchmark/scripts/detect-engine.sh renamed to .agents/skills/run-api-benchmark/scripts/detect-engine.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Read-only host probe for the run-benchmark skill.
2+
# Read-only host probe for the run-api-benchmark skill.
33
# Detects an available container engine and the flags the benchmark run needs on
44
# this host, then prints a machine-parsable report + a human summary. It NEVER
55
# mutates the system (no install, no `colima start`, no alias) — installing an
Lines changed: 20 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,31 @@
11
---
22
name: run-benchmark
3-
description: >-
4-
Run this repository's problem-reductions bug-finding benchmark end to end and produce a
5-
submission.json. Supports reproducible Docker/Podman runs and lightweight local headless
6-
runs with codex exec or claude -p, including pinned repository preparation, explicit output
7-
and log paths, preflight where applicable, and optional upload. Use when asked to run,
8-
reproduce, smoke-test, or generate a model submission. Not for pytest/unit-test requests.
3+
description: Route a request to run, reproduce, smoke-test, or generate a submission for this problem-reductions benchmark. Use when the caller has not yet chosen between a model API run and an installed coding-agent CLI run. Ask the execution-route question, then hand off to run-api-benchmark or run-cli-benchmark; do not implement either backend flow here.
94
---
105

11-
# Run the benchmark
6+
# Route a benchmark run
127

13-
Run one whole-repository agent session. The agent chooses rules, search depth, and when to
14-
stop. Do not add a step, turn, cost, or rule-count limit. The evaluation-owned `submit`
15-
command is the only scored certificate channel; its run-wide attempt limit defaults to 100.
8+
Choose exactly one execution route before asking about models, credentials, paths, or
9+
submission settings.
1610

17-
First determine two choices if the user has not already supplied them:
11+
If the caller already explicitly requested an API, container, mini-swe, Codex, Claude Code,
12+
or another coding-agent CLI, do not ask the route question again. Invoke the matching child
13+
skill immediately.
1814

19-
1. Frontend: reproducible container, or lightweight local headless CLI.
20-
2. Goal: produce/test a local submission, or upload it to the official intake.
15+
Otherwise ask this question and wait:
2116

22-
Do not ask for intake secrets unless upload is requested. Before any real model run, show the
23-
resolved model, backend, target `PR_REF`, submit limit, output path, and log path; get explicit
24-
confirmation because the run can consume time and API credits.
17+
> How should the benchmark call the model?
18+
>
19+
> 1. **Model API** — use the containerized mini-swe/LiteLLM runner with an API key or custom
20+
> endpoint.
21+
> 2. **Coding-agent CLI** — use an installed autonomous coding agent such as Codex or Claude
22+
> Code.
2523
26-
## Common configuration
24+
Use the product's structured user-input UI when available; otherwise ask the same question
25+
in plain text. Do not combine both routes in one run.
2726

28-
Create `submission.env` from the template when absent. It is gitignored.
27+
- For **Model API**, invoke `$run-api-benchmark` and follow it completely.
28+
- For **Coding-agent CLI**, invoke `$run-cli-benchmark` and follow it completely.
2929

30-
```bash
31-
cp submission.env.example submission.env
32-
```
33-
34-
Set `MODEL_NAME` and the authentication required by the selected backend. Read
35-
`references/env-and-troubleshoot.md` when configuring a provider or diagnosing a failure.
36-
Do not add the removed `AGENT_MODE`, `MAX_RULES`, or max-turn settings.
37-
38-
## Container path
39-
40-
Use this for the reproducible benchmark. The image pins the problem-reductions source,
41-
compiled `pred`, Python dependencies, and mini-swe runtime.
42-
43-
1. Run `<skill-dir>/scripts/detect-engine.sh` and parse its `KEY=VALUE` output. Read
44-
`references/engines.md` only if no engine is available or the RAM hint is low.
45-
2. Build with one consistent ref:
46-
47-
```bash
48-
make runner-build PR_REF=v0.6.0
49-
```
50-
51-
For Podman, use the equivalent raw build shown in `references/engines.md`.
52-
3. For the default mini-swe backend, run `make preflight`. It checks `pred`, rule sources,
53-
and makes one tiny LiteLLM call. Do not describe this as a Codex/Claude CLI preflight.
54-
4. After user confirmation, run `make run` (or the equivalent Podman command using the
55-
detector's `RUN_FLAGS`).
56-
5. Confirm `out/submission.json` exists. Report `bugs_found`, `total_tokens_k`, submit attempts,
57-
and any `run_error`. Logs are also under `out/`; the configured submission path is the
58-
single authoritative JSON output.
59-
60-
An exit code 137 during build means the engine needs more memory. Never proceed after a
61-
failed preflight.
62-
63-
## Lightweight local headless path
64-
65-
Use this for an installed `codex exec` or `claude -p`. It reuses the same benchmark CLI,
66-
prompt, schema, verifier, and submit ledger as the container path.
67-
68-
Confirm these host prerequisites:
69-
70-
- `git` and the benchmark's Python dependencies;
71-
- a `pred` binary matching the target benchmark version;
72-
- `codex` authenticated (`codex login status`) or an authenticated Claude CLI.
73-
74-
Require all three paths explicitly and keep them separate:
75-
76-
- `LOCAL_REPO_DIR`: clone destination;
77-
- `LOCAL_OUTPUT`: authoritative submission JSON path;
78-
- `LOCAL_LOG_DIR`: agent logs (raw CLI stream for headless backends, normalized mini-swe log).
79-
80-
Run, for example:
81-
82-
```bash
83-
make run-local \
84-
PR_REF=v0.6.0 \
85-
LOCAL_BACKEND=codex \
86-
LOCAL_REPO_DIR=../runs/problem-reductions-v0.6.0 \
87-
LOCAL_OUTPUT=../runs/results/submission.json \
88-
LOCAL_LOG_DIR=../runs/logs
89-
```
90-
91-
Use `LOCAL_BACKEND=claude-code` for Claude. The default is Codex.
92-
93-
The runner clones `PR_REF` when `LOCAL_REPO_DIR` is absent. If it already exists, it must be
94-
a Git checkout whose `HEAD` exactly matches the requested tag, branch, or commit. The runner
95-
must not fetch, reset, or check out an existing working tree; on mismatch, use another path or
96-
ask the user to update it.
97-
98-
Every backend starts by probing the evaluation-owned file-backed submission channel with
99-
`submit --status`. A run with neither a successful status probe nor a ledger attempt is an
100-
infrastructure failure and must carry `run_error`; do not report it as a clean zero. On such
101-
a failure, check `LOCAL_LOG_DIR/salvaged-agent-artifacts/` for preserved certificates.
102-
103-
There is no local turn cap. `CODEX_SESSION_TIMEOUT` and `CLAUDE_CODE_SESSION_TIMEOUT` are only
104-
hung-process backstops. Codex token totals come from its JSON `turn.completed` event.
105-
106-
## No-spend wiring smoke test
107-
108-
Only use this when the user wants to test runner wiring without invoking a model or `pred`:
109-
110-
```bash
111-
python -m benchmark.run_submission \
112-
--fake --model fake/smoke \
113-
--repo-dir /tmp/prb-fake-repo \
114-
--output /tmp/prb-smoke/submission.json \
115-
--trajectory-dir /tmp/prb-smoke/logs
116-
python -m benchmark.submit --predictions /tmp/prb-smoke/submission.json --dry-run
117-
```
118-
119-
Clearly label this as a wiring check, not a benchmark result.
120-
121-
## Validate and optionally upload
122-
123-
Always validate the produced file before handoff or upload:
124-
125-
```bash
126-
python -m benchmark.submit --predictions <submission.json> --dry-run
127-
```
128-
129-
If the goal is local/test, stop after reporting the artifact paths. If the user explicitly
130-
requested official submission and supplied `PRB_SUBMIT_URL` plus `PRB_API_KEY`, upload with:
131-
132-
```bash
133-
python -m benchmark.submit --predictions <submission.json>
134-
# add --test to keep an end-to-end intake test off the public leaderboard
135-
```
136-
137-
Never upload merely because a run completed. The backend re-verifies accepted ledger
138-
certificates with `pred`; only aggregate results become public.
139-
140-
## Failure handling
141-
142-
- Read actual command output and branch on it; never assume build, auth, or run success.
143-
- Preserve a partial submission and logs when `run_error` is present; report it as partial,
144-
not as a clean zero-bug completion.
145-
- Treat `submit channel was not successfully probed` as runner infrastructure failure, not
146-
agent performance. Preserve the logs and salvaged certificate artifacts.
147-
- Do not silently install software, change engine settings, mutate an existing checkout, or
148-
upload data.
149-
- For provider fields and common failures, read `references/env-and-troubleshoot.md`.
150-
- For Docker/Podman setup, ownership, SELinux, or OOM issues, read `references/engines.md`.
30+
The child skill owns all later questions, preflight, execution, validation, and optional
31+
upload. Do not duplicate those workflows here.

0 commit comments

Comments
 (0)