Skip to content
项目

关于

Open Source Reimplementation of Google Deepmind's Co-Scientist

开发工具

这些数字如何统计

实测星标增长

24小时
0
7天
+4
15天
+5
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

AI co-scientist

An open source re-implementation of Google's AI co-scientist (Gottweis et al., Nature, 2026; research blog, 2025) — a multi-agent system that takes a natural-language research goal and produces a tournament-ranked research overview of novel hypotheses.

It runs on an LLM API key or on your Claude Code / Codex subscription. The default routes everything through OpenRouter, so one key reaches 200+ models from every vendor and [models] can mix them per agent. You can also point [llm] provider at Anthropic, OpenAI, or Gemini directly, or at a local claude -p / codex exec CLI that authenticates with its own OAuth login and bills nothing per token. Under the CLI backends, structured output and citation provenance come back through a bundled MCP server. Either way the agents are identical — see LLM backend.

The agent roster, prompts, and control flow follow the paper, except where marked "designed, not yet wired" below. Source materials that were used to instruct the coding agent (mainly Claude Code) include:

  • reference/8 Pseudocode of Co-Scientist agents: the supplementary pseudocode for Supervisor, Generation, Reflection, Ranking, Evolution, Proximity, Meta-review.
  • reference/9 Prompts for the specialized agents in .md: the per-agent prompts from the paper's supplement, used verbatim (modulo Jinja interpolation) in co_scientist/resources/prompts/.
  • reference/AICoScientist-*.png: the architecture and component diagrams from the paper.

The reference/ directory is gitignored, so a fresh clone does not contain these files.

The agents:

  • Generation: proposes hypotheses via tool-driven literature review. The paper's simulated scientific debate (generation.debate) is designed, not yet wired. Its prompt template exists, but the agent raises NotImplementedError for any strategy other than literature.
  • Reflection: reviews hypotheses for novelty, correctness, and testability (the full review). Deep verification of the underlying assumptions (reflection.verification) and the observation review are designed, not yet wired. Their prompt templates exist, but the Supervisor never schedules them and the agent raises NotImplementedError for any kind other than full.
  • Ranking: runs an Elo tournament with simulated debates between hypotheses.
  • Evolution: combines, simplifies, or out-of-box-reimagines top-ranked hypotheses. A feasibility rewrite is implemented in the agent, but the Supervisor never schedules it.
  • Proximity: embeds and clusters hypotheses to drive dedup and informative tournament pairings.
  • Meta-review: synthesizes system-wide feedback and the final research overview.

A Supervisor parses the goal into a research plan and schedules agent tasks through a durable SQLite-backed queue with bounded concurrency.

This is an independent re-implementation in Python on top of pluggable LLM provider SDKs — not affiliated with Google or the paper's authors.

docs/BENCH_RESULTS.md — every cross-model bench ever run on this code, with per-candidate Elo, every hypothesis produced, gold-set hits, and direct file pointers. Auto-generated from the bench DB.

Contents

