Understanding an open-source coding agent often starts with a concrete question: will it ask before deleting a file? Answering it requires tracing permission checks, confirmation state, execution paths, and possible bypasses. Searching for delete, permission, or confirm can reveal useful fragments, but the behavior depends on how those fragments work together.
Harness Handbook organizes this relationship into a behavior-level manual. It describes what the harness does, identifies the implementation sites responsible, and links the explanation to code evidence. Readers can move from a system overview to a specific behavior and then to the source. The same path supports understanding how the system works, checking whether it follows a policy, and planning changes to its behavior.
At a glance
- Organize code around behavior. Harness Handbook groups related implementation sites into behavior units and connects them to the system’s execution flow.
- Read with evidence. The three-level structure leads from the system overview to behavior details, with code links that let readers check each explanation.
- Improve code localization before editing. In the evaluated settings, judge models prefer the plans produced by coding agents using the Handbook, which also use fewer planner tokens. The experiment evaluates localization and planning before code changes.
- Review changes in Handbook Studio. Users can describe a desired behavior, inspect the resulting plan and diff, and confirm the coordinated updates to code and Handbook.
Part 01
Why does an agent harness need a behavior-level manual?
A model proposes actions, but the surrounding harness determines how those proposals become execution. It decides whether a command may run, how user confirmation is handled, and what happens after failure. Understanding an agent therefore requires examining both model outputs and the mechanisms that act on them.
These mechanisms are difficult to follow in a large codebase. The Codex snapshot analyzed in the study contains 2,267 files, more than 34,000 functions, and nearly 160,000 code connections. Together, they coordinate the model, tools, state, permissions, and execution environment. A file tree locates the components, but understanding a behavior also requires tracing the relationships between them.
A behavior-oriented view makes these relationships easier to inspect. Starting from a behavior and following its implementation evidence supports three kinds of work.
Understand
See how the harness runs
Follow one request through the full flow: what the model receives, when tools are called, how state moves, and how the system responds to failure.
Audit
Verify that behavior matches expectations
Trace the actual execution path to check permissions, confirmation logic, sandboxing, and data flow, including unusual routes that might bypass those protections.
Adapt
Build your own agent
First see which capabilities the harness already provides and which behaviors and code support them, then extend or adjust the system for your own needs.
All three goals begin with a specific behavior and then return to the code for evidence. The difficulty is that behavior and code do not map one-to-one: one behavior is often determined by implementation scattered across several modules.
Part 02
Why is one behavior scattered across so many locations?
“Ask the user before deleting a file” sounds like a simple rule. To verify how it works in code, however, you must follow a chain of decisions: does the model request confirmation, can the tool call be intercepted, where is the user’s choice recorded, and under what conditions is the deletion finally executed? Any link in that chain can change the outcome.
Each site controls part of the behavior. A function named confirmBeforeDelete() may describe a local check, but understanding the full flow also requires tracing permissions, confirmation state, tool execution, and fallback paths. These connections determine whether a request proceeds, is rejected, or takes another route.
We call the process of finding these implementation sites and their relationships behavior localization. It establishes the evidence needed to explain a behavior, audit its execution paths, or define the scope of a change. Harness Handbook makes those relationships navigable so readers can inspect them progressively and verify them against source code.
Part 03
Harness Handbook: a navigable behavior map
To support behavior localization, Harness Handbook organizes the harness at three levels: L1, L2, and L3. Each level narrows the scope, from the full execution flow to individual behavior units and their implementation details. Links to code evidence connect these explanations to the repository.
L1 · System overview. Follow a request through the harness: where it enters, which stages it passes through, how state is carried forward, and how model output becomes an action. This establishes the context for more detailed questions.
L2 · Behavior-unit overview. Break the system flow into units with defined responsibilities. Each unit records its inputs, outputs, dependencies, and key state, showing how it contributes to the surrounding flow.
L3 · Behavior-unit detail. Inspect a unit’s triggers, execution logic, state changes, and exception or failure paths. Source links identify the files and functions that support each part of the description.
An example L3 behavior unit
Return to the example of “confirm before deleting a file.” The L3 entry below expands that one-line rule into a behavior unit that can be checked item by item, covering both the normal execution path and edge cases that need separate review.
Confirm before file deletion
In this illustrative behavior unit, a deletion request first goes through permission and user-confirmation checks. The harness uses the resulting state to decide whether to execute the request or reject it.
- Trigger
- The model emits a deletion call such as
delete_file(path). - Permission rule
- Permission configuration marks file deletion as a high-risk operation that requires user confirmation before execution.
- State change
- The harness records the confirmation request and user response, then uses them to determine whether the current execution may continue.
- Execution path
- User approval → run in the
sandbox runner; rejection or lack of authorization → abort the call and return an error. - Edge cases
headlessmode, auto-approval policies, or fallback paths may change the confirmation flow and need separate checks.
tools/file_ops.py · L32–78
tools/wrapper.py · L84–128
policy/permissions.py · L15–66
runtime/sandbox.py · L40–112
state/manager.py · L40–61
Part 04
How is the behavior map generated from code?
This structure is useful only if readers can check its descriptions against the implementation. Handbook generation therefore begins with extracted program facts, then organizes those facts by behavior before producing the three-level document. Natural-language explanations remain linked to the code evidence used to build them.
Extract facts
→ program graphStatic analysis extracts files, functions, classes, call relationships, state reads and writes, configuration boundaries, and external API calls. These facts form a program graph, which records connections between implementation elements and provides the basis for organizing behavior.
Organize by behavior
→ behavior mapThe next step builds a coarse execution skeleton of the harness lifecycle and maps functions, modules, and code regions to its stages and behavior units. A proposer–reviewer loop refines this mapping, checking the stage structure, unit boundaries, and supporting code evidence.
Synthesize the Handbook
→ HandbookThe resulting map is rendered as L1, L2, and L3. The prose describes behavior, while source links, function references, and code snippets come from the extracted program facts. Readers can follow those references to verify an explanation or investigate a missing detail.
Part 05
How do you get from a behavior question to code evidence?
Once the Handbook is available, readers can begin with a behavior question and open only the detail needed to answer it. Behavior-Guided Progressive Disclosure (BGPD) follows the three levels: L1 establishes context, L2 locates relevant behavior units, and L3 provides implementation details and source links.
One evidence path, three uses
Understand: build a system-level model
- Start at L1 and L2: map the harness’s overall execution flow, state transitions, and dependencies among behavior units.
- Before opening any single file, establish the system context for the target behavior and how it connects to upstream and downstream stages.
- With that map in place, later code details stay tied to the full flow.
Audit: verify system behavior
- Auditing continues into L3, checking the unit’s triggers, permission rules, state changes, fallback paths, and code evidence one by one.
- Take file deletion: confirmation on the main path does not rule out bypasses. Every real execution path still has to match the expected policy.
- The conclusion rests on verifiable implementation evidence along the full behavior path—not on what the documentation promises.
Adapt: define the scope of the change
- When behavior must change, use the Handbook to find the relevant behavior units, implementation links, and dependency paths—then define the change boundary.
- That evidence path can then become an edit plan, reducing repository-wide search and the risk of missing a prompt, permission rule, or fallback path.
- The plan cites Handbook evidence; the coding agent still verifies and applies the changes in the repository itself.
Part 06
Does the Handbook help a coding agent find relevant code more accurately?
The evaluation isolates one use of the Handbook: locating code and planning changes. The same coding agent handles the same harness change requests, with access to the Handbook as the only difference between conditions. The planner uses NexAU with DeepSeek-V4-Pro. Evaluation stops before code edits, so the results concern localization and planning rather than the correctness of completed modifications.
Harnesses evaluated
Terminus-2 & Codex
Both harnesses come from real production code; behavior spans multi-stage control flow, tool calls, state management, and multiple modules.
Comparison setup
Agent with vs. without the Handbook
Both conditions use the same coding agent, planner LLM, and workflow. The only difference is whether the planner reads the Handbook before localization.
Judging setup
Three independent judge models
GPT-5.5, Opus 4.8, and DeepSeek-V4-Pro independently judge whether each plan identifies relevant implementation sites and proposes an appropriate scope of changes.
Evaluation metrics
Win rate & token cost
Win rate is the share of pairwise comparisons in which a condition is preferred. Token cost records the planner’s token use per case. The two metrics describe judged plan quality and the computational cost of producing the plan, respectively.
The requests cover three types of change. Q (Query) adjusts existing behavior, such as a trigger, execution timing, or control flow. CF (Cross-file) adds a capability that requires coordinated changes to schemas, processing logic, runtime behavior, and interfaces. SH (Search-hostile) targets behavior that is difficult to locate through keywords, often in mirrored implementations, fallback paths, or rarely exercised branches.
Result 1 Higher preference rates with fewer planner tokens
On both harnesses, judges prefer the Handbook-assisted plans more often, and the planner uses fewer tokens per case. These results show an improvement in judged plan quality alongside lower token consumption. The localization analysis below examines whether the plans also identify the relevant implementation sites more accurately.
Overall preference rate
% of pairwise comparisons preferred · higher is better
Planner token cost
Average planner tokens per case (M) · lower is better
Three judge models, two harnesses
Preference rate: baseline → with Handbook, by judge
Result 2 More accurate localization at file and symbol level
To examine localization directly, we compare the proposed edit sites with reference plans independently generated by Opus 4.8 and GPT-5.5. With the Handbook, recall, precision, and F1 improve in nearly every setting at file and symbol level. Wrong cases, in which the plan targets an entirely different subsystem, also decline sharply. This supports more accurate localization relative to these reference plans.
| Harness | Granularity | Metric | Baseline | Handbook | Δ |
|---|
Result 3 The advantage persists as tasks get harder
Breaking down the results by request type and difficulty shows gains beyond the simplest cases. Easy requests usually involve one main behavior unit or a few direct implementation sites. Medium requests involve coordination across units, state changes, or files. Hard requests require following indirect execution paths. The Handbook-assisted planner has higher preference rates across these groups on both harnesses.
What do these results tell us?
Understand large codebases through behavior
The results support organizing harness documentation around the behavior a user wants to inspect or change. This groups implementation sites by their role in a request, helping the planner identify relevant code across module boundaries.
Localization quality improves while token use falls
Higher recall and precision, together with fewer planner tokens, suggest more efficient localization in the evaluated settings. These metrics do not establish the correctness of a later code change, which still requires implementation and testing.
Understanding, auditing, and modifying share one evidence path
The same links from behavior to implementation can support explanation, review, and change planning. The experiment tests the planning use case; the broader workflow also gives human readers a structured route for inspecting the underlying code.
Part 07
Handbook Studio: review changes in the behavior view
The evaluation studies an agent’s use of the Handbook for planning. Handbook Studio extends the workflow to an interactive interface: connect a repository, generate its three-level Handbook, and use the behavior map to read code, verify explanations, and propose changes. The repository remains the source of truth.
Read
Handbook
The three-level handbook forms a navigable workbench: the system overview, execution stages, behavior units, and key concepts unfold layer by layer as needed. Users can also ask questions directly and, with full context, see how a behavior is triggered, executes, and affects system state.
Cross-check
Handbook ⇄ Code
Every behavior description links back to code evidence. Click a behavior unit, state variable, or execution path and a split view opens the corresponding source on the right: the left explains what happens; the right shows the implementation behind each claim.
Modify
Co-Edit
Changes also start from the behavior map. Select a behavior unit and describe the desired change; the system generates an edit plan and code diff for review. After the user confirms, the changes are written to the repository and the Handbook is updated to match.
A concrete example: temporary environment variables for one command
Consider a researcher using a Codex-based agent to run repeated data experiments. Each backtest needs its own data-source token and date range. The request is to pass environment variables to one command without affecting later commands.
Implementing this requires more than adding an env field. The command schema must accept the field, tool descriptions must expose it to the model, and the execution paths must carry it to process creation with the intended scope. Tests must cover both the interface and runtime behavior. In the example, the affected code includes ShellCommandToolCallParams, ExecCommandArgs, to_exec_params, ExecCommandRequest, process_manager, and three test files: 14 implementation sites across 10 files.
Handbook Studio maps the request to the “command execution and environment variables” behavior unit, follows its code links, and generates a plan and diff for review. A single behavior change is thus expanded into coordinated implementation changes. After the user reviews and confirms them, the code and Handbook are updated together.
- Start from a behavior question. No need to learn the repository layout first—the system places the question in the full execution flow and locates the relevant stages and behavior units.
- Verify with code evidence. The Handbook provides explanations, and source evidence lets readers check whether those explanations hold. Reading, cross-checking, and tracing take place in the same interface.
- Modify on the behavior map. State the intended change at the relevant behavior unit, review the generated plan and diff, and confirm before anything is written to the repository or synced to the Handbook.
Part 08
Takeaways
Harness Handbook connects a question about system behavior to the code that implements it. Its three-level structure gives readers a way to navigate complex control flow while keeping the implementation available for verification.
Readers
Start from the system overview and behavior-unit map to see the harness’s execution flow, state transitions, and behavior structure before diving into source.
Auditors
Follow the same path through permission rules, confirmation logic, fallback routes, data flow, and rarely exercised branches—grounding every conclusion in verifiable implementation evidence.
Developers
Use the behavior map to identify relevant files, functions, and dependencies before editing. In the evaluated planning tasks, this improves localization quality while reducing planner token use.
HANDBOOK STUDIO
Handbook Studio brings reading, code inspection, and change review into one interface. Users can follow a behavior question through to a proposed diff, then confirm updates to both code and Handbook.