Skip to content
lamalab-orgPublic

About

A framework for the science of agents and agents for science

Resources

Code of conduct

Stars

21 stars

Watchers

1 watching

Forks

Latest commit

 

History

300 Commits

Folders and files

Repository files navigation

Corral: Scientific Agent Benchmark

Tests PyPI PyPI - License Documentation Status Contributor Covenant

Corral logo

A comprehensive benchmarking framework for evaluating AI agents on science tasks. The system provides standardized environments, tools, and evaluation metrics to test agent performance across diverse materials science challenges.

🚀 Quick Start: Run One Task from One Environment

The shortest useful Corral run does not need CorralRunner, trials, scoring, or report generation. corral run executes one independent task using the execute_task function in run.py.

You need Python 3.11 or newer for SampleMath, uv, and a model API key such as OPENAI_API_KEY. Clone the repository and install SampleMath together with the framework:

git clone https://github.com/lamalab-org/corral.git
cd corral/tasks/samplemath
uv sync

Run one task with one agent and model:

uv run corral run \
  --agent tool-calling \
  --environment samplemath \
  --task task1 \
  --model openai/gpt-5.6

This path skips evaluation: it prints the final status, submitted answer, and commit hash, and writes the authored commit ledger to .corral/run-commits.sqlite3. It does not create trials, invoke a scorer, or generate a benchmark report. Because it executes exactly one task, it rejects a task with upstream dependencies and points to corral bench instead.

Re-running with the same --execution-id and commit database restores the latest persisted task state.

The equivalent Python API is below. Save this as quickstart.py in the current tasks/samplemath directory:

import asyncio
from uuid import uuid4

from dotenv import load_dotenv

from corral import (
    RuntimeRegistry,
    RunTaskInput,
    execute_task,
    load_environment_group,
)
from corral.agents import ToolCallingAgent
from corral.persistence import SQLiteCommitStore

AGENT_ID = "tool-calling"
TASK_ID = "task1"
MODEL = "openai/gpt-5.6"


async def main():
    load_dotenv()
    environment = load_environment_group("samplemath")[TASK_ID]
    store = SQLiteCommitStore(".corral/quickstart-commits.sqlite3")
    registry = RuntimeRegistry(
        agents={AGENT_ID: ToolCallingAgent(model=MODEL)},
        environments={TASK_ID: environment},
    )

    try:
        state = await execute_task(
            state_store=store,
            registry=registry,
            task=RunTaskInput(
                execution_id=f"samplemath-task1-{uuid4().hex}",
                task_id=TASK_ID,
                environment_id=TASK_ID,
                agent_id=AGENT_ID,
                model=MODEL,
                max_iterations=10,
            ),
        )
    finally:
        registry.close()
        await store.aclose()

    print(f"status: {state.status}")
    print(f"answer: {state.submission}")


if __name__ == "__main__":
    asyncio.run(main())

Run it with the current SampleMath virtual environment:

uv run python quickstart.py

The result is a StateRef pointing to the persisted final state, and the example prints its status and submitted answer. No scorer, aggregate metric, or benchmark report runs. task1 is independent; use corral bench for a task such as task4 whose inputs come from earlier tasks.

📊 Running Benchmarks

Run any agent with the corral CLI

The installed corral command can run every public concrete agent against a registered environment.

Each task environment is a separate Python project because it has its own dependencies. Change into that project once, then uv automatically uses its environment and no --project option is needed:

cd tasks/samplemath
uv sync
uv run corral bench \
  --agent react \
  --environment samplemath \
  --model openai/gpt-4o \
  --task task4 \
  --trials 3

corral bench calls the same CorralRunner used by Python callers. The runner schedules trials in the CLI process using asyncio.

Without --task, corral bench runs corral-mini, a fixed 3-task subset of each level chosen from the published reports; pass --run-full to run every task. Levels the mini does not cover run in full. See corral_mini/README.md.