Architecture

                       co-scientist run "<goal>"
                                  │
                                  ▼
            ┌──────────────────────────────────────┐
            │            Supervisor                │  durable task queue (SQLite)
            │  • parse_goal → ResearchPlan         │  bounded concurrency
            │  • enqueue initial Generation tasks  │  lease + dead-letter + resume
            │  • main loop: claim → run → follow-up│  termination: BUDGET / WALL_CLOCK
            │  • decide_next_steps when idle       │              / ELO_STABLE / IDLE / EXTERNAL
            │  • finalize: meta-review overview    │
            └──────────────────────────────────────┘
                                  │  tasks
            ┌─────────────────────┼─────────────────────────────┐
            ▼                     ▼                             ▼
   ┌──────────────┐      ┌──────────────┐              ┌──────────────┐
   │  Generation  │ hyp  │  Reflection  │ review       │   Ranking    │
   │  literature  │─────►│  full        │─────────────►│ pairwise vs  │──► Elo
   │  (+ debate*) │      │ (+ verify.*) │              │   debate     │
   └──────────────┘      └──────────────┘              └──────────────┘
            ▲                     ▲                             │
            │                     │ informative pairings        ▼
   ┌──────────────┐      ┌──────────────┐              ┌──────────────┐
   │  Evolution   │◄─────│ Meta-review  │              │  Proximity   │
   │ combine /    │ feed │ system fdbk  │              │ FAISS embed  │
   │ simplify /   │ back │ + final      │              │ + cluster /  │
   │ feasibility*/│      │ overview     │              │ dedup        │
   │ out_of_box   │      └──────────────┘              └──────────────┘
   └──────────────┘
            │
            ▼
       new hypotheses re-enter the cycle

   * Designed, not yet wired: Generation debate, Reflection verification and
     observation. Their prompts exist, but the agents raise NotImplementedError.
     Evolution feasibility is implemented, but the Supervisor never schedules it.


  Shared infrastructure
  ─────────────────────
  • LLMProvider  ─ metered API (anthropic / openai / any OpenAI-compatible)
                   or subscription CLI (claude_cli `claude -p`,
                   codex_cli `codex exec`) over OAuth, no key
  • ToolRegistry ─ web_fetch + pubmed_search / arxiv_search / europe_pmc_search;
                   web_search auto-registered iff TAVILY/BRAVE key set;
                   science-skills discovered via SKILL.md frontmatter
  • MCP server   ─ record_* schemas + research tools served to the CLI backends;
                   captures structured output and URL provenance
  • TokenBudget  ─ per-agent shares + global cap; reservation released on retry
  • EventBus     ─ in-memory fan-out to SSE for the live web UI
  • FaissStore   ─ IndexFlatIP per session, asyncio-locked, atomic save/load;
                   Voyage → OpenAI → hash fallback, rebuilt on a dim change
  • SQLite       ─ sessions / hypotheses / reviews / tournament_matches /
                   elo_journal / tasks / transcripts / system_feedback /
                   embeddings_meta / spans / events / bench_* (15 tables;
                   WAL, busy_timeout, idempotent migration runner)

Install

# Recommended: Python 3.11–3.13 (FAISS wheel availability)
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

cp .env.example .env
# Add the API key for your chosen provider — or none at all if you plan to run
# on a subscription CLI. See "LLM backend" below.

Then pick one of the two backend families. Either an API key for the provider you want:

export OPENROUTER_API_KEY=...      # provider = "openrouter" (the default)
# or, to talk to one vendor directly:
export ANTHROPIC_API_KEY=...       # provider = "anthropic"
export OPENAI_API_KEY=...          # provider = "openai"
export ATLASCLOUD_API_KEY=...      # provider = "atlas"
export GEMINI_API_KEY=...          # provider = "gemini"

Each provider reads only its own key. A key exported for another tool, such as OPENAI_API_KEY, is never sent to a different vendor.

…or a subscription CLI installed and signed in, with no key at all:

claude          # Claude Code — complete the subscription login once, then quit
# or
codex login     # Codex — sign in with your ChatGPT account

Initialize

co-scientist init
co-scientist list

init creates data/ (artifacts and vectors) and applies migrations to data/co_scientist.db. The output prints which backend it found and whether it is usable: a resolvable API key for an API provider, or the CLI's version and login state for a subscription backend. Application logs are JSONL on stderr, so stdout carries only what a command prints; there is no per-session log file. To keep them, redirect it: co-scientist run "..." 2> run.jsonl.

co-scientist doctor    # backend readiness + MCP handshake, no model call

Run a research session

co-scientist run "Identify hypotheses about microbiome-driven inflammation" \
  --n 3 --budget-usd 2.0 --wall-clock 600

This kicks off Generation → Reflection → Ranking → Evolution → Meta-review under the configured backend. The Supervisor schedules tasks, the Elo tournament refines a leaderboard, and the final research overview is written to data/artifacts/<session_id>/final/overview.md.

co-scientist serve            # FastAPI + htmx + SSE dashboard at localhost:7878
co-scientist report <id>      # print the final overview
co-scientist status <id>      # session metadata + counts
co-scientist pause <id> | resume <id> | abort <id>
co-scientist feedback <id> "focus on metabolic pathways" --kind directive
co-scientist doctor           # verify backend readiness and the MCP server
co-scientist estimate         # pre-flight equivalent-cost estimate
co-scientist eval [agent]     # run the rubric eval bundle (offline mode optional)
co-scientist tools list       # show every registered tool the agents can call

