Sub topic 7
Writing a good delegation brief
A delegation brief is the message an orchestrating agent sends to a subagent to define its task. It is the only thing the subagent sees. This chapter shows what a brief must contain, how to check one before sending it, and which mistakes cause the most rework.
This chapter assumes you know what a subagent is, that it runs in its own context window, and that you can read short Python and shell snippets. It builds on context isolation and task decomposition from earlier chapters.
Why the brief matters
A subagent starts with an empty context. It does not see the parent's conversation, the files the parent has read, or the decisions the user made earlier. If a fact is not in the brief, the subagent either does not know it or has to guess.
This is the main trade-off of delegation. Isolation keeps the parent's context small, but the parent must pay for it by writing down what the worker needs. A vague brief produces a confident answer to the wrong question. The parent then spends more effort finding and fixing the problem than it saved by delegating.
A useful test is to imagine handing the brief to a capable contractor who has never seen your project. Could they start work and finish without asking you anything? If not, the brief is incomplete.
The six parts of a brief
A solid brief has six parts. Each one prevents a specific failure.
| Part | Question it answers | Failure it prevents |
|---|---|---|
| Goal | What outcome is wanted? | The worker solves a different problem |
| Context | What must the worker know? | The worker guesses at facts or re-explores the codebase |
| Scope | Which files or areas may it touch? | Edits that collide with other workers or break unrelated code |
| Constraints | What must it avoid? | New dependencies, style violations, network use |
| Done when | How will it know it is finished? | Stopping too early or never stopping |
| Return | What should it send back? | Replies that flood the parent's context |
Here is a complete brief for a testing task:
Goal: Add unit tests for the parse_args function in src/cli.py.
Context: parse_args builds an argparse parser with --verbose and --output options. Tests live in tests/ and use pytest.
Scope: Create or edit only tests/test_cli.py. Do not change files under src/.
Constraints: Do not add new dependencies. Tests must run offline.
Done when: pytest tests/test_cli.py passes.
Return: A short summary of the tests added, the command you ran to check them, and its result. Do not paste full file contents.The sections below go through each part.
Goal
State the outcome, not the activity. "Add unit tests for parse_args" names a result. "Look at the CLI code" names an activity and gives the worker no way to know when it is finished.
Keep to one goal per brief. If you find yourself writing "and also", you probably have two tasks that should be separate subagents, or a task that needs another round of decomposition.
Context
Include only what the worker cannot easily discover and what changes how it works. Good context items are:
- The relevant file paths and function names.
- The test framework and how to run it.
- Decisions already made, such as "we chose argparse over click".
- Known traps, such as "the config loader reads environment variables at import time".
Do not paste the whole conversation. Long context in a brief defeats the purpose of isolation, and the worker may treat irrelevant details as instructions. Point to files instead of pasting them when the worker can read them itself.
Scope
Scope lists what the worker may change, and it often helps to list what it must not change. In parallel runs, scope is what keeps workers from editing the same file. If two briefs both allow edits to src/cli.py, you have a conflict waiting to happen, so fix the briefs or use separate workspaces.
Scope in a brief is a request, not a lock. The worker can still break it. Enforcement comes from tool permissions and from separate branches or worktrees, which are covered in later chapters. Treat the brief as the first line of defense and review the diff as the last.
Constraints
Constraints cover rules that apply no matter how the worker solves the task. Typical examples are no new dependencies, no network access, keep the public API unchanged, and follow the existing code style. Give the reason when it is not obvious. "Do not use print; the project logs through logging" lets the worker apply the rule correctly in cases you did not foresee.
Done when
A finish condition must be checkable. "The code looks good" is not checkable. "pytest tests/test_cli.py exits with code 0" is. Prefer a command the worker can run itself, because then it can verify its own work before replying.
A checkable condition does not prove the work is correct. A test suite can pass because the worker weakened the tests. Verification by the parent is a separate step, covered in a later chapter.
Return
The worker's reply goes into the parent's context, so its size and shape matter. Say exactly what to send back: a short summary, the commands run, their results, and the paths changed. Ask for paths instead of full file contents, since the parent can read the files if it needs them. If the parent will process replies in code, request a fixed structure so parsing is reliable.
Sending briefs from an orchestrator
When a script orchestrates workers, the brief is plain data. The example below runs two independent tasks at the same time. The worker receives only the brief string, never the parent's history.
import asyncio
from dataclasses import dataclass
@dataclass
class Task:
name: str
brief: str
async def run_subagent(task: Task) -> dict:
# Placeholder: replace with a call to your agent runtime.
# The subagent receives only the brief, not the parent's history.
await asyncio.sleep(0.1)
return {"name": task.name, "status": "ok", "summary": f"finished {task.name}"}
async def orchestrate(tasks: list[Task]) -> list[dict]:
outcomes = await asyncio.gather(
*(run_subagent(t) for t in tasks), return_exceptions=True
)
results = []
for task, outcome in zip(tasks, outcomes):
if isinstance(outcome, Exception):
results.append({"name": task.name, "status": "failed", "summary": str(outcome)})
else:
results.append(outcome)
return results
if __name__ == "__main__":
tasks = [
Task("update-docs", "Update README usage section for the new --verbose flag."),
Task("add-tests", "Add unit tests for parse_args in tests/test_cli.py."),
]
for result in asyncio.run(orchestrate(tasks)):
print(result)The two briefs in __main__ are short on purpose, to keep the example readable. In real use each would carry all six parts. Notice that their scopes do not overlap: one edits the README and the other edits a test file. That separation is what makes running them together safe.
Passing return_exceptions=True means one crashed worker does not cancel the others. The orchestrator records a failed status and continues. Handling those failures is a later topic.
Common errors
- The brief assumes shared memory. Phrases like "as we discussed" or "the file from before" point to context the worker lacks. Name the file and state the decision.
- The brief describes a method, not a result. Over-specifying steps removes the worker's ability to adapt. Specify the outcome and the constraints, and leave the steps to the worker.
- No finish condition. The worker stops at a plausible point, or keeps adding changes. Add a command it can run.
- Overlapping scopes. Two workers edit the same file and one overwrites the other. Split scopes, or give each worker its own git worktree.
- Unbounded returns. Asking to "report everything you did" fills the parent's context with the detail you tried to keep out. Ask for a summary and paths.
- Hidden constraints. A rule that exists only in your head gets broken. If a violation would be costly, write it down.
A pre-send checklist
Before dispatching a brief, check:
- Could a newcomer to the project start from this text alone?
- Is there one goal, stated as a result?
- Do the scopes of all briefs sent at the same time avoid overlap?
- Can the worker run a command to confirm it is done?
- Does the return format keep the reply short?
A brief that passes all five is usually good enough. If a worker still goes wrong, read the brief again before blaming the worker. Most failures trace back to something the brief left out.
Exercise
An orchestrator sends two parallel briefs. Brief A says "Refactor the config loader in src/config.py so it is easier to read." Brief B says "Add a --timeout option to the CLI; you may edit src/cli.py and src/config.py." Name three problems and say how you would fix them.
Show answer
First, Brief A has no checkable finish condition, since "easier to read" cannot be tested. Add a condition such as "existing tests in tests/test_config.py still pass and the public function signatures are unchanged." Second, both briefs allow edits to src/config.py, so the workers can overwrite each other. Narrow the scopes so only one touches that file, run the tasks in sequence, or give each worker its own git worktree. Third, neither brief states a return format or constraints, so replies may be long and unpredictable. Add a short summary format that asks for paths changed and the command run, and add constraints such as no new dependencies.
Exercise
Why should a brief ask the worker to return file paths and a summary instead of the full contents of the files it changed?
Show answer
The worker's reply is added to the parent's context window. Full file contents use up space that context isolation was meant to save. The parent can read any file itself when it needs to review the change, so paths and a short summary give it what it needs at lower cost.