Designing subagents and instructions (context engineering)
Scoping subagents so the right one is selected, writing scope descriptions and instructions, using variables, avoiding overlap, guardrails and refusal behaviour, and why context engineering replaces prompt engineering.
Simple explanation
Subagents (formerly topics)
- Each covers one job to be done with a clear scope description used for selection.
- Avoid overlap: two subagents that both sound like "account questions" confuse selection.
- Keep the number of actions per subagent small and relevant β verify current limits.
Instructions
- Specific, testable statements: "If the order is more than 30 days old, explain the return policy and offer a human."
- Say what not to do and when to hand over.
- Put fixed rules in Agent Script, not in long prose.
Variables
- Hold state (verified customer ID, chosen order) and control which actions or subagents are available.
Context engineering Designing the whole context: which subagent, which instructions, which actions, which data and which variables the model sees at each step, instead of crafting one perfect prompt.
Guardrails
- An off-topic subagent or instructions for out-of-scope requests.
- Refuse unsafe or unsupported requests politely.
- Escalation paths with conversation summaries.
Real-world analogy
Subagents are departments with clear signs at a reception desk. If two signs say "Customer matters", visitors queue in the wrong place. Instructions are each department's procedures manual.
Worked example
A retailer split "orders" into two subagents after testing showed confusion: "order status and delivery" and "returns and refunds". Each has three to five actions. Instructions in the returns subagent say it must not promise refunds outside policy and must hand off for damaged high-value items.
Diagram
Key points
- One subagent per job to be done, with a clear scope description.
- No overlap between subagents.
- Instructions are specific and testable; fixed rules go in Agent Script.
- Variables carry state and gate actions.
- Design refusal and hand-off explicitly.
Limits and gotchas
- Long, vague instructions reduce reliability and increase tokens.
- Selection errors are the most common failure; test with varied phrasings.
- Instructions don't override missing permissions or bad data.
π€ How to say this in an interview
Show how you'd split subagents, write one good instruction, and test selection. Use the term context engineering.
Common follow-ups
Testing shows the wrong subagent is selected 15% of the time. What do you do?
Review misrouted utterances, sharpen scope descriptions, remove overlap, split or merge subagents, add examples, and retest.
Where do you put a rule like 'never discuss competitor pricing'?
In agent-level instructions and guardrails, and test it with adversarial prompts.