pause lets the running process finish the tasks it has started and then wait. abort cancels the tasks in flight and ends the run, and the session keeps the aborted status. Both leave a finished session as it is: pause applies to a running session and abort to a running or paused one, in the dashboard as on the command line. The dashboard shows only the buttons that apply to the session's status. resume picks a session up again, whatever stopped it: a pause, an abort, a crash, or a run that reached its wall-clock or budget limit. It takes the session back from a run that is gone, requeues the tasks that stop cancelled or left half done, and gives the run a fresh wall clock. The spend limits still apply to the whole session. Only one process runs a session at a time. If another process still has it, resume unpauses a paused session (that process carries on) and refuses any other. The fence is an flock on a file under locks/ in the data directory. Where there is no flock (Windows, some network file systems) a run starts without it and logs session_lock_unavailable, so do not resume a session that may still be running.

The dashboard has no login, so it only answers requests addressed to localhost, to an IP address, or to the host name it was started with (--host). It also refuses form posts that come from another site, and every response forbids being shown inside another site's frame. A reverse proxy or tunnel that presents a different name gets a 403.

LLM backend

Two families of backend serve the same agents, selected with [llm] provider:

Family provider values Billing Needs
Metered API openrouter (default), anthropic, atlas, openai, gemini/google, groq, together, mistral, ollama, openai_compatible per token an API key
Subscription CLI claude_cli, codex_cli included in a subscription you already pay for the CLI installed and signed in

They are fully interchangeable from the agents' point of view — the same six agents, the same tools, the same structured-output contract. What differs is who runs the tool-use loop, and whether tokens cost money. [models] is interpreted by whichever family you pick, so switching usually means revisiting it.

Metered API providers

Every agent talks to one provider per session. openrouter is the default because one key reaches every vendor's catalog, which is also the only way to give different agents different vendors in a single session. Any of the providers below works; pick whichever you have a key for.

Config is deep-merged over co_scientist/resources/default.toml, whose [models] defaults are OpenRouter ids (anthropic/claude-opus-4-7 and friends). So if you switch provider away from openrouter, override every key in [models]: any key you leave out keeps its OpenRouter default and will be sent to your new provider, which will reject it. co-scientist doctor and every run warn about ids that look like they belong to another provider, so you find out in preflight rather than at the first model call. Fill in model ids your chosen provider exposes (see the provider table below for examples per vendor):

[llm]
# Pick one. See the provider table below.
provider = "openai"   # openrouter | anthropic | atlas | openai | gemini | google | groq | together | mistral | ollama | openai_compatible

[models]
# Override ALL of these with model ids from your chosen provider.
# (Two tiers are enough: a stronger model for reasoning-heavy agents and a
#  cheaper one for the rest — set them to whatever your provider offers.)
parse_goal          = "<cheap-model>"
generation          = "<strong-model>"
reflection          = "<strong-model>"
evolution           = "<strong-model>"
ranking_pairwise    = "<cheap-model>"
ranking_debate      = "<strong-model>"
ranking_priority    = "<strong-model>"
metareview_feedback = "<cheap-model>"
metareview_final    = "<strong-model>"
classifier          = "<cheap-model>"
judge               = "<cheap-model>"

Providers are listed alphabetically. openrouter is the default, but nothing else about the system prefers it; pick whichever you have a key for.

provider Endpoint API-key env var Example models
anthropic api.anthropic.com ANTHROPIC_API_KEY claude-opus-4-7, claude-sonnet-4-6
atlas api.atlascloud.ai/v1 (OpenAI-compat) ATLASCLOUD_API_KEY anthropic/claude-sonnet-4.6, openai/gpt-5.4
gemini / google generativelanguage.googleapis.com (OpenAI-compat) GEMINI_API_KEY gemini-3-pro, gemini-3-flash, gemini-2.5-pro
groq api.groq.com GROQ_API_KEY llama-3.3-70b-versatile, mixtral-8x7b-32768
mistral api.mistral.ai MISTRAL_API_KEY mistral-large-latest, codestral-latest
ollama localhost:11434 — local models (none) llama3.3:70b, qwen2.5:32b
openai api.openai.com OPENAI_API_KEY gpt-5, gpt-4o, o3-mini
openai_compatible Anything else; set [llm.openai] base_url explicitly OPENAI_API_KEY (optional) depends
openrouter (default) openrouter.ai — 200+ models from every major vendor OPENROUTER_API_KEY openai/gpt-5, google/gemini-2.5-pro, anthropic/claude-3.5-sonnet, meta-llama/llama-3.3-70b-instruct
together api.together.xyz TOGETHER_API_KEY meta-llama/Llama-3.3-70B-Instruct-Turbo

