Building on Deep Agents: Keep the Harness Thin, Put the Product in Skills
Seven months running a multi-agent platform on LangGraph and Deep Agents taught us to turn 'use the framework' into four ordered questions and a living reversibility list, push agent behaviour to 160 lines of Markdown skills per line of Python, and face what happens when logic leaves code.
Building on Deep Agents: Keep the Harness Thin, Put the Product in Skills
Every team that runs AI agents in production ends up building a harness: the plumbing wrapped around the model loop that constructs agents, wires up tools and sandboxes, persists checkpoints, retries failures, and streams tokens to a UI. The tempting move in month one is to build all of it yourself. The painful discovery in month six is that the underlying framework shipped half of your custom code while you were maintaining it.
Earlier this year, our multi-agent software delivery platform had its own agent instance pool, its own sandbox pool, its own MCP tool cache, and its own session router. Meanwhile, the stack underneath us, LangChain, LangGraph, and Deep Agents, kept absorbing those exact primitives. Every custom layer we kept cost upgrade tax, created another dialect for new engineers to learn, and drifted away from the framework's assumptions.
So we wrote down a single operating rule: keep the harness as thin as the framework allows, and put our actual product differentiation into skills, prompts, and context. Seven months later, we have retired whole subsystems, pushed agent behaviour to a 160-to-1 ratio of skill Markdown to agent Python, and hit a few uncomfortable surprises about what "thin" actually costs.
The call at the center of everything
Our platform runs a roster of delivery agents (analysis, architecture, backend, mobile, web, review, advisory) serving multiple teams on shared infrastructure. Whatever wraps the model loop has to clear three bars simultaneously: multi-tenant (state, sandboxes, and credentials strictly isolated per workspace and user), resilient (survives pod restarts, provider outages, and slow tools), and observable (every model and tool call traced).
Those three words became our operational definition of "production quality."
The service itself is one Python package organized into four strict layers, checked on every pull request by import-linter: transports on top, then agents, then harness, then platform primitives at the bottom. A lower layer can never import a higher one, and agents can never import each other.
At the center sits a single call. The harness does not run an agent loop of its own. For each request, the base class constructs a Deep Agent graph and hands it our tools, middleware, sandbox backend, and subagents:
# Simplified from the agent base class
graph = create_deep_agent(
model=self._model,
system_prompt=system_prompt,
tools=self._all_tools,
checkpointer=resources.checkpointer, # framework Postgres checkpointer
backend=backend, # sandbox for shell and file tools
middleware=middleware_list, # ours, plus framework retry middleware
interrupt_on=self._get_interrupt_on(), # human-in-the-loop gates
skills=skills_path,
subagents=subagents, # resolved from our agent registry
)
Everything inside that call belongs to the framework: planning, the tool loop, subagent delegation through the built-in task tool, context summarization, and checkpointing. Everything passed into it is harness code we have to justify.

