Token Efficiency Encyclopedia

Write-Path Delegation

Hand a generation subtask to a separate model that writes its output directly to disk, and return only a confirmation to the orchestrator. The generated artifact never appears in the caller's context — not as a tool result, not even as a summary.

This is the output-side counterpart of Context Isolation via Subagents. Isolation keeps bulk material from entering the caller's context on the way in; write-path delegation keeps it from being produced by the caller on the way out.

Why It Saves Twice

A file the orchestrator writes itself costs on both sides of the ledger:

Delegating the write eliminates both at once. This is also why the saving is awkward to quantify: there is no baseline in which the same bytes appear on both sides of the comparison.

How It Works

  1. The orchestrator issues a spec (what to produce), a reference (an existing file to match), and a target path.
  2. A worker model generates the file from the spec, imitating the reference.
  3. A wrapper script cleans the output — stripping markdown fences and any preamble the model added — and writes it to the target path.
  4. The orchestrator receives a confirmation: path and size. Nothing else.

The reference file is not optional. Without something to pattern-match against, a worker with no project knowledge produces code that compiles against an imagined codebase: wrong imports, wrong assertion library, wrong naming. The reference is the substitute for the context the worker does not have.

The worker's system prompt must forbid decoration explicitly — output only the code, no explanations, no markdown fences — or the caller pays to parse prose it did not want.

What Delegates Well

The boundary is predictability from existing patterns:

If the correct output follows mechanically from a reference, delegate it. If it requires knowing why the surrounding code is shaped the way it is, keep it.

Verification

The orchestrator has, by construction, not read what was written. Isolation is only safe when something other than the caller's eyes checks the result:

Without a verification step, write-path delegation trades tokens for unreviewed code on disk — a bad trade in any codebase that outlives the session.

Trade-offs

Anti-patterns

See Also

Tools