Each provider reads only the key in its own row. OPENAI_API_KEY and OPENAI_BASE_URL apply to openai and openai_compatible only, so a stray OPENAI_API_KEY is never sent to a preset's endpoint (it still feeds OpenAI embeddings). An explicit [llm.openai] base_url overrides the endpoint of every row except anthropic, and that row's own key is then sent to it (a private mirror, say). Leave it unset when you switch providers: the log names the host a preset's key is going to when it is overridden. To reach another OpenAI-compatible server with a key you keep in OPENAI_API_KEY, use provider = "openai_compatible" and set [llm.openai] base_url. openai_compatible needs that endpoint (or OPENAI_BASE_URL, in the environment or in .env) and no key, and co-scientist doctor says so when it has none. With a key and no endpoint it would send the key to api.openai.com, which is what provider = "openai" is for.

Gemini thinking and tool calls

Gemini 3 models attach an opaque thought signature to function calls. The OpenAI-compatible adapter preserves provider-owned tool-call metadata, but only the named gemini / google providers replay Gemini's documented extra_content envelope with the corresponding function result. Other response-only tool-call fields are retained for diagnostics and future provider adapters, but are not sent to endpoints that may reject them. No manual signature configuration is required.

Gemini's thinking level is also optional. With thinking_level = "default" the request omits reasoning_effort and Gemini uses the selected model's default. For this system's autonomous, multi-step literature and evaluation work, medium is a sensible starting point:

[llm]
provider = "gemini"

[llm.gemini]
thinking_level = "medium"  # default | minimal | low | medium | high

[llm.gemini.thinking_by_mode]
"parse_goal" = "minimal"
"reflection.full" = "high"
"metareview.final" = "high"

Per-mode entries override the global level and use the same agent.mode names as model routing. These semantic levels are separate from the numeric Anthropic [thinking] token budgets. Do not fabricate or edit thought signatures; the adapter treats them as provider-owned continuation state.

Every other provider talks to exactly one vendor. For multi-vendor routing inside a single session, stay on the default provider = "openrouter" and let it dispatch upstream per model:

[llm]
provider = "openrouter"
[llm.openrouter]
referer = "https://your-app.example.com"   # optional, for catalog attribution
title   = "My Co-Scientist"

[models]
generation         = "openai/gpt-5"
reflection         = "anthropic/claude-3.5-sonnet"
ranking_pairwise   = "google/gemini-2.5-flash"
metareview_final   = "meta-llama/llama-3.3-70b-instruct"

Any per-agent model can point at any vendor — the example above just mixes four. Use whatever combination you prefer.

Cost is estimated via co_scientist/llm/routing.py's PRICE_TABLE; unknown models match a family-hint (flash / mini / opus / sonnet / gemini / llama / mistral) so brand-new previews price sensibly. Tighten [run] budget_usd if running on a new model you haven't sanity-checked.

Provider feature support. Tool / function calling is required — the agent pipeline is built on it, so a provider (or openai_compatible endpoint) that can't do function calling won't work. The other three rows are optional vendor-specific accelerators: when a provider doesn't support one, it's transparently skipped, never an error.

Feature anthropic everything else (OpenAI + all OpenAI-compatible providers)
Tool / function call (required) ✅ ✅ native OpenAI; on other endpoints it must be supported or the run fails
Extended reasoning ✅ [thinking] budgets: a token budget on models before 4.6, an effort tier on newer ones ✅ OpenAI reasoning models use reasoning_effort; Gemini uses optional [llm.gemini] semantic levels
Prompt-cache breakpoints ✅ ❌ (stripped before sending)

There is no Batch API support: every tournament match runs synchronously, on every provider.

For direct OpenAI and generic OpenAI-compatible endpoints, the reasoning-model check is a name heuristic (openai_client.py _is_reasoning_model). Model ids that do not match it still work, but do not receive a numeric [thinking] budget translated to reasoning_effort. The named Gemini provider uses its explicit semantic configuration instead.

Subscription CLI backends

These execute every agent call through a local agent CLI running on a subscription you already pay for. No API key is involved:

[llm] provider Drives Auth [models] values
claude_cli claude -p (Claude Code 2.1.323 or newer) OAuth login — run claude once full ids (claude-opus-4-7) or aliases (opus, sonnet, haiku)
codex_cli codex exec (Codex) codex login (ChatGPT account) Codex model ids your account is entitled to
[llm]
provider = "claude_cli"

