AutoResearch is AnySwarm’s flagship end-to-end application. It demonstrates how all six SDK building blocks fit together to run a long-horizon, self-improving coding team without trusting any Agent’s self-reported score.
The problem it solves: You have a codebase, an optimization or correctness goal, a finite time/evaluation budget, and a trusted evaluator. You want multiple autonomous coding peers to explore competing ideas in parallel, review one another’s patches, and let the host objectively score frozen candidates and export the winner.
Explore the live 1-hour four-peer Trace replay ↗
About this demo: AutoResearch here is designed as a quick-to-try, small-scale experiment showing how the SDK primitives fit together end to end. In a 1-hour four-peer demo run using GPT-6.1 Sol on the FrontierCS-2 (
binary_fuse_filter) benchmark, peers iterated from stub implementations through competing patches and peer reviews to reach 53.07 (strict PASS) on the independent host-controlled final evaluator. This is a lightweight workflow demo — it is not a formal benchmark evaluation and does not represent the absolute capability of any underlying model.
The four-stage research loop
1. Spawn Isolated Peers ──▶ N equal peers boot in separate OpenSandbox containers
with private copies of the target codebase
│
▼
2. Propose & Peer-Review ──▶ Peers edit code locally, share directions & findings,
submit candidate patches, and review peers' patches
through the host ResearchService
│
▼
3. Host Freeze & Evaluate ──▶ Host snapshots & hashes each submitted patch,
enforces budget limits, and runs the trusted
Evaluator outside the peer sandboxes
│
▼
4. Archive & Export Winner ──▶ On budget/time end, host runs independent final
evaluation and Stop → Export → Delete archives
every patch, review, score, and swimlane trace
How AutoResearch connects all six SDK building blocks
1. Sandboxes & Profiles — isolated equal peers
Each peer gets its own container (createSandbox) and private working copy of the target project, so two peers exploring incompatible refactors never clobber each other’s files or build caches.
All peers share the same role Profile: writable local workspace, bounded CPU/memory limits, and permission to call only the research Service operations:
profiles: {
peer: {
model: 'research',
image: config.image,
writable: true,
services: {
research: ['board', 'claim', 'publish', 'message', 'submit_candidate', 'read_candidate'],
},
addedSystemPrompt: buildPeerInstructions(config.goal, config.direction),
},
}
2. Services — shared research board & anti-cheating identity
Instead of ad-hoc peer-to-peer chat, all collaboration flows through one host-owned inProcessService (research-service.ts). Its interface defines every legal action with strict JSON Schema validation:
const researchInterface: ServiceInterface = {
description: 'Shared research directions, peer reviews, candidate patches, and trusted scores.',
operations: {
board: { sideEffect: 'read', description: 'Read directions, candidates, reviews, and scores.' },
claim: { inputSchema: directionSchema, idempotent: true },
publish: { inputSchema: findingOrReviewSchema, idempotent: true },
message: { inputSchema: peerMessageSchema, idempotent: true },
submit_candidate: { inputSchema: candidateSchema, idempotent: true },
read_candidate: { sideEffect: 'read', inputSchema: candidateIdSchema },
},
};
Because Host Gateway injects an unforgeable caller.agentId on every request, the Service guarantees:
- Candidate authorship (
candidate.agentId) and SHA-256 patch hash are recorded by the host, never self-declared. - Peer reviews are tied to the real reviewing peer, preventing self-endorsement.
- Evaluation admission counts against the host’s
ResearchBudget(maxEvaluations,workMs,maxModelRequests).
3. Host Gateway & Trusted Evaluator — why peers cannot game scores
Model API keys stay strictly on the host inside Host Gateway. Equally important, the evaluation code never runs inside a peer’s writable sandbox:
export interface Evaluator {
// Fast feedback loop called when a peer submits a frozen candidate patch
train(candidate: Buffer, signal: AbortSignal, admitted: (ref: string | number) => void): Promise<Evaluation>;
// Independent final check run once on the selected best candidate
final(candidate: Buffer, signal: AbortSignal): Promise<FinalEvaluation | JsonValue>;
}
When a peer calls submit_candidate, the host extracts .anyswarm-candidate.patch via runtime.files.snapshot(), computes its SHA-256 digest, freezes the exact bytes, and passes that Buffer to evaluator.train(). The resulting score is attached to that candidate hash on the shared board so all peers can read the real feedback and iterate.
4. Runtime — finite budget, live coordination, and crash-safe close
createRuntime() manages all peer sandboxes concurrently under a single control plane:
- Peers run in parallel inside the configured
workMswindow. - When a peer finishes a turn or when
runtime.onEvent()observes a new score or peer message, the Harness wakes or steers peers as needed without busy-polling. - When the time or evaluation budget expires, the Harness runs
evaluator.final()on the top candidate and callsruntime.close()(Stop → Export → Delete), preserving every candidate patch, review ledger, and session archive even if a container timed out.
5. Trace Viewer — auditing the full lineage
Open any completed or live AutoResearch run in anyswarm trace --root ./runs:
- Start at Independent final to inspect the winning score and exact patch SHA-256.
- Trace backwards through
researchService calls to see which peer authored the patch, which parent candidate it derived from (basedOn), and which peer reviews influenced it. - Open Files & Results to inspect candidate diffs, checksums, and cleanup receipts separately from model scores.
Try AutoResearch on your own project
Quick local mode (ordinary model + lightweight Python evaluator)
You do not need heavy benchmark containers to run AutoResearch. On macOS or Linux, eject the template and wire up any local directory plus a fast scoring script (eval.py or shell script):
anyswarm eject autoresearch --dir ./research-local
cd ./research-local
npm install
export ANYSWARM_MODEL_URL='https://api.openai.com/v1/responses'
export ANYSWARM_MODEL_ID='gpt-5-mini'
export ANYSWARM_MODEL_TOKEN='<your-api-key>'
In config.ts, set:
targetPath: the local directory peers should optimizegoalanddirection('max'or'min')budget:{ workers: 2, workMs: 10 * 60_000, maxEvaluations: 6 }evaluator:{ train, final }callbacks that apply the frozen patch in a clean temp directory and return{ valid, score, feedback }
Run the experiment and inspect it in the browser:
npm start -- --config ./config.ts --output-dir ./runs
anyswarm trace --root ./runs --port 8787
Advanced: Official FrontierCS-2 benchmark
The ejected template also includes a prepared FrontierCS-2 (binary_fuse_filter) configuration for Linux x86-64 hosts with Git LFS, Python 3, Docker Buildx, and an OpenSandbox deployment with dns+nft egress:
anyswarm eject autoresearch --dir ./research-demo
cd ./research-demo
npm install
# Check host prerequisites without spending model tokens
npm exec -- anyswarm run ./prepare-demo.ts --config ./frontiercs2-config.ts --check
# Build official judge images and verify no-model baseline
npm exec -- anyswarm run ./prepare-demo.ts --config ./frontiercs2-config.ts
# Start the research run
npm run start -- --config ./frontiercs2-config.ts \
--prompt 'Run the FrontierCS-2 task.' --output-dir ./runs
See the AutoResearch example README for detailed evaluator callbacks and resource tuning.
Next: ready to design a custom Harness for your own workflow? Read How to Design a Harness.