Benchmarks run one Docker container per (run, task, trial) by default. Corral builds corral-benchmark:latest from docker/benchmark.Dockerfile when that image is missing, resolves it to an immutable image ID before scheduling any trial, and applies these defaults: 2 CPUs, 4 GiB memory, 256 PIDs, a read-only root filesystem, and Docker's bridge network so the container has outbound network access. Pass --sandbox-network none for fully network-isolated trials. The image includes curl, wget, and git; outbound access is available with --sandbox-network bridge in either guardrail mode, except for protected tools explicitly declared with network_access="none".

For isolation ablations, keep Docker and toggle its internal guardrails:

corral bench ... --sandbox docker --sandbox-guardrails on   # default
corral bench ... --sandbox docker --sandbox-guardrails off  # ablation

off disables Corral's controller/worker isolation and native agent SDK sandboxing and approval checks. Native tools still share the task workspace and their workspace changes are checkpointed. Agents can read task source, scoring data, checkpoints, and other files present in the container or its mounts. Docker resource limits, networking, read-only root filesystem, and read-only input mounts remain in place. Both conditions use the same image and installed utilities; this toggle does not grant arbitrary host filesystem access. The setting is recorded in run configuration, trial sandbox metadata, and execution scaffold metadata. Python callers can use DockerSandboxSpec(guardrails="off"). Rebuild trial images after upgrading to this runtime protocol; older images are rejected. --sandbox-guardrails off requires --sandbox docker.

Use --sandbox local only for local debugging; corral run remains local and never contacts Docker.

Evaluation-awareness ablations can be selected independently of the execution boundary with --evaluation-awareness on|off (default: off), for example:

corral bench --agent react --environment samplemath --task task4 \
  --evaluation-awareness on --max-iterations 50

When enabled, Corral prepends this notice to every agent's task prompt:

Evaluation notice: You are being evaluated on this task. Your final submission will be assessed by the task's scoring function. Your configured iteration limit is 50.

The limit reflects the effective budget, including agent defaults and delegated budgets. Scores retain each task's existing semantics, including partial credit. Text and image content in the original task prompt are preserved. The mode, notice template, and iteration limits are saved in benchmark metadata; execution scaffold metadata also records the rendered notice. off adds no notice and leaves any evaluation wording already present in task or agent prompts intact. The enabled condition discloses both evaluation and the budget.

The option is also available for corral run and corral continue, and Python callers can pass evaluation_awareness="on" to CorralRunner.run() or RunTaskInput. It works in local and Docker execution and can be combined with other ablations without changing their settings. A continuation uses its selected mode; prior conversation history remains intact. Changing the mode while resuming the same trial is rejected: use a new trial or continuation instead. Docker images must include this implementation for on; the launcher rejects older images that would otherwise silently omit the notice. Rebuild with --build-sandbox-image when needed.

By default, each invocation creates one descriptive, self-contained directory below .corral/runs/. Its name records the UTC start time, agent, model, environment, requested tasks, k/trial count, and sandbox mode. The exact task and trial checkpoint layout is:

.corral/runs/<descriptive-run-name>/
├── report.json
├── run-metadata.json
└── task-<task-id>/
    └── k-<1-based-trial>/
        ├── metadata.json
        ├── commits.sqlite3
        ├── artifacts/
        ├── workspace-snapshots/
        │   ├── <revision>.json
        │   └── latest.json
        ├── state-snapshots/
        │   ├── <sequence>-<commit>.json
        │   ├── latest.json
        │   └── final.json
        └── recovery/

Workspace snapshot manifests reference the content-addressed files in artifacts/, so the combination is a complete, restorable workspace snapshot. State projections are exported at the ledger interval and again at terminal completion; commits.sqlite3 remains the authoritative, replayable history. Docker runs also place request.json, result.json, and sandbox.json in the trial directory.

The final report.json includes the resolved agent, model, environment, task mapping, benchmark settings, concurrency, retry policy, sandbox configuration, and output paths. Credential-like values in runtime option dictionaries are redacted. --output-dir (also accepted as --state-dir) moves the runs root, and --report overrides the default report location. If a task launch fails, its retry discards the old container and volume, creates a clean workspace, and restores the last committed workspace revision. Completed actions are not repeated; filesystem changes from an action interrupted before its completion commit are deliberately excluded. --keep-sandboxes on-failure or always retains Docker resources for inspection without making them the recovery source of truth.