Left: four layers with one import direction enforced in CI, and the single allowed lazy-import seam in the registry. Right: the four ordered questions that decide whether a capability stays custom or gets retired to the framework.
"Use the framework" is useless until it is a decision tree
Left as a slogan, "use the framework where you can" settles zero pull-request arguments. Every engineer reads "where you can" differently. We turned it into four ordered questions, plus one living table we started calling the reversibility contract:
| Situation | Decision |
|---|---|
| Framework provides it at production quality (multi-tenant, resilient, observable) | Use it, and delete our custom code |
| Framework provides it, but not yet at production quality | Build custom behind a protocol seam and track upstream |
| Framework has it on the roadmap within six months | Build a minimal shim and plan to retire it |
| No framework equivalent, and it is plumbing | Build behind a clean seam so it can be swapped later |
| No framework equivalent, and it is context engineering | Build and own it outright |
If you cannot name the upstream feature that would retire a piece of custom harness code, you have not finished justifying why you wrote it.
The table sits next to the code, separate from the architecture decision record (ADR) so the principle stays durable while the rows evolve. Each row names the custom component, why it exists today, and the exact upstream capability that triggers retirement.
Applied across seven months, the tree produced three kinds of outcomes that surprised us:
- The clean retirements. We deleted an LRU agent instance pool (building a graph per request turned out to be cheap), removed an in-memory sandbox pool in favor of a stateless per-request factory over a Kubernetes sandbox adapter, moved model retries onto framework middleware, and swapped a custom subagent dispatch tool for Deep Agents' built-in
tasktool. That last PR added eight lines and deleted hundreds. - The disciplined decline. One worker needed an interactive discovery step that pauses, asks a person to choose from a list, and resumes inside the same child conversation. Deep Agents' native
taskdelegation is stateless. We wired it up, tested it, and ripped it out three days later before merge. "Thin" does not mean bending a framework feature into something it was never designed to be. - The hidden fifth gate: licensing. For durable background runs that survive pod restarts, the framework vendor's hosted service cleared every technical bar. Its license terms ruled it out for our production deployment. We built durable runs in-house behind a seam and tracked it on the inventory anyway. Licensing is not one of the four questions on paper, yet in enterprise infrastructure it acts as a fifth gate every time.
Notice what accepting a framework concept actually requires. After we deleted our custom dispatch tool in favor of task, a follow-up ticket proposed overriding the subagent to share parent context and run a smaller model. A platform architect closed it: by design, subagents exist to isolate context. Half of keeping a harness thin is accepting the framework's mental model instead of recreating your old abstraction on top of it.
What "thin" did not fix
I want to be honest about the ledger, because architecture posts love showing the clean diagram and hiding the messy scorecard.
A thin harness is not the same thing as a small harness. Seven months in, our shared harness is still roughly the same size as all of our agents combined. The inventory of custom harness components did not shrink; it more than doubled, from six rows to fifteen. Every row has a named exit, so the rule did its job of forcing justification, but enterprise policy middleware, guardrails, identity plumbing, and durable runs do not vanish just because you wrote an ADR. Only about one in six middleware layers we attach to an agent comes straight from the framework unmodified.
Three other operational cracks showed up:
- Scheduled reviews quietly die without an owner. Our ADR called for revisiting the inventory on every minor framework release or once a quarter. Seven months later, zero scheduled reviews were on the record. Upgrades happened when a bug or a cost spike forced our hand, not when a calendar fired.
- Private imports creep in through the cracks. Five imports reached into private framework modules, and two agents imported one directly past the harness wrapper. Because our framework dependency was pinned with a floor (
>=) instead of a cap, any patch release could break those seams silently. - A single code owner slows the seam. Having one reviewer approve every change across harness, platform, and transports kept the architecture coherent, until an emergency fix to an over-eager guardrail sat waiting in queue. When our own leak filter suddenly replaced four out of five governance replies with refusals across three models, writing the fix took minutes; landing it through a single-owner gate took far longer.
Even our dependency list tells the story. A thin harness does not eliminate coupling; it moves coupling into pinned lines you can read and test:
# Simplified from pyproject.toml
"fastmcp==4.1.6", # Exact pin: rerun the MCP contract suite on every bump
"kubernetes>=35.0.0,<36", # v36 breaks in-cluster auth
"deepagents>=0.7.32", # Required for model profiles that set summarization triggers
The other half of the rule: fat skills, boring agent code
If the harness stays thin, where does the actual intelligence go? Into the one layer the rule explicitly told us to build and own: context.
In our platform, an agent is a folder: a YAML manifest declaring identity, model tier, and allowed tools; a system prompt; a directory of Agent Skills (SKILL.md files that the framework indexes by name and description and lets the model read on demand); and an optional Python class.
When I audited Python versus skill prose across twelve production agents between April and November, the roster split cleanly into two families:
| Agent family | Share of roster | Python per agent | Skill prose |
|---|---|---|---|
| Prompt- and skill-driven agents (analysis, architecture, backend, mobile, web, review, advisory) | 8 of 12 | A few dozen lines on average (one has zero) | ~160 lines of skill text per line of agent Python |
| Code-first agents (specialist router and upgrade workflow graphs) | 4 of 12 | Hundreds to thousands of lines | Little or none |
A typical skill-driven agent class looks almost comically boring:
# Simplified from a production agent class
class BackendAgent(AbstractGraphAgent):
def _get_prompt_name(self) -> str:
return "backend"
def _get_llm_identifier(self) -> str:
return "backend_agent"
def _get_model_defaults(self) -> dict[str, Any] | None:
return {"max_tokens": MAX_OUTPUT_TOKENS}
def _build_custom_middleware(self) -> list:
return [IdentityMiddleware()]
Over seven months, total skill prose grew roughly sevenfold and the number of skills nearly tripled, while total Python across those skill-driven agents stayed flat even as the number of agents doubled. About two thirds of pull requests that added a skill touched zero production Python. One agent's entire multi-step design workflow landed across roughly a dozen pull requests over six weeks, touching code only once to hide a framework built-in tool.
I wrote earlier about SkillOpt treating a skill file like a trainable parameter, and about how agent memory files act as unreviewed config. Seeing a real multi-agent system reach 160 lines of Markdown per line of Python makes that reality concrete: the Markdown is the product.
One command, three homes (and the hidden test bill)
Moving logic out of Python and into Markdown sounds clean until you watch a real feature make the jump. Our clearest case was a /plan command on our backend agent, where a developer asks for an implementation plan instead of a quick answer.