[llm.claude_cli]
binary = "claude"
timeout_seconds = 900
max_parallel = 3          # bounded by the subscription rate limit, not CPU
replace_system_prompt = true

[models]
# Replace ALL of them. A key left out keeps its OpenRouter default
# ("anthropic/claude-opus-4-7"), which `claude --model` does not accept, and
# `co-scientist doctor` flags it. Full ids or the aliases "opus" / "sonnet" /
# "haiku" both work, as long as there is no vendor prefix.
parse_goal          = "claude-sonnet-4-6"
generation          = "claude-opus-4-7"
reflection          = "claude-opus-4-7"
evolution           = "claude-opus-4-7"
ranking_pairwise    = "claude-sonnet-4-6"
ranking_debate      = "claude-sonnet-4-6"
ranking_priority    = "claude-opus-4-7"
metareview_feedback = "claude-sonnet-4-6"
metareview_final    = "claude-opus-4-7"
classifier          = "claude-haiku-4-5-20251001"
judge               = "claude-sonnet-4-6"

Every ANTHROPIC_*, OPENAI_* and CLAUDE_CODE_USE_* variable in your environment, plus CODEX_API_KEY, CODEX_ACCESS_TOKEN and AWS_BEARER_TOKEN_BEDROCK, is stripped from the CLI subprocess (cli_backend/base.py BILLING_ENV_VARS and BILLING_ENV_PREFIXES). That covers API keys, custom endpoints, and the Bedrock, Vertex, Foundry, Mantle and gateway switches, so an exported credential cannot silently route a call to metered billing. CLAUDE_CODE_OAUTH_TOKEN, the subscription token, is kept. A test asserts this.

Every claude call also runs with --setting-sources project, --strict-mcp-config and --no-session-persistence, in its own empty working directory. Your own Claude Code hooks, MCP servers (the claude.ai connectors included), skills and CLAUDE.md stay out of the research prompts, so a benchmark runs the same call on every machine and your personal instructions are not sent to the model. Nothing is added to your claude --resume list. On one machine with 33 connector servers and three hooks, a one-word call with no tools read 66,109 input tokens without these flags and 647 with them, and a call with the four tool schemas of a generation task read 5,917 without and 2,617 with. --safe-mode is not used: it also disables the --mcp-config server the record tools live in. These flags are checked against Claude Code 2.1.323 and newer, and doctor and run refuse an older release.

How structured output survives without an API

The agents depend on forced tool use (record_hypothesis, record_review, …), and headless CLIs have no tool_choice flag. The project ships its own MCP server (co_scientist/mcp/) that the backend launches per call and wires in via --mcp-config:

  • record_* tools — the schemas from agents/schemas.py verbatim, validated at the tool boundary exactly as the API used to validate them, then written to a capture directory the backend reads back.
  • research tools — the existing PubMed / arXiv / Europe PMC / web_fetch registry, with every result's URLs appended to a provenance log. That is what keeps the citation verifier's "you may only cite what you actually saw" rule enforceable.

The server runs in the directory you ran co-scientist from, whichever directory the CLI runs the call in (a claude call runs in an empty one). It reads the .env and co-scientist.toml there, but not a --config file. If that directory has been deleted, or its name is not valid UTF-8, the server is not told about it and stays where the CLI started it: for claude that is the empty directory, so it finds neither file. web_search is offered only when a search key is found. Claude Code passes your shell environment to the server and codex does not, so with the codex backend keep search keys in .env. The server is started as python -P -m co_scientist.mcp.server, so the package has to be installed (pip install -e . in a checkout): it is not found in the directory you run from.

--tools "" disables the CLI's built-in tools so every tool call flows through that server and lands in your transcripts.