The main isolation controls all have CLI defaults and can be overridden with --sandbox-image, --sandbox-cpus, --sandbox-memory, --sandbox-pids-limit, --sandbox-network, --keep-sandboxes, and repeated --sandbox-env NAME arguments. Only allowlisted host variables are forwarded; the built-in list covers common model-provider credentials. Environment stacks that need dependencies beyond the base image should provide their own image with --sandbox-image, optionally paired with an image-specific registry via --sandbox-registry-module module:create_registry.

If that environment is already activated, uv run is optional and the command is simply corral bench .... The --project form is only needed when invoking uv from elsewhere in the monorepo.

The available agent names are ai-scientist, claude-code, codex, denario, epistemic, llm-planner, openhands, react, reflexion, terminus, and tool-calling. Class names and underscore spellings such as ReActAgent and tool_calling are accepted as aliases. Claude Code, Codex, and OpenHands need their corresponding optional package extra and report an installation hint if it is missing.

denario uses Denario (code) for idea and methodology generation followed by its native get_results() workflow. CMBagent owns planning, review, researcher/engineer handoffs, code execution, and retries. Corral exposes the benchmark's tools directly to the engineer and researcher for observations and nonterminal propose_answer calls. The final researcher step must confirm the candidate answer. The adapter submits it only after native control completes the plan and get_results() saves a nonempty input_files/results.md. Corral runs Denario’s code blocks with its native executor in a separate restricted worker sharing the task workspace. The Corral adapter authenticates upstream model requests. The Denario SDK receives a per-run loopback token, and generated code receives neither credential.

The Task section contains the environment's task text directly, including its inputs, constraints and required answer format. Corral's system, user and surrender prompt templates are not applied to Denario, and the task is not JSON-serialized. Denario supplies its own role prompts; tool schemas and environment integration instructions are provided separately from the task text. Only text tasks are supported.

Native code execution requires the Docker sandbox. With OPENAI_API_KEY configured, run from the task project, for example:

cd tasks/samplemath
uv run corral bench \
  --agent denario --environment samplemath --task task1 \
  --model openai/gpt-6.1-sol --max-iterations 50 \
  --sandbox docker --build-sandbox-image

--model selects the model for every role, including formatters and plot review. For evaluation consistency, this implementation diverges from upstream Denario's default model configuration by using a single model across all roles. Use openai/<model>, anthropic/<model>, or openrouter/<author>/<model>. The gateway uses each provider's API key (OPENAI_API_KEY, ANTHROPIC_API_KEY, or OPENROUTER_API_KEY); Anthropic uses its OpenAI-compatible endpoint. --api-endpoint, --temperature, and explicit model settings such as reasoning_effort apply throughout; omitted sampling and reasoning settings use provider defaults. The legacy denario_model option, if supplied, must match --model without its provider prefix.

For OpenRouter, --agent-kwargs '{"openrouter_zdr":true}' adds zdr: true and data_collection: "deny" to every request. Additional routing restrictions go in openrouter_provider, for example {"only":["fireworks"]}. These cannot override the requested ZDR policy. OpenRouter account logging and safety-retention exceptions must also be disabled or excluded when requiring no content retention. Claude Opus 5.5 rejects forced tool selection. For that model, the gateway retains the tool definitions, explicitly asks for the requested tool, and uses auto selection. Corral records this compatibility step; model reasoning stays at its configured setting. Automatic selection cannot guarantee that the model calls the tool.

Kimi K3.1 Pro through OpenRouter keeps native tool selection, but omits the SDK's parallel_tool_calls parameter, which Fireworks does not advertise. When the SDK requests serial calls, the prompt asks for one tool call at a time; this is a preference, not an API guarantee. Corral records this adaptation and all returned tool calls. Strict OpenRouter parameter matching and zero-retention routing remain enabled when configured.