Three homes for the same decision ("is this a plan request?"). Moving logic from Python to Markdown deleted the unit tests and forced an eval-dataset rewrite.
- Stage 1: forced in middleware. A custom
CommandsMiddlewarescanned user text for/plan, read the plan skill off disk itself, and injected a fakeread_multiple_filestool call and result into the message stream so the model never had to decide. It worked, and it violated our layering rule because agent-specific logic was sitting inside the shared harness. - Stage 2: moved into prompt text. An engineer deleted hundreds of lines of middleware and tests, replacing them with a mode table in the system prompt so the model read the plan skill on its own. Two days later, we reverted it. Not because the design failed, but because the behaviour shifted: the agent now asked clarifying questions before drafting a plan instead of dumping one in a single turn. Our regression eval datasets still expected the old one-turn contract, so the pull request's eval check went red. We had to land updated eval datasets first, then re-land the agent change two and a half weeks later.
- Stage 3: handed to the caller. A month later, the single MCP tool split into two explicit tools,
askandplan. The transport stamps[INTERACTION_MODE: plan]into context, and the prompt treats that signal as final. All planning procedures stayed in Markdown; the binary mode switch moved to the one party that already knew the answer for certain.
When logic leaves Python for Markdown, its unit tests vanish with the diff, and your evaluation datasets become the test suite. Nobody budgets for rewriting eval expectations when they estimate a "prompt cleanup" ticket. We learned to put the dataset update in the same merge plan.
What must stay in code (and where fat skills bite back)
"Fat skills" does not mean "skillify everything." Four things consistently resisted moving into Markdown:
- Allowlists and hidden built-ins. Which tools an agent may call belongs in manifest configuration checked by CI, never in prose. (Where the manifest lacked a switch to hide a framework built-in like the to-do tool, we had to fall back to a small code hook.)
- Known-input routing. When a request already names the target platform, a tiny routing table in code filters to that platform's skills and tools. Asking a model to guess something the payload already states adds error rate for zero upside.
- Order and human approval gates. If step B must never run before a person signs off step A, put the gate in a graph edge. Prose can only ask politely. (Part 2 of this series is the full story of what happened when we forgot that rule.)
- Deterministic verdicts and fingerprints. Skills can reason and classify, as long as anything that decides a gate or needs exact replay passes through code or a named verifier.
And fat skills carry their own token economics trap. When one agent's monolithic skill was refactored into a small router skill plus reference files to save context, median cost per case on one request type jumped by more than a third and tool calls per case doubled, with quality scores unchanged. Fewer tokens per file does not automatically mean fewer tokens per run.
One other payoff of enforcing the four layers early showed up when a second internal product (a suite of critique and red-team agents) wanted our hardened harness without bundling our first product's agents. Because import-linter kept the harness completely free of agent imports except for one deferred call in the registry, splitting the harness into a zero-agents distributable package with Python entry-point discovery turned out to be a packaging change rather than a rewrite. That split is still a proposal because the business premise (whether both products truly need separate quotas, tenancy, and on-call rotas) is harder than the code seam. Enforcing clean layers early buys you that option before you know you need it.
What I am still going back and forth on
I am still split on how far "skills replace routing code" should go. We have a proposal on paper to replace our 500-line specialist classifier graph with a single manifest-only front-door agent: skills by default, subagents only when context isolation shows a measured gain, and deterministic workflows launched via a tool. It is clean on a whiteboard, and completely unmeasured. Running one capable frontier model on every turn can easily beat a small classifier plus specialist on latency and UX, or blow past it on p95 cost. Until both run head-to-head on the same eval suite, I do not trust either intuition.
I also still wonder whether a living inventory of custom harness components can ever survive real sprint pressure without an explicit quarterly owner. Writing a retire condition in a wiki page is good hygiene; putting it in a comment right beside the module, or wiring an automated check when a pinned dependency bumps, is probably the only version that lasts.
Own the context, rent the plumbing
Start with four questions before you write harness code, put every exception on a list with its exit condition, and push everything domain-specific into reviewed Markdown backed by evals.
A framework will eventually ship a better retry loop, a better sandbox adapter, and a better MCP client than the one you wrote in a hurry last spring. It will never ship your domain judgment. Keep the harness thin enough that you can throw away your plumbing when upstream catches up, and thick where the actual product lives.
Next in this series: Deep Agents Orchestrator-Worker Pattern: What Survived in Production, on what happened when we put a model orchestrator in charge of a 50-service enterprise upgrade.