Workflows, Skills, and Sub-agents: context isolation engineering
If we already have Agents and MCP, why did engineers invent Workflows, Skills (SKILL.md), and Sub-agents?
When developers attach 50 MCP tools and massive rulebooks to an Agent, disaster strikes: tool schemas alone eat tens of thousands of tokens before work even starts, and 15 turns of search/debug logs flood the main context window—causing sky-high costs and degraded reasoning.
Three patterns tame context bloat: 1) Workflow: lock deterministic steps into fixed code scripts; 2) Skill (SKILL.md): keep only a 1-line index in the main prompt and lazy-load detailed instructions/scripts only when triggered; 3) Sub-agent: delegate noisy 20-turn search/debug subtasks to an isolated child context that returns only a clean 200-word summary!
Attention sums to 100%: prune noise, sandbox untrusted data, compact logs, and enforce JSON schemas
Upgrade from ad-hoc prompt tweaking to rigorous signal-to-noise engineering over the context window.
Filter Low-Score RAG Chunks & Compact Verbose Tool Logs
Every irrelevant token dilutes Softmax attention away from critical constraints.
Wrap Untrusted Documents in Data Tags and Enforce Privilege Hierarchy
Prevents indirect prompt injection hidden inside retrieved web pages or files.
Mask Invalid Grammar Tokens at Sampling Time for 100% Valid JSON
Guarantees machine-parsable payloads without brittle regex post-processing.
First-principles breakdown: three steps
Deterministic Steps → Lock into Workflows
Never pay an LLM to improvise a fixed pipeline; lock deterministic file parsing and formatting into scripts.
Long Domain Rules → Package as Lazy-Loaded Skills
Instead of stuffing every SOP into the system prompt, let the Agent read the relevant SKILL.md and helper scripts only when needed.
Noisy Multi-Turn Exploration → Isolate in Sub-agents
A Sub-agent runs file searches and retries in its own disposable context window, returning only the distilled answer to the parent.
Switch between [Monolith All-In], [Fixed Workflow], [On-Demand Skill], and [Isolated Sub-agent] in the sandbox to compare main context token watermarks and adaptability.
Compare all 4 patterns: Skills lazy-load instructions on demand, while Sub-agents isolate noisy multi-turn tool logs in a separate context.
Workflow vs. Autonomous Agent
In a Workflow, code dictates the step order; in an Agent, the model loops and decides which tool to call next.
If a task follows a fixed recipe, use a deterministic Workflow rather than an unconstrained Agent.Agent Skill (SKILL.md)
A folder holding domain instructions (SKILL.md) and scripts that the Agent reads on demand instead of bloating every prompt.
Stripped of hype, a Skill is simply lazy-loaded modular prompting plus helper scripts.Sub-agent & Agent Harness
Sub-agents are disposable workers for context isolation; the Harness is the outer runtime managing loops, permissions, and retries.
Clean context isolation and a rock-solid harness are the real secrets behind top coding agents.Workflows hardcode deterministic steps; Skills lazy-load instructions on demand; Sub-agents isolate noisy multi-turn work from the main context.
When a parent Agent delegates “search 30 files to locate a function definition” to a Sub-agent, what is the primary architectural benefit?
Explanations, cases, and exercises are authored by Reallier. Links provide further learning. The workplace activity and people are fictional.