denario_iterations controls native fast idea refinement (default 4, matching upstream: four idea-generation passes and three critiques); max_plan_steps (default 6) and max_n_attempts (default 10) configure the native experiment workflow. wall_clock_timeout_s optionally limits elapsed time. Set these through --agent-kwargs. Environment execution failures use CMBagent's shared per-step attempt counter and native control handoff. Reaching the limit terminates the step and prevents further experimental calls, including remaining calls in the same batch. Argument-validation errors do not consume experimental attempts. Failed environment actions are never automatically replayed by the adapter.

Reported usage and --max-iterations cover all model requests, including planning, review, formatting, and provider retries. A local gateway commits requests and responses to Corral state before native execution continues; streaming responses are buffered. SDK messages (including handoffs), proposed tool calls, native tool/code results, and Corral tool results are also recorded in state and exported to Langfuse. Interrupted requests are marked explicitly. This records public messages, not the provider's private reasoning. SDK logs and research artifacts remain in the trial workspace under denario-*/.

Verbose JSON reports retain model inputs, outputs, tool results, and SDK handoffs. The short “Solve the supplied task…” handoff is only the task description: native Denario passes the generated idea and method into role-specific prompts, then adds the plan and current subtask for execution. New Langfuse exports label actual model calls separately from SDK bookkeeping, which appears under “SDK messages and routing”.

For GPT-6 models, the gateway translates tool requests to the Responses API, which gpt-6.1-sol requires for function calling. This preserves default reasoning and Denario's native loop; the original provider payloads are also recorded. SDK speaker names are represented as [Speaker: ...] content labels across provider transports, without sending a message-level name field. Function names, tool-call IDs, multimodal inputs, and cached reasoning items are retained.

Each trial uses a separate worker process. Resuming an interrupted native run is currently rejected to avoid replaying experiments; start a new trial instead. Subagents cannot call the terminal submit_answer tool. Failed or incomplete native runs cannot submit their preliminary candidates. Literature searches and publication writing are outside this task-solving workflow.

Use uv for this extra: the project overrides older OpenAI constraints in cmbagent-autogen and futurehouse-client with the tested openai==2.45.0. The extra pins langchain-openai==0.3.35 and the Mistral SDK version required by cmbagent. Plain pip install 'corral[denario]' cannot resolve those upstream constraints. --agent denario --build-sandbox-image selects the extra automatically on Python 3.12 and applies the same OpenAI override. The optional integration tests exercise the real native SDK with a mocked provider, including two-step engineer/researcher completion, saved results, environment failure recovery, attempt exhaustion, and native Python execution. Run tests/agents/test_denario.py with CORRAL_TEST_DENARIO_NATIVE=1 inside a Denario-enabled Docker image.

Use --agent-kwargs for constructor-specific settings. Where the agent supports them, explicit --model, --api-endpoint, and --temperature options take precedence over the same keys in that JSON object:

uv run corral bench \
  --agent codex --environment samplemath --task task1 \
  --model gpt-5.4 \
  --agent-kwargs '{"reasoning_effort": "high"}'

--max-iterations counts model responses for Claude Code and Codex, not individual tool calls. Claude Code uses its native max_turns limit. Codex uses cumulative SDK token usage updates as a proxy and interrupts at the limit; this can cut off tools from the final allowed response. Codex's count is approximate because usage updates are not guaranteed to arrive once per model call.

ReflexionAgent wraps ToolCallingAgent by default. Select another actor with {"actor": "react", "actor_kwargs": {...}}. For AIScientistAgent, a JSON config object is validated as AIScientistConfig; add "config_profile": "sakana" to use SakanaAIScientistConfig.

Compatibility ToolCallingAgent script

run_scripts/run_tool_calling.py delegates to the same local benchmark execution function as corral bench; it does not maintain a separate runner implementation. The runner infers BenchmarkTaskMetadata and includes the selected task's dependencies automatically. Its existing options, defaults, and invocation remain supported:

From the repository root:

uv sync --project tasks/samplemath
uv run --project tasks/samplemath python run_scripts/run_tool_calling.py \
  --environment samplemath --list-tasks

uv run --project tasks/samplemath python run_scripts/run_tool_calling.py \
  --environment samplemath --task task4 --model openai/gpt-4o \
  --report .corral/samplemath-report.json

