Skip to content
AgenticAIWiki
  1. Learn
  2. Part 8
  3. 43. Subagents
  4. 43.3

Lesson 43.3 · 3 of 5 · 5 min read · Reviewed 24 Nov 2026

Passing the right context to a subagent

By the end, you can

  • Write a subagent brief with the goal, the context it needs and the shape of the answer.
  • Avoid passing the parent's whole history to a subagent.

A subagentSubagent: A separate agent instance, with its own context and instructions, that a main agent delegates a task to. knows nothing except its own prompt and the brief the parent writes in the Task call. The brief is the whole handover.

What a good brief contains

  • Goal: one sentence. “Find every place the retry delay is configured.”
  • Context: only the facts it needs. “The service is in /payments. Ignore /legacy.”
  • Boundaries: what not to do. “Read only. Don’t run tests.”
  • Result shape: “Return a list of file:line, the value, and one sentence each. Under 200 words.”

Don’t pass everything

Sending the parent’s whole conversation defeats the point of isolation, costs tokensToken: The unit a model reads and writes: a word, part of a word, a space or a symbol, mapped to an integer id., and distracts the subagent with irrelevant turns. Pass the minimum.

Ask for structure

Structured, short results are easy for the parent to compare and combine: a JSON list, a table, or fixed headings. Ask for sources or file paths so the parent can check claims rather than trust them.

Key points

  • A subagent starts with no memory of the parent's conversation; it only knows what the brief says.
  • A good brief has the goal, the relevant facts, the boundaries and the exact shape of the result.
  • Ask for compact, structured results so the parent's context stays small.
Hands-on labRuns in the Playground

Lint a brief before delegating

Write a brief checker that makes sure every subagent brief has a goal, context, boundaries and a result shape, and stays small.

You will have: A brief builder, a linter, and a printed comparison of a vague brief, a good brief and a brief that pastes the whole conversation.

Steps

  1. Write make_brief(goal, context, boundaries, result_shape) that renders four labelled sections.
  2. Write lint(brief) that reports any missing section and any brief over 150 words.
  3. Check that the result shape asks for something structured: a list, a table, JSON or fixed headings.
  4. Run the linter on three briefs: a one-line vague one, a good one and one with the parent's whole history pasted in.
  5. Print the problems and word count for each.

Done when

  • The vague one-liner is flagged for all four missing sections.
  • The good brief passes with no problems.
  • The pasted-history brief is flagged as too long.

Open in the Playground No API key needed.

Starter code (Python)
SECTIONS = ["Goal", "Context", "Boundaries", "Result"]

def make_brief(goal, context, boundaries, result_shape):
    # TODO: return a string with "Goal:", "Context:", "Boundaries:" and "Result:" lines
    return goal

def lint(brief, max_words=150):
    problems = []
    # TODO: missing sections, too many words, result not structured (list, table, json, headings)
    return problems

vague = "Look into the retry settings."
print("vague:", lint(vague))
Show a solution
SECTIONS = ["Goal", "Context", "Boundaries", "Result"]
STRUCTURED = ("list", "table", "json", "headings")

def make_brief(goal, context, boundaries, result_shape):
    return f"Goal: {goal}\nContext: {context}\nBoundaries: {boundaries}\nResult: {result_shape}"

def lint(brief, max_words=150):
    problems = [f"missing {s.lower()}" for s in SECTIONS if f"{s}:" not in brief]
    words = len(brief.split())
    if words > max_words:
        problems.append(f"too long ({words} words)")
    result = next((l for l in brief.splitlines() if l.startswith("Result:")), "")
    if result and not any(k in result.lower() for k in STRUCTURED):
        problems.append("result shape is not structured")
    return problems

vague = "Look into the retry settings."
good = make_brief("Find every place the retry delay is configured.",
                  "The service is in /payments. Ignore /legacy.",
                  "Read only. Do not run tests or edit files.",
                  "A list of file:line, the value, and one sentence each. Under 200 words.")
history = "\n".join(f"Turn {i}: the user and I discussed retries, timeouts and the refund flow at length." for i in range(20))
pasted = good + "\nFull history:\n" + history

for name, b in [("vague", vague), ("good", good), ("pasted", pasted)]:
    print(f"{name}: {len(b.split())} words, problems: {lint(b) or 'none'}")
Quick checkA research subagent keeps returning long essays that fill the parent's context. What fixes it?
How sure are you?
Pick an answer and how sure you are