Things worth knowing

  • The CLI runs its own agentic loop. Under these backends run_tool_loop does not drive turns; it issues one call and reads the capture. If a call ends without a structured record, it retries once with the search tools removed and the record demanded, then raises. Under an API provider the same function drives the classic assistant↔tool_use↔tool_result cycle — the switch is the backend's runs_own_loop flag.
  • --system-prompt replaces Claude Code's default prompt. Measured on this machine: a trivial call under the default prompt costs ~19k cache-creation + ~24k cache-read tokens of harness scaffolding; with ours it is ~1–2k. Set replace_system_prompt = false if you want the harness context back.
  • --bare is unusable here — it forces ANTHROPIC_API_KEY auth and never reads OAuth, which defeats the point.
  • Rate limits are hours, not minutes. Subscription limits clear over a multi-hour window, so rate-limit backoff starts at 30s and grows to 10min (llm/retry.py) instead of the seconds an API 429 deserves.
  • budget_usd is not a spend gate here. Nothing is billed per token under a subscription. The CLI reports an equivalent API cost per call and budget_usd caps that gauge, which still catches a runaway session. The real limit is wall_clock_seconds. A run creates no new hypothesis once it holds max_ideas, and goes on ranking the ones it has. max_matches_per_idea only sizes what co-scientist estimate assumes. Under an API provider budget_usd is real money again.
  • Codex model entitlement is a real gate. A ChatGPT account that is not entitled to the model you name fails the run with "model is not supported when using Codex with a ChatGPT account". Check with co-scientist doctor before a long run.
  • codex_cli runs on a ChatGPT login only. co-scientist doctor reports a Codex signed in with an API key, an access token, or Amazon Bedrock credentials as not signed in, and run, resume, bench and eval (unless --offline) refuse to run on it. Those bill per token, which this backend must never do. Run codex login and sign in with ChatGPT.
  • claude_cli asks the CLI who is signed in. co-scientist doctor, and run, resume, bench and eval (unless --offline) before they start, use claude auth status. It reads the login the way a call does, so one this process cannot read shows as not signed in. Over ssh and in cron or launchd jobs the macOS keychain can be locked: ~/.claude.json still names the account while every call stops at "Not logged in". It is asked as a call asks, with --setting-sources project and from an empty directory, so an apiKeyHelper or API key in your own settings does not count: a call does not load them. The detail line names the kind of login (claude.ai for a subscription) and says so when it is one that bills per token. Only the CLI answering loggedIn: false refuses a run; when it cannot be asked, the login files decide.

Embeddings — independent of the backend

No agent CLI exposes an embedding endpoint, and Proximity/dedup needs real semantic vectors, so embeddings always call a hosted API regardless of which backend runs the agents:

[embeddings]
provider = "voyage"                # voyage | openai | hash
model = "voyage-3-large"
dim = 1024

With neither VOYAGE_API_KEY nor OPENAI_API_KEY this degrades to a local hash embedder that catches literal token overlap but not paraphrase — sessions still run, dedup is just weaker. Falling back from Voyage to OpenAI uses text-embedding-3-large shortened to the configured dim, so vector width never changes underneath an existing index. Changing dim yourself does invalidate the FAISS indices under data/vectors/; the store detects the mismatch and rebuilds rather than corrupting them.

Configuration

Layered: co_scientist/resources/default.toml → ~/.co-scientist/config.toml → ./co-scientist.toml → --config <path>. Secrets come from environment only (see .env.example).

A relative storage.data_dir (default ./data) is rooted at the repository when you run from a source checkout. In a pip-installed copy it is rooted at ~/.co-scientist, so an upgrade never deletes your sessions. Set an absolute path, or one starting with ~, to put the data anywhere else.

A setting that no section declares, a value of the wrong type or out of range, and an unknown [llm] provider, [web_search] provider or [embeddings] provider are errors that name the file and the key. A misspelled budjet_usd therefore stops the run instead of leaving you on the default budget. So does a budget_usd that is nan or not above 0, and a concurrency of 0. A setting that older default files carried but that no code ever read (for example [lease] heartbeat_seconds or the whole [code_exec] section) is reported as no longer existing. Delete it: it never had an effect.

[run] budget_tokens counts the output plus the input that was not served from a cache. anthropic, claude_cli and codex_cli report cache reads and writes beside the plain input, so those are left out of the count and priced into budget_usd instead. The OpenAI-compatible providers are counted by prompt_tokens, which includes any cached part, so there the whole prompt counts.

Bench: compare models head-to-head

co-scientist bench runs the same goal under N different (provider, model) configurations and ranks them via a single shared Elo tournament. Each candidate independently generates hypotheses; then every candidate-pair plays --matches head-to-head debates, judged by ONE fixed judge model (picked separately so no candidate scores its own work).

For live numbers — per-candidate Elo, the actual hypotheses each model proposed, gold-set hits, and what the data showed — see docs/BENCH_RESULTS.md. It includes a headline-findings section at the top so you don't have to scroll through every bench.

Presets

