Raven-1/benchmarks
LivXue ede8e7ed3c refactor(*): install the shipped sub-agents without a running raven
## Summary

Installing one of the sub-agents that ship under `subagents/` required a running
raven: each folder's `install.py` registered its entry through
`PUT /raven/subagents`, so both the web service and the gateway had to be up. On a
machine that has just cloned the repository, neither is.

The installer now writes `subagents.thirdParty` in the host raven's config
directly, through `raven.config.update_subagents` - the supported write path,
which validates the entry against the schema, replaces the entry sharing its name,
refuses a list that would hold duplicates, and replaces the file atomically. Hand-editing the JSON gets none of that, and a
half-written config is one raven will not start on. That module is importable only
from the host raven's environment, which is rarely the interpreter running the
installer, so it is reached in a subprocess resolved from the shebang of `raven`
on `PATH` (or `RAVEN_PYTHON`, or `--raven-python`). The installer therefore stays
standard-library only and runs under a bare `python3`.

What the file write costs is hot-apply: a running raven holds the roster it read
at startup, so the installer prints a restart instruction and the guide says the
same. `--endpoint` is gone; `--config` and `--raven-python` are new.

Two additions on top:

- `subagents/install.sh` does the whole install for every folder, or the ones
  named: builds each checkout's venv, scaffolds `.env` from its template, then
  registers. It refuses to register a folder whose api key is still blank, so a
  half-configured agent never reaches the roster, and exits non-zero while
  anything still needs attention. It discovers the checkout by its lone
  `pyproject.toml` and derives the key prefix from the folder name, so a new
  folder needs no edit in the script.
- `subagents/README.md` is the directory-level guide: what a folder is made of,
  the install steps, what the installer does and does not do, how to remove an
  agent, what a new folder has to satisfy, and what never gets committed.

`subagents/*` stays excluded by default. Only the folders that were already
tracked are whitelisted, plus those two new files by name; a folder holding a
docker image tar or a private checkout is unaffected. The change also drops a
sentence that pointed a published README at an unpublished sibling folder.

The pre-install backup is written before the config is touched, holds the list as
it sits on disk rather than a schema round-trip of it (loading coerces an `openai`
entry's `readsLocalFiles` away, so a validated copy would restore something the
user never wrote), and is at mode 600 because another entry among the others can
carry its own api key. A backup that cannot be written stops the install with the
config untouched, rather than going missing after a config that already changed.

`install.sh` reads the api key the way the launcher does, first non-empty match
wins, so the two cannot disagree about a `.env` that sets it twice. It expands its
argument array through `${args[@]+...}`, since an empty array under `set -u` is an
unbound-variable error before bash 4.4 - the stock `/bin/bash` on macOS. A relative
`--config` is made absolute at parse time, because `install.py` runs with each
folder as its cwd and would otherwise resolve the path once per folder.

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [x] Refactor
- [ ] Other

## Verification

The branch touches 12 files: `.gitignore` and 11 under `subagents/`. Nothing under
`raven/` or `tests/`, and `testpaths = ["tests"]`, so no unit test collects any of
it.

```
uv run pytest -q          8237 passed, 46 skipped, 13 deselected in 170s
uv run ruff check  --no-force-exclude subagents/raven-code/install.py   All checks passed
uv run ruff format --check --no-force-exclude subagents/raven-code/install.py   1 file already formatted
bash -n subagents/install.sh                              clean
python3 scripts/check_commit_messages.py origin/main..HEAD exit 0
python3 scripts/check_large_files.py origin/main..HEAD     exit 0
```

`subagents/` is excluded in `[tool.ruff] extend-exclude`, so the two ruff commands
above need `--no-force-exclude` to reach the file at all.

End-to-end on a freshly provisioned host with no `raven`, no `uv`, and Python 3.10:
cloned the repository, installed `uv`, built the venvs, ran the installer twice and
spawned one agent for real.

