Skip to content

Composing tools

After reading notes.txt, suppose the model needs to find related text notes, exclude archived notes, and read what remains. With separate tool calls, it asks for a search, receives the list, then makes another request to read selected files. Each dependent step needs another model response.

Harness lets the model express those steps as one program. The search result stays a structured value that the program can filter and pass to the next tool. The model still chooses the work; the interpreter carries out the steps that choice already specifies.

One program instead of several round trips

Section titled “One program instead of several round trips”

The model submits Scheme in scheme_repl.expr. This program finds text notes, drops files in an archive directory, then reads each remaining file:

(define paths
(filter (lambda (path)
(not
(string-contains?
path "/archive/")))
(glob "notes/**/*.txt")))
(map (lambda (path)
(list path (read_file path)))
paths)

glob returns paths; filter selects the paths before any reads begin. The later map reads each selected file and returns a structured pair-like list containing its path and contents. The glob and filter are dependent steps; after they finish, the mapped reads are independent. Procedure names come first in Scheme calls, and lambda supplies the procedure applied to each item.

This is an example of the program’s shape, not a live recorded execution: its files and results depend on the workspace. An illustrative result could look like (("notes/todo.txt" "[ ] Test\n") ("notes/ideas.txt" "Draft")). It is not output recorded from a session.

There are two top-level forms here. They run in order: the first defines paths; the second uses it. Each form produces its own result for the model. Definitions are available throughout this evaluation, but do not carry into the next scheme_repl call.

A program does not need a model decision between each known step. If a result needs interpretation rather than a specified calculation, the program can return it and let the model decide what to do next. Composition does not require predicting the whole task in advance.

The model specifies two independent reviews in one program. The interpreter starts the requests, waits for their responses, and collects the answers as values. Launching the second reviewer and assembling the results take no additional model response. The parallel review example below uses this pattern.

For a dependent handoff, the program passes the returned value into the next specified call. Tool results stay structured instead of being rewritten as a summary between steps. When the answers conflict or the next action needs judgment, the program returns them to the model.

The model spends its next response deciding what the results mean, rather than carrying them between workers. Workers investigate, implement, and review; the interpreter handles the specified dependencies and joins. The task determines which workers run and when their work ends.

JSON tool calls describe an operation and its arguments. They do not themselves express a filter over the result, a reusable function, or a dependency between several calls. Scheme provides that small computation language. Its procedures and list operations let tool results feed other tools without turning them into prose first.

Arrival is the interpreter that evaluates those expressions. It does not supply the filesystem or model providers by itself. Harness binds operations such as glob, read_file, and agent/ask to its host runtime. Arrival handles the language; Harness handles the tools, work records, and permissions.

You do not need to write Scheme to ask Harness to fix a test. The model writes these programs during its work. Operators can also submit programs through CLI eval, and extension authors use Scheme for other configurable procedures. Not every tool has to pass through a model-written program: some are exposed as direct JSON tools too.

A shell command can also combine operations, but it runs as a process with its own output format and effects. This program calls the registered tools individually and works with their returned values. It does not hide several operations inside one shell invocation.

Harness records the evaluation as a ProgrammaticJob, a container for its work. Each inner tool invocation becomes its own ToolCallJob and follows the normal authorization path. Permission to evaluate Scheme is not blanket permission to edit files or call external services.

Program contains
glob request → policy → result
filter computes over result
read request → policy → result

The program container organizes the work; authorization applies to each tool request inside it. The reference calls that individual request a “leaf.” An inner request can be refused or wait for human approval just as a direct tool call can.

Scheme has no await keyword here. The evaluator records a tool request, waits for its authorization and result, then uses that value in a dependent expression. If glob has not finished, filter does not receive a guessed list.

The file reads in the example are independent once paths is known, so map can start them without waiting for each preceding read to finish. It joins their results in input order:

glob → filter → paths
│
├─ read A ─┐
├─ read B ─┤
└─ read C ─┤
▼
results A, B, C

The branches overlap host I/O, not Scheme computation on multiple CPU threads. Calls to the same reused named worker are serialized there; fresh one-shot workers can handle independent requests concurrently.

For example, this delegates one fresh review per file:

(map (lambda (path)
(agent/one-shot/ask
'reviewer
(string-append
"Review for regressions: "
path)
:readonly #t))
(list "src/auth.ts"
"src/cache.ts"))

Each ask has its own authorization and response. Here readonly restricts the worker’s Scheme tools; it does not remove recipe-granted JSON write tools or provide filesystem isolation. See Agents and delegation before relying on that flag.

A refused or failed tool whose outer outcome reports failure raises an evaluation error; a successfully returned value can also contain its own failure fields. Ordinary REPL evaluation records a form’s error and proceeds to later top-level forms. Do not assume a failed form rolls back earlier effects.

A failure in map is not a promise to cancel every sibling call already started. Cancellation is a separate runtime action, and an external operation already on the wire may still settle. The program is not a transaction.

Running the whole program in the background lets the enclosing turn proceed once the runtime has taken responsibility for executing it. The caller receives a job ID rather than the finished value, and the turn can end while the program is still running. The work remains recorded in the session. Background release does not keep a session eligible after its clients leave; an ordinary session can still park as described in Runtime and session state. Inside that program, an agent/ask still waits for its response before a dependent expression can use it.

Harness also uses configurable procedures for policy, commands, and compaction. Their inputs and return rules depend on that interface. A compaction function returns a summary; a control-effect procedure can return a proposal or a request for the host to handle a condition.

The control-effect interface describes flat runs that return Done, Control, or Abort, with the host responsible for waiting and re-invocation. That is not a claim that scheme_repl returns before its tools finish. The REPL evaluator joins tool results so expressions can use them.

The live Scheme interface is assembled in packages/harness-scheme-runtime/src/catalog-description.ts. Evaluation and scopes are in interpret.ts; inner tool admission and joining are in env.ts in that package. Arrival’s evaluator handles asynchronous host results in packages/arrival/src/eval/evaluator.ts in the Arrival repository.

For the separate host return interface, see Control effects.