Presets come in the same two families as the backends. API presets route every candidate through OpenRouter — the only way to get cross-vendor comparison, since no agent CLI serves a third party's models — and need OPENROUTER_API_KEY. CLI presets run on a subscription and bill nothing per token, but can only field what those CLIs serve.

--preset Family What it does
paper API The paper's own baselines (Gemini 2.0 Flash Thinking → 2.0 Flash, Gemini 2.0 Pro → 2.5 Pro, OpenAI o1, plus Claude Haiku) — see bench/presets.py for each substitution and why
paper-aml API The paper's AML drug-repurposing goal + gold-set recall scoring (strict top-3: Nanvuranlat / KIRA6 / Leflunomide) across those baselines
paper-aml-vs-raw API Same, but each model runs both through the full pipeline AND as a single raw call — isolates the multi-agent harness's value-add
frontier-aml-vs-raw API Same pipeline-vs-raw split across current frontier models (Claude Opus, GPT-5, Gemini 3 Pro/Flash)
claude-aml CLI The AML goal and gold set, run across the three Claude Code tiers
claude-aml-vs-raw CLI Pipeline-vs-raw split across those tiers
cross-backend-aml CLI Claude Code vs Codex on the same goal. Needs both CLIs signed in and a ChatGPT account entitled to the Codex model

Do not compare across families. The prompts and gold sets are identical, but under a CLI backend the tool loop belongs to the CLI rather than to this repo, and the $ column becomes a reported equivalent cost rather than real spend. Pick a judge in the same family as your candidates. The numbers in docs/BENCH_RESULTS.md came from the API presets.

# Free (subscription): score the Claude Code tiers on the paper's AML picks.
co-scientist bench --preset claude-aml --n 3 --matches 2

# Free: isolate how much the multi-agent harness actually adds.
co-scientist bench --preset claude-aml-vs-raw --n 3 --matches 2

# Free: Claude Code vs Codex, if you have both signed in.
co-scientist bench --preset cross-backend-aml --n 1

# Metered (needs OPENROUTER_API_KEY): reproduce the paper's baseline comparison.
co-scientist bench --preset paper-aml --n 3 --matches 2

# Metered: current frontier models, pipeline vs raw.
# (--budget-per-candidate defaults to 3.0; frontier models need it.)
co-scientist bench --preset frontier-aml-vs-raw --n 1

Pipeline vs raw LM (one model, isolated)

The --preset *-vs-raw presets pit each model's full co-scientist Generation pipeline (literature tools + tool loop + dedup + record_hypothesis) against a single raw LM call with the same model + a forced record_hypothesis function call (no tools). Lets you measure how much of the system's output quality comes from the multi-agent harness vs the underlying model. → live numbers in docs/BENCH_RESULTS.md.

Gold-set scoring (AML drug repurposing)

The *-aml* presets score recall against a curated answer key from the Co-Scientist paper. Two gold sets ship; both stay registered so historical bench artifacts remain interpretable.

label size what it is
aml-repurposing-paper-top3 (default for every *-aml* preset) 3 Top-3 of the original paper's list: candidates with no prior published AML repurposing, no prior preclinical evidence in AML, and no external inputs (no DepMap scores, no expert curation). → Nanvuranlat (JPH-203 / KYT-0353), KIRA6, Leflunomide (Arava / HWA-486 / Teriflunomide / Aubagio)
aml-repurposing-paper-5 5 Broader 5-drug list referenced in the paper's main text: Binimetinib (MEK162), Pacritinib (SB1518 / Vonjo), Cerivastatin (Baycol), Pravastatin (Pravachol), Dimethyl fumarate (DMF / BG-12 / Tecfidera)

Swap with --goldset:

co-scientist bench --preset claude-aml --goldset aml-repurposing-paper-5   # broader list
co-scientist bench --preset claude-aml --goldset none                       # head-to-head only

The matcher is whole-token, case-insensitive, and looks at every searched field of every hypothesis (title / summary / full_text / entities / citation excerpts). Drug class mentions (e.g. "DHODH inhibitor") do not count — the candidate has to name the actual compound (or one of its registered aliases).

Custom candidates

label=provider:model[@mode]. mode is pipeline (default) or direct. Pipeline goes through the full Generation agent stack; direct is a single forced-tool LM call with no literature tools.

