How I Built a Research Agent That Reads the Docs Before My Coding Agent Ships A developer built a read-only research sub-agent that runs before an autonomous coding agent implements a task, returning a structured Markdown brief with questions, verdict, confidence, and staleness risk. The change cut hallucinated-API failures from roughly one in five tasks to about one in forty over three months, at under 10% additional token cost. The developer attributes the improvement to splitting documentation research from code generation into separate agents with distinct tool sets rather than relying on prompting. My autonomous coding agent kept shipping code against library APIs that didn't exist, because it wrote first and read the docs never. I fixed it by adding a read-only research sub-agent that runs before implementation, returns a short structured brief, and blocks the implementer until that brief exists. Hallucinated-API bugs dropped from roughly one in five tasks to about one in forty over three months, and the extra cost was under 10% of tokens. Here's how it works and what I got wrong along the way. 🚀 I run a fully autonomous implementation system on a Mac mini. An orchestrator picks up tasks, hands them to parallel implementation agents built on Claude Code, and a self-healing agent cleans up whatever fails. It ships real code to real projects, mostly unattended. For the first few months, the single most annoying failure mode was this: The implementer confidently calls client.batchUpsert . The library has never had a batchUpsert . It has upsertMany , added in v4.2, with a different argument shape. Tests fail, the self-healing agent tries three fixes, burns 40k tokens, and finally gives up and marks the task blocked. I'd wake up to a pile of "blocked" tasks that all shared one root cause: the agent guessed an API instead of reading it. When I audited two weeks of failed tasks, the numbers were ugly: | Failure cause | Share of failed tasks | |---|---| | Hallucinated or outdated library API | 38% | | Misread existing internal code | 22% | | Genuinely hard bug | 19% | | Everything else | 21% | Sixty percent of failures were "didn't look before writing." That's not an intelligence problem. That's a process problem. What made it interesting: the implementer could read docs. It had web fetch and file tools. It just didn't, because the moment you give a capable model a task, its instinct is to start producing code. Prompting "please read the docs first" helped for about two days, then the instruction got crowded out by everything else in the context window. The fix was structural, not prompt-based. I split "figure out how this works" from "build it" into two different agents with two different tool sets. php flowchart LR O Orchestrator -- |task + question list| R Research agent