Research-Driven Agents: What Happens When Your Agent Reads Before It Codes

Alex Kim ยท article ยท 2026-04-09 source โ†— Reader ๐Ÿ–ฅ๏ธ

Agentic LoopCoding AgentsContext EngineeringRecursive Self-ImprovementTaste & Judgment
Coding agents generate better optimizations when they read papers and study competing projects before touching code, because a codebase tells you what the code does but not why it's slow or what alternatives exist outside the repo โ€” and the quality of an agent's hypotheses is bounded by the quality of its context.

practical ยท mixed โ€” Practical: argues for a specific architectural change to coding agent loops (add a research phase). Mixed form: part technical case study with concrete benchmarks, part generalizable methodology recommendation. The evidence is unusually specific โ€” actual code diffs, benchmark numbers, cost breakdowns โ€” making it one of the more rigorous agent-capability posts available.

Structure

PartRole
Where code-only context works (Liquid template engine case)Establishes the baseline โ€” shows that code-only agents CAN work when the optimization surface is visible in the source. This prevents the argument from overstating the research phase's necessity.
Where code-only context breaks down (llama.cpp Wave 1 failures)Primary evidence for the problem โ€” the agent tried SIMD micro-optimizations and got ~0.8% gains at best, because it couldn't know from code alone that the bottleneck was memory bandwidth, not compute
Adding a research phase (papers, forks, competing backends)The intervention โ€” describes the architectural change to the agent loop
What the research turned up (ik_llama.cpp, Blockbuster paper, CUDA backend analysis)Evidence that external context produces qualitatively different hypotheses โ€” the agent started asking 'can I fuse operations?' instead of 'can I make this loop faster?'
The five optimizations that landed (softmax fusion, RMS norm fusion, adaptive parallelization, graph-level fusion, flash attention KQ fusion)Concrete evidence โ€” each optimization traced to a specific insight from the research phase, with before/after code and benchmark numbers
What didn't work (25 failed experiments, benchmark bug, noisy VMs)Credibility and methodology โ€” honest about the failure rate (5/30+), the debugging challenges, and the measurement problems. This section is unusually candid for a product blog.
Try it on your own project (setup instructions, candidate projects)Call to action โ€” positions this as a reusable methodology, not a one-off result

Key terms

Propositions

Arguments

Coding agents should read before they code โ€” a research phase that studies papers, forks, and competing implementations produces qualitatively better hypotheses strength: high
Explicit premises:
Implicit premises:
Inferences:
Agents have a systematic weakness in calibrating confidence against their own instrumentation strength: medium
Explicit premises:
Implicit premises:
Inferences:

Narratives

Questions addressed

Gaps

Related documents