Sub topic 7
Writing a good delegation brief
This chapter assumes you know what a subagent is and that it starts with a fresh context. You should also be comfortable reading a short task description for a coding project.
Why the brief matters
A subagent cannot see the parent's conversation. It does not know which files you discussed, which approaches you rejected, or what "done" means for this task. The brief is the only thing it receives. If a fact is missing from the brief, the subagent will guess.
Most failed delegations trace back to a brief that felt complete to the writer because the writer remembered the missing context.
The six parts of a brief
A useful brief has six parts:
| Part | Question it answers |
|---|---|
| Goal | What outcome do I want? |
| Context | What does the subagent need to know about the code? |
| Scope | Which files may it touch, and which are off limits? |
| Constraints | What rules apply, such as dependencies or offline tests? |
| Done when | What check proves the work is finished? |
| Return | What should the reply contain, and in what shape? |
A worked example
This brief delegates test writing for a command-line parser.
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.Each line removes a guess. The scope line stops the subagent from "fixing" src/cli.py when a test fails. The finish condition is a command, so the subagent and the parent can both check it. The return line keeps the reply short, which protects the parent's context.
Common errors
- Vague goals. "Improve the tests" has no finish line. Name the function, the behavior, or the file.
- Missing context. Phrases like "the bug we discussed" mean nothing to the subagent. Restate the facts.
- Open scope. Without a file boundary, parallel subagents may edit the same files. Scope is also your first defense against conflicts.
- Unverifiable completion. "Make sure it works" is not checkable. "
pytest tests/test_cli.pypasses" is. - No return format. The subagent may paste whole files back, filling the parent's context and defeating the purpose of delegating.
Building briefs in code
An orchestrator can build briefs from a template so every brief has all six parts. This helper raises an error if any part is empty.
from dataclasses import dataclass, fields
@dataclass
class Brief:
goal: str
context: str
scope: str
constraints: str
done_when: str
returns: str
def render(self) -> str:
for f in fields(self):
if not getattr(self, f.name).strip():
raise ValueError(f"brief is missing: {f.name}")
return "\n\n".join(
f"{f.name.replace('_', ' ').capitalize()}: {getattr(self, f.name)}"
for f in fields(self)
)
if __name__ == "__main__":
brief = Brief(
goal="Add unit tests for parse_args in src/cli.py.",
context="parse_args uses argparse with --verbose and --output. Tests use pytest.",
scope="Edit only tests/test_cli.py.",
constraints="No new dependencies. Tests run offline.",
done_when="pytest tests/test_cli.py passes.",
returns="Summary of tests added, the check command, and its result.",
)
print(brief.render())Rejecting an incomplete brief before the subagent starts is cheaper than discovering the gap after it has spent time and tokens.
Exercise
A brief says "Fix the failing login test and clean up anything related." Which two of the six parts are weakest, and how would you rewrite them?
Show answer
Scope and Done when are weakest. "Anything related" lets the subagent edit unknown files, and no check defines completion. Rewrite scope as "Edit only tests/testlogin.py and src/auth/login.py", and the finish condition as "pytest tests/testlogin.py passes with no other test files changed."