- Installer on a clean clone with no keys: three checkout venvs built, three `.env`
  files scaffolded at mode 600, stopped at the key gate for all three, exit 1. The
  host config's mtime was unchanged and no backup file was written, so nothing
  half-configured reached the roster.
- Same host with keys filled in: all three entries `replaced` in a config that
  already held 8 third-party sub-agents, and all 8 survived. Each backup was mode
  600 and held the full 8-entry list. `load_config()` then listed all 8, so the
  written entry is valid to the runtime and not only to the writer.
- The resolved `command` of each entry pointed at the clone's own path, confirming
  the placeholders resolve against the installer's location rather than the machine
  that built the folder.
- One real spawn answered correctly in 22s.
- Before that, on a machine with no `raven` on `PATH`, the installer reported
  `no raven on PATH; pass --raven-python ...` and recorded the folder as failed.

Probes for the fixed defects: a config seeded with `readsLocalFiles: true`
on disk produced a backup recording `false` before the fix and `true` after; a
`.env` setting the key twice with an empty second line made the shell installer
refuse an agent the launcher would run, and both now agree; an interpreter stub
printing non-JSON now yields `cannot read the writer's output` instead of a
traceback; a `--config` whose parent is a regular file makes the config write fail
with the backup already on disk, which is what shows the backup precedes it; and a
run with no flags at all registers against a scratch `HOME`, which is the path the
empty-array expansion used to break on bash before 4.4.

Proving the backup ordering took two attempts. Making the folder unwritable with
`chmod 555` proved nothing, because this runs as root and root ignores mode bits -
a trap the repository's own skipped test records. The failing-config probe above is
the one that holds.

- [ ] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [x] User-facing docs or screenshots are updated when needed

The first box is deliberately unchecked: there is no unit test covering this tree,
because pytest does not collect it. The end-to-end run above is the evidence
offered in its place. The unit suite was run anyway, on the rebased tree, and
reported no failures at all - so there are no failing ids to diff against the
target branch.

## Risk

**Behaviour change.** An install no longer takes effect immediately. Anyone
following the old flow will see the agent appear only after raven or the gateway
restarts; the installer's last line and the guide both say so. `--endpoint` no
longer exists, so a caller passing it gets an argparse error rather than a silent
fallback.

**Not reproduced, environment-dependent.** On the test host, the provider's model
listing answered 200 while inference answered
`403 This model is not available in your region.`, which the launcher reports as a
run that exits 0 having committed no answer - it reads like a launcher bug and is
not one. Exporting the site proxy fixed it, and the guide now records both that and
the fact that a missing EverOS degrades rather than fails.

**Security.** The pre-write backup can contain another entry's api key, so it is
written at mode 600 and is covered by the existing ignore rules. Keys stay in each
folder's `.env` at mode 600; the tracked `config.json` files hold none. The
installer no longer sends the entry list over a loopback HTTP service.

**Rollback.** Revert the commit: the previous installer talked to the RPC and needs
nothing else restored. Entries already written stay valid either way, since the
schema did not change.

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

## Related Issues

N/A
2026-08-18 09:07:22 +00:00
..

Raven Benchmarks

This directory holds evaluation harnesses that are deliberately decoupled from the runtime package. They are not imported by raven/ and are excluded from the wheel build — keep it that way.

Use this area for reproducible evaluation work: capability suites, agent comparisons, context stress tests, and proactivity runs that should not ship as part of the end-user CLI package.

Layout

benchmarks/
├── appworld/           AppWorld agent benchmark + evolver plugin
│   ├── agent_cli.py       One-task subject agent (drives AgentLoop)
│   ├── batch.py           Batch scorer: N tasks x K trials, resumable
│   └── evolve/            raven.evolver BenchBundle plugin (entry.py)
│                          + designer/diagnosis/sandbox/precheck glue
│
├── pinchbench/         Context / AgentLoop capability benchmark
│   ├── tasks/             23 task_*.md cards (YAML frontmatter + sections)
│   ├── direct/            Drives AgentLoop.process_direct() per task
│   ├── bot_runner/        Drives full gateway + channel path per task
│   ├── assets/            Task-specific workspace files
│   └── results/           Run outputs (gitignored)
│
├── clawbench/          ClawBench streaming benchmark adapter
│   ├── stream.py          Drives AgentLoop.process_direct() across one session
│   ├── run.sh             Shell wrapper
│   └── README.md          Setup and run instructions
│
├── proactivity_eval/   Sentinel / Proactive Engine benchmark
│   ├── data/              5 sub-benchmarks: cases / pbench / longrun /
│   │                      simulation / timeline + reward_data
│   └── runners/           run.py (unified entry) + judge.py +
│                          *_scorecard.py + per-agent adapters
│
└── README.md           This file

