This document describes baseline agent implementations for CoDA-Bench.
We provide reference implementations for several baseline agents to help you get started:
- Random Agent: Submits random answers (baseline floor)
- Oracle Agent: Has access to target files (oracle ceiling for DA)
- Simple LLM Agent: Basic code-generation agent
- Advanced Agents: State-of-the-art implementations
# Install baseline dependencies
pip install -e ".[baselines]"
# Run a baseline agent
python baselines/run_simple_agent.py --model gpt-4 --split full --output predictions.jsonl| Agent | Model | EA (Full) | EA (Hard) | DA (Full) | DA (Hard) |
|---|---|---|---|---|---|
| Mini-SWE-Agent | GPT-5.5 | 61.1% | 49.6% | 52.3% | 48.7% |
| Codex CLI | GPT-5.5 | 60.3% | 47.9% | 51.7% | 47.2% |
| OpenHands | GPT-5.5 | 59.7% | 44.5% | 48.9% | 43.1% |
| Claude Code | Sonnet-4.6 | 53.8% | 42.9% | 47.2% | 41.8% |
All agents should implement this interface:
from pathlib import Path
from typing import Protocol
class Agent(Protocol):
def solve_task(self, question: str, data_dir: Path) -> str:
"""Solve a task and return the answer.
Args:
question: Natural language task description
data_dir: Path to the data community directory
Returns:
Final answer as a string
"""
...Create isolated environments for each task:
import tempfile
import shutil
from pathlib import Path
def setup_sandbox(community_id: str, data_root: Path) -> Path:
"""Create a sandbox for task execution."""
sandbox = Path(tempfile.mkdtemp(prefix=f"coda_bench_{community_id}_"))
data_path = data_root / community_id / "full_community"
# Symlink data into sandbox
(sandbox / "data").symlink_to(data_path)
return sandbox
def cleanup_sandbox(sandbox: Path):
"""Remove sandbox after execution."""
shutil.rmtree(sandbox)import openai
from pathlib import Path
class SimpleLLMAgent:
def __init__(self, model: str = "gpt-4"):
self.model = model
self.client = openai.OpenAI()
def solve_task(self, question: str, data_dir: Path) -> str:
# List available files
files = list(data_dir.rglob("*"))
file_list = "\n".join(f"- {f.relative_to(data_dir)}" for f in files[:100])
# Create prompt
prompt = f"""You are a data analysis assistant.
Question: {question}
Available files in data directory:
{file_list}
Write Python code to solve this task and print the final answer.
"""
# Generate code
response = self.client.chat.completions.create(
model=self.model,
messages=[{"role": "user", "content": prompt}]
)
code = response.choices[0].message.content
# Execute code (simplified - use proper sandboxing in production)
exec_globals = {"data_dir": str(data_dir)}
exec(code, exec_globals)
# Extract answer from output
return exec_globals.get("answer", "")Strategy 1: Keyword Matching
def find_files_by_keywords(data_dir: Path, question: str) -> list[Path]:
keywords = extract_keywords(question)
candidates = []
for file in data_dir.rglob("*.csv"):
if any(kw.lower() in file.name.lower() for kw in keywords):
candidates.append(file)
return candidatesStrategy 2: Content Inspection
import pandas as pd
def find_relevant_files(data_dir: Path, question: str) -> list[Path]:
candidates = []
for csv_file in data_dir.rglob("*.csv"):
try:
df = pd.read_csv(csv_file, nrows=5)
if matches_schema(df.columns, question):
candidates.append(csv_file)
except Exception:
pass
return candidatesStrategy 3: LLM-based Discovery
def llm_discover_files(data_dir: Path, question: str, llm) -> list[Path]:
file_list = "\n".join(str(f.relative_to(data_dir)) for f in data_dir.rglob("*"))
prompt = f"""Which files are most relevant to answer this question?
Question: {question}
Available files:
{file_list}
Return a JSON list of the most relevant file paths."""
response = llm.generate(prompt)
return parse_file_paths(response, data_dir)We welcome contributions of new baseline implementations!
- Create a new file in
baselines/your_agent.py - Implement the agent interface
- Add documentation and usage instructions
- Submit a PR with evaluation results
See CONTRIBUTING.md for details.
- OpenHands: Open-source code agent
- SWE-agent: Software engineering agent
- AutoGPT: Autonomous GPT-4 agent
- Open an issue on GitHub
- Email: zhangshaolei98@ruc.edu.cn