The built-in presets are afm, corral_md, resistor_network, retrosynthesis, samplemath, spectra_elucidation, and wetlab. These are fixed choices for --environment. Use --env-kwargs for environment-specific configuration, including the common level, subtasks, task_config, and work_dir keys. Environment dependencies and credentials still need to be configured as described in each task package's README.

Omit --task to run every task returned by the environment. Pass --task multiple times to select specific tasks; their required dependencies are included automatically.

The runner applies no time limit to task execution or evaluation. Failed attempts are retried up to --max-attempts times (default: 3).

For example, select SampleMath's subtask set with one environment argument:

python run_scripts/run_tool_calling.py --environment samplemath \
  --env-kwargs '{"subtasks": true}'

Langfuse observability

run_tool_calling.py loads the repository's .env before starting a run. Configure Langfuse there with the keys and URL for your project:

LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=https://cloud.langfuse.com
CORRAL_LANGFUSE_ENABLED=true

Install the optional SDK in the environment running the script. From the repository root, use uv sync --extra langfuse, then retain the extra when running with uv:

uv run --extra langfuse python run_scripts/run_tool_calling.py \
  --environment samplemath --task task1 --run-id samplemath-traced

When using a task package's environment instead, add --with 'langfuse>=4,<5' to its uv run --project tasks/<environment> command. Each task produces a trace named corral.task.<task-id>, with model turns, token usage, and tool results, grouped into a Langfuse session by run ID. Set CORRAL_LANGFUSE_SESSION_ID to group several runs (for example one-trial runs of the same model) under one session instead. Traces are flushed before the runner exits. Docker runs forward the Langfuse settings and build a separate image with the SDK installed; custom images need the langfuse extra too. Set CORRAL_LANGFUSE_ENABLED=false to keep only local logging.

Scored, Multi-Trial Benchmarks

CorralRunner is the higher-level convenience layer for repeated trials, evaluation, metric calculation, and reports. Use it after the direct execution path above when those benchmark features are actually needed. Given the store and model settings from the example above (keep the store open until the benchmark finishes):

from corral import CorralRunner

environments = load_environment_group("samplemath")
registry = RuntimeRegistry(
    agents={AGENT_ID: ToolCallingAgent(model=MODEL)},
    environments=environments,
)
runner = CorralRunner(
    registry,
    environments=environments,
    agent_id=AGENT_ID,
    model=MODEL,
    max_iterations=10,
    state_store=store,
)
result = await runner.run(
    "samplemath-run-2",
    task_ids=["task1", "task2"],
    trials_per_task=3,
    k_values=[1, 2, 3],
    max_parallel=4,
    max_parallel_per_task=2,
    max_parallel_evaluations=2,
    max_parallel_total=6,
)

CorralRunner handles concurrency, task retries, and dependency readiness. Task execution and evaluation are split into two separate processes in corral.

🏗️ Available Environments

The framework includes several pre-built environments:

Environment Description
afm Hardware-in-the-loop atomic force microscopy tasks
corral_md LAMMPS molecular dynamics simulation setup and analysis
resistor_network Hidden resistor-topology inference from measurements
retrosynthesis Reaction-template-based synthesis planning
samplemath Lightweight mathematical operations
spectra_elucidation Spectroscopy-based organic structure elucidation
wetlab Simulated qualitative inorganic ion analysis

🤖 Available Agents

The framework includes several built-in agent types:

AIScientistAgent

Uses progressive tree search to formulate hypotheses, run experiments, refine results, and verify conclusions. It is based on Sakana AI's original AI Scientist v2 implementation.

from corral.agents import AIScientistAgent

agent = AIScientistAgent(
    model="gpt-4o",
    evaluator_model="gpt-4o",
)

ReActAgent

Uses the ReAct (Reasoning and Acting) framework for step-by-step problem solving.

from corral.agents import ReActAgent

agent = ReActAgent(
    model="gpt-4o",  # or "claude-3-5-sonnet-20241022" or any other model litellm supports
    temperature=0.1,
)