skill_evals/ will land here in Phase 1 once raven/skill_forge/evals/ is folded into memory_engine/skill/.

Running

Model and tool configuration

The benchmark runners can use the normal ~/.raven/config.json, or the environment overrides below. Never commit real keys.

For an OpenAI-compatible gateway using OpenRouter-style environment names:

export OPENROUTER_API_KEY="..."
export OPENROUTER_API_BASE="https://openrouter.ai/api/v1"
export RAVEN_BENCH_PROVIDER="custom"
export RAVEN_BENCH_MODEL="deepseek-v4-flash"

Optional web tools:

export SERPER_API_KEY="..."
export JINA_API_KEY="..."

Equivalent ~/.raven/config.json:

{
  "agents": {
    "defaults": {
      "provider": "custom",
      "model": "deepseek-v4-flash",
      "maxToolIterations": 40,
      "contextWindowTokens": 65536
    }
  },
  "providers": {
    "custom": {
      "apiKey": "YOUR_API_KEY",
      "apiBase": "YOUR_OPENAI_COMPATIBLE_API_BASE"
    }
  },
  "tools": {
    "web": {
      "jinaApiKey": "YOUR_JINA_KEY",
      "search": {
        "apiKey": "YOUR_SERPER_KEY"
      }
    }
  }
}

PinchBench (Direct mode):

./benchmarks/pinchbench/direct/run.sh \
    --model deepseek-v4-flash \
    --provider custom \
    --api-base "$OPENROUTER_API_BASE" \
    --api-key "$OPENROUTER_API_KEY" \
    --suite task_00_sanity

PinchBench (Bot mode):

./benchmarks/pinchbench/bot_runner/run.sh --suite automated-only

ClawBench (first 80 tasks, one streaming session):

git clone https://github.com/claw-bench/claw-bench ../claw-bench
export CLAW_BENCH_ROOT="$PWD/../claw-bench"

./benchmarks/clawbench/run.sh \
    --clawbench-root "$CLAW_BENCH_ROOT" \
    --limit 80 \
    --session-id clawbench-stream-raven-80 \
    --max-iterations 40

ClawBench with Curator context engine:

./benchmarks/clawbench/run.sh \
    --clawbench-root "$CLAW_BENCH_ROOT" \
    --limit 80 \
    --session-id clawbench-stream-raven-curator-80 \
    --context-engine curator \
    --curator-model deepseek-v4-flash \
    --max-iterations 40

Proactivity Eval (longrun, 30-day persona):

uv run python benchmarks/proactivity_eval/runners/run.py \
    --agent raven --mode sentinel --benchmark longrun \
    --persona dev-01

Relation to runtime

The runtime (raven/) never statically imports from benchmarks/ — this is the "independent eval track" principle. The reverse is allowed and expected: benchmarks import raven.agent, raven.providers, etc. directly.

One scoped exception: raven.evolver loads its bench plugins from here by registry name at launch (benchmarks.appworld.evolve.entry:build), inserting the subject repo root on sys.path first. It is lazy, opt-in, and only works from a repo checkout — evolution needs the git repo as its subject anyway, so nothing in the installed wheel depends on this directory.

Two unit tests under tests/ reach into benchmarks/proactivity_eval/runners/ via sys.path injection because they exercise the synthesizer / prompt-loader code that lives there (it is benchmark code, not runtime code, and there is no production substitute to test against).