LocBench
Use this sample to study an agent locating code relevant to an issue. The agent investigates a repository with list, grep, and read tools, then submits file or symbol locations. The environment scores those locations against reference labels.
What you supply
Section titled “What you supply”Provide a case with the issue, repository, base commit, and reference locations, plus a policy. Prepare a Repository at the case’s base commit and pass it to build_world() with a RunConfig. The task prompt exposes the issue; reference changes are used for evaluation.
What to adapt
Section titled “What to adapt”Adapt RepositoryTool for a different code browser or LocationSubmit for another location format. The metrics module owns scoring, and the environment owns investigation limits and completion. This sample demonstrates code localization; it does not edit the repository or produce a patch.
The reference below covers repository access, task assembly, submission, and evaluation.
Represent a LocBench issue, its repository revision, and the reference change used to evaluate localization.
Definition
Fields
Case.from_row
Section titled “Case.from_row”Case.task_prompt
Section titled “Case.task_prompt”The sole model-facing dataset projection; no hints, patch, or labels.
Hold the reference files and symbols used to score a localization answer.
Definition
Fields
LocBenchEnv
Section titled “LocBenchEnv”Apply repository-inspection actions and evaluate the agent’s submitted file and symbol locations.
Definition
LocBenchEnv.init
Section titled “LocBenchEnv.init”repeat_limit ends the investigation after that many identical
consecutive requests (zero disables it). fold_horizon ends it once task
turns plus compactions reach that many decisions.
LocBenchEnv.initial_state
Section titled “LocBenchEnv.initial_state”LocBenchEnv.should_finish
Section titled “LocBenchEnv.should_finish”LocBenchEnv.on_compaction_failure
Section titled “LocBenchEnv.on_compaction_failure”LocBenchEnv.step
Section titled “LocBenchEnv.step”LocBenchEnv.on_submit
Section titled “LocBenchEnv.on_submit”LocBenchEnv.reward
Section titled “LocBenchEnv.reward”LocBenchEnv.on_tool_calls
Section titled “LocBenchEnv.on_tool_calls”LocBenchState
Section titled “LocBenchState”Track the agent’s repository-inspection progress, submitted locations, and task allowance.
Definition
Fields
Repository
Section titled “Repository”Expose repository evidence at a fixed base commit so all branches inspect the same source revision.
Definition
Repository.init
Section titled “Repository.init”Repository.list
Section titled “Repository.list”Repository.text
Section titled “Repository.text”Repository.read
Section titled “Repository.read”Repository.grep
Section titled “Repository.grep”RunConfig
Section titled “RunConfig”Configure model execution, repository tools, budgets, and context management for a localization run.
Definition
Fields
Bundle a prepared localization case, repository, agent, workspace, and prompt.
Definition
Fields
aggregate
Section titled “aggregate”Average localization metrics across cases using each metric’s eligibility count.
Definition
build_world
Section titled “build_world”Assemble the repository tools, environment, context manager, agent, workspace, and prompt for one localization case.
Definition
load_cases
Section titled “load_cases”Read LocBench cases from a user-supplied JSONL file. Each record provides the problem, repository revision, and private scoring labels; duplicate case IDs are rejected.
Definition
Describe a file or symbol exposed by the immutable repository view.
Definition
Fields
Entry.readable
Section titled “Entry.readable”Compute per-case localization metrics from predicted files and symbols; an empty submission receives zero reward.
Definition