co-scientist bench "Identify hypotheses about X" \
  -c opus=anthropic:claude-opus-5 \
  -c opus-raw=anthropic:claude-opus-5@direct \
  -c sol=openai:gpt-5.6-sol \
  -c luna=openai:gpt-5.6-luna \
  --judge anthropic:claude-sonnet-5

Where results live

Every bench writes to SQLite + JSON on disk:

data/co_scientist.db                          ← SQLite, all metadata
  bench_runs                                  one row per bench
  bench_candidates                            one row per (bench × candidate × mode)
  bench_matches                               one row per head-to-head

data/artifacts/<session_id>/                  ← JSON on disk
  bench/<bench_id>.json                       run summary + per-entity gold_hit_detail
  hypotheses/<hyp_id>.json                    every hypothesis the bench produced
  transcripts/generation/<trn_id>.json        every LLM call

The auto-generated docs/BENCH_RESULTS.md (rebuild with python scripts/build_bench_report.py) walks every recorded bench and renders the per-candidate result table, every hypothesis attributed to the model that produced it, and a post-hoc rescore against every registered gold set.

Mechanics

  • Generation runs in parallel per candidate under a deep-copied Config (cfg.llm.provider, cfg.models.*, budget shares flattened onto generation; [thinking] budgets are kept as configured and each backend decides what to do with them).
  • Round-robin pairings: every pair plays --matches head-to-heads (one random hypothesis from each side per match).
  • Structured verdict via a forced record_verdict function call — no fragile better idea: <N> text parsing across providers.
  • Bench runs do not write to tournament_matches or affect any session's leaderboard. They are not fully isolated from regular sessions, though: each bench leaves one private session row, marked done (failed if no candidate produced a hypothesis or, when matches were asked for, no match gave a valid verdict, aborted if it was interrupted). That row is visible in co-scientist list and the web index. It is not a research run, so pause and resume refuse it, on the command line and in the dashboard. abort marks it aborted, which is how a row that a killed bench left running is cleared. It does not stop a bench that is still running: stop that with Ctrl-C.

Repository layout

co_scientist/
  agents/       # supervisor + 6 specialized agents (base, generation, reflection,
                # ranking, evolution, proximity, metareview)
  bench/        # cross-model bench runner (Elo tournament + gold-set scoring)
  llm/          # provider abstraction (anthropic / openai / openai_compatible),
                # tool loop, token budgets, model routing, retry, estimator
  storage/      # SQLite schema + migrations, db connection, 10 repos
  tools/        # tool registry; web_fetch, web_search, pubmed/arxiv/europe_pmc,
                # science-skills bridge
  vectors/      # embeddings (OpenAI text-embedding-3-large / hash) + FAISS
  orchestrator/ # task scheduling, Elo updates, termination, event bus
  safety/       # injection quoting, classifier, citation verifier
  obs/          # metrics (tokens, cost, cache hit ratio, latency)
  web/          # FastAPI + htmx + SSE UI + sanitized markdown renderer
  evals/        # per-agent + e2e + regression evals
  tests/        # unit tests + fixtures + smoke
  resources/    # ships inside the wheel:
    default.toml
    prompts/    # 14 Jinja2 templates (one per agent.mode), derived from
                # the paper's supplementary prompts
docs/
  BENCH_RESULTS.md   # every bench ever run (auto-generated)
scripts/
  build_bench_report.py
  smoke_installed_package.py   # checks a built wheel from a clean environment
reference/      # gitignored; paper source materials (pseudocode, prompts, diagrams)
data/           # gitignored; runtime artifacts (SQLite, FAISS, transcripts)
vendor/         # gitignored; clone of google-deepmind/science-skills

Development

Install the dev tools, then run the checks CI runs:

pip install -e ".[dev]"
pytest co_scientist/tests/unit -q   # no network and no API keys needed
ruff check .
mypy co_scientist

The unit tests run against a checkout, where the default config and the prompt templates sit beside the code. They cannot tell whether those files reach an installed copy, or whether a new release of a dependency breaks the CLI at import. CI covers that by building the wheel, installing it into a clean environment, and running it from outside the checkout. To do the same locally:

pip wheel . --no-deps --wheel-dir /tmp/dist
python -m venv /tmp/venv
/tmp/venv/bin/pip install /tmp/dist/*.whl
cd /tmp && /tmp/venv/bin/python <path-to-checkout>/scripts/smoke_installed_package.py

License

Apache-2.0.

探索相关项目

加载中…