ToolCallingAgent

Uses native function calling from LLM providers to solve tasks by leveraging built-in tool/function calling capabilities.

from corral.agents import ToolCallingAgent

agent = ToolCallingAgent(
    model="gpt-4o",  # or "claude-3-5-sonnet-20241022" or any other model LiteLLM supports
    temperature=0.0,
)

Both ReActAgent and ToolCallingAgent accept epistemic=True to enable the same annotations, actor feedback, and submission review as EpistemicAgent:

agent = ReActAgent(model="gpt-4o", epistemic=True)
# Or: ToolCallingAgent(model="gpt-4o", epistemic=True)

The mode is off by default.

EpistemicAgent

Extends ToolCallingAgent with dedicated scientific prompts and a Decisions assessment after each public actor turn.

from corral.agents import EpistemicAgent

agent = EpistemicAgent(
    model="openai/gpt-4o",  # Actor: any model supported by ToolCallingAgent.
    actor_refusal_max_retries=1,  # Retries after the initial refused actor call.
    epistemic_model="gpt-6-luna",  # Separate Decisions classifier.
    epistemic_explanation_model="gpt-6-luna",  # Defaults to epistemic_model.
    epistemic_explanation_concurrency=8,  # Per assessment, one request per candidate.
    epistemic_timeout_s=120,
    epistemic_max_retries=2,
    epistemic_pattern_thresholds="positive-mass-20261020-v1",  # Default policy.
)
uv run corral bench \
  --agent epistemic --environment samplemath --task task1 \
  --model openai/gpt-4o \
  --agent-kwargs '{"epistemic_model":"gpt-6-luna"}'

Set OPENAI_API_KEY for the classifier. Its connection can be configured with epistemic_api_key and epistemic_base_url, independently of the actor's api_endpoint. The Decisions API currently supports gpt-6-luna. The annotator uses the SDK's native Decisions helper when available, or its generic POST /decisions transport on older SDKs.

LLMPlanner

Uses hierarchical planning with high-level planning and low-level execution delegation to other agents.

from corral.agents import LLMPlanner

agent = LLMPlanner(model="gpt-4o", temperature=0.1)

ReflexionAgent

Implements the Reflexion architecture (paper) which adds self-reflection and learning from mistakes.

from corral.agents import ReActAgent, ReflexionAgent, ToolCallingAgent

# Create base agent (the "Actor")
base_agent = ToolCallingAgent(model="gpt-4o", temperature=0.1)

# Wrap with Reflexion capabilities
reflexion_agent = ReflexionAgent(
    actor=base_agent,
    reflection_model="gpt-4o",  # Model for generating reflections
    reflection_temperature=0.0,  # Deterministic reflections
)

💾 Commit Ledger

Corral persists one small, immutable, typed commit for every durable event in a SQLite ledger. parent_hash links each ordinary commit to the current branch head, while based_on_hash records the projection the author actually saw. ExecutionState is rebuilt from the ledger plus occasional replay snapshots; agents receive an authorized AgentContext, not the complete execution trace.

Agent and tool authors are bound capabilities. Subagents share the same linear branch and appear in the parent conversation as ordinary tool calls with automatic result summaries. Their full conversations and state remain private unless the parent chooses to inspect and import selected details. Parallel tool completions are stored in real completion order and presented to the model in declared action order. Shared environment and workspace effects carry revision preconditions, so overlapping writes conflict instead of silently rebasing. Explicit experiments use SQLiteCommitStore.create_branch(); spawning a subagent never creates a branch.

Subagent inspection is opt-in per agent. Agents declaring AgentSessionCapabilities(inspect_subagents=True) receive an inspect_subagent tool that returns a bounded authorized child context through the normal tool-call ledger path. AI Scientist enables it; other built-in agents do not expose it.

Start independent trials from a finished trajectory with corral continue:

corral continue --source-trial PATH_TO_TRIAL --commit FULL_COMMIT_HASH \
  --trials 4 --message "Recheck your conclusion." --sandbox docker

The child trials restore the selected workspace, environment, and canonical conversation, and record their parent commit. See the continuation reference for the Python API, checkpoint semantics, and reproducible local/Docker checks.

🔧 Contributing

Adding a New Environment

  1. Create environment directory

    mkdir -p tasks/my_new_env/my_new_env
    cd tasks/my_new_env
  2. Create pyproject.toml

    [project]
    name = "my_new_env"
    version = "0.1.0"
    dependencies = [
        "corral",
        # Add your specific dependencies
    ]
  3. Create tools

    # tasks/my_new_env/my_new_env/tools.py
    from corral.core.tool import tool
    
    
    @tool
    def my_custom_tool(input_param: str) -> str:
        """Description of what the tool does.
    
        Args:
            input_param: Description of the parameter
    
        Returns:
            Description of the return value
        """
        # Your tool implementation
        return f"Processed: {input_param}"

    Note that the docstring has to be formatted correctly for the tool to be registered properly. This means it has to include a description of the parameters and return values as in the example above.

  4. Define the task and environment

    # tasks/my_new_env/my_new_env/env.py
    from corral.core.environment import Environment, Toolset
    from corral.core.task import TaskDefinition
    
    from .tools import my_custom_tool
    
    task = TaskDefinition(
        name="task_1",
        description="Solve this problem: Problem 1",
        tools=["my_custom_tool"],
        scoring_fn=lambda answer: float(answer == "Answer 1"),
        submission_format={"answer": "string"},
        resolve_answer=False,
    )
    environment = Environment(
        "task_1",
        task,
        toolset=Toolset(pool={"my_custom_tool": my_custom_tool}),
    )

Adding a New Agent

  1. Create agent file

    # src/corral/agents/my_agent.py
    from corral.agents import AgentOutcome
    from corral.core import submit_answer_action
    
    
    class MyAgent:
        model = "gpt-4o"
    
        async def run_session(self, session):
            result = await session.execute(submit_answer_action("Your final answer"))
            if not result.success:
                return AgentOutcome(
                    status="protocol_failure",
                    error=f"submit_answer failed: {result.error}",
                )
            return AgentOutcome(status="completed", answer="Your final answer")
  2. Add to agent registry

    # src/corral/agents/__init__.py
    from .my_agent import MyAgent
    
    __all__ = ["MyAgent", ...]
  3. Register your agent for execution

    from corral.agents.my_agent import MyAgent
    from corral import RuntimeRegistry
    
    registry = RuntimeRegistry(
        agents={"my-agent": MyAgent()},
        environments={"my-environment": environment},
    )

Development Setup

  1. Install development dependencies

    uv pip install -e .
  2. Install pre-commit hooks with commitizen commits

    pre-commit install --hook-type commit-msg --hook-type pre-push

📋 Advanced Usage

Tool Creation

Standard Tools

from corral.core.tool import tool


@tool
def calculate_molecular_weight(formula: str) -> float:
    """Calculate molecular weight from chemical formula.

    Args:
        formula: Chemical formula (e.g., 'H2O', 'CH4')

    Returns:
        Molecular weight in g/mol
    """
    # Implementation here
    pass

Evaluation Metrics

The framework provides comprehensive evaluation metrics:

result = await runner.run(
    "metrics-run-1",
    trials_per_task=10,
    k_values=[1, 3, 5],
)

metrics = result.calculate_metrics()
print(metrics["average_score"])
print(metrics["pass_at_1"])

# Per-task analysis
for task_id, task_result in result.task_results.items():
    print(task_id, [trial.score for trial in task_result.trials])

🤝 Community

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use Corral in your research, please consider citing:

@article{ríos-garcía2026ai,
  title   = {AI scientists produce results without reasoning scientifically},
  author  = {Martiño Ríos-García and Nawaf Alampara and Chandan Gupta and Indrajeet Mandal and Sajid Mannan and Ali Asghar Aghajani and N. M. Anoop Krishnan and Kevin Maik Jablonka},
  year    = {2026},
  journal = {arXiv preprint arXiv: 2604.18805}
}

About

A framework for the science of agents and agents for science

Resources

Code of conduct

Stars

21 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages