# Inside DeepWiki: How Cognition Builds Wikis for Devin at Scale <!-- ref: @content/youtube/langchain/2026-08-21-inside-deepwiki-how-cognition-builds-wikis-for-devin-at-scal version: 3 updated_at: 2026-10-31T19:29:45.869Z --> Jacob (LangChain, 2026-08-21): Jacob argues that generating a genuinely useful codebase wiki is not just "prompt a coding agent to write docs" — at enterprise scale it requires deterministic pre-computation (heuristic file scoring, codebase graphs, clustering) to produce a good table of contents, because… *Synthesized from Jacob (Cognition) on LangChain, 2026-08-21.* Jacob works at Cognition on DeepWiki, the auto-generated codebase documentation product that also serves as the context layer behind Cognition's cloud coding agent, Devin; this talk was hosted by LangChain with Brace and the LangChain team. ## Core Thesis Jacob argues that generating a genuinely useful codebase wiki is not just "prompt a coding agent to write docs" — at enterprise scale it requires deterministic pre-computation (heuristic file scoring, codebase graphs, clustering) to produce a good table of contents, because the table of contents determines the quality of everything written after it. He also frames the RAG-versus-agentic-search debate as a false dichotomy: pre-computed wikis, user-defined knowledge, and live MCP data are all context sources that augment an agent rather than replace its search. The open frontier, in his view, is "unknown unknowns" — the facts an agent would never discover on its own — which is why fully agent-driven approaches still fall short and orchestration and human judgment still matter. ## Key Insights - **Origin: built for the agent first, humans second.** Over a year ago, the first iteration of DeepWiki was built to give Cognition's main agent better *macro* understanding of a codebase. Only after building it did the team notice humans liked reading it — for onboarding and repo Q&A — so it shipped as a product. - **Scale of the public index.** Cognition indexed the top 100k GitHub repos to seed deepwiki.com; today roughly **1.4 million repositories** are indexed and the service has served **over 20 million queries**. The access pattern is a URL swap: change `github` to `deepwiki` in any repo URL. - **The enterprise constraint that breaks naive agent-driven generation.** Jacob cites customers with a **single repo at ~20 GB and tens of millions of lines**, and orgs with **~100k repos** scaling horizontally where one project may touch **~1,000 repos at once**. Running a full agent swarm across that is impractical on both cost and latency. - **The table of contents is the hardest part.** Once the ToC is set, it dictates what gets written, how codebase pieces connect, and what gets cross-linked. Jacob says early wiki-algorithm failures traced to generating the wrong contents page — after which no amount of good per-page writing rescues the wiki. - **Three things the ToC must resolve:** which systems are key and which people actually care about; coverage triage (you can't cover the whole codebase, so what deserves inclusion); and canonical terminology — which is why every DeepWiki ends with a **glossary section**, useful to both humans and agents. - **Heuristics before LLMs.** Cognition scores files and file-to-file connections using directory structure, the symbol graph, git history, and even runtime data where available. The point is to *quantify* importance rather than let an LLM trawl the repo, because quantification is what makes the process viable at scale. - **Graph → clusters → ToC → fan-out pages.** Scored connections become codebase graphs; clustering over those graphs yields the candidate systems the wiki will track. Jacob showed graphs for a small repo and for the full LangChain repo, framing the graph as a first-pass breakdown that informs how the agent structures its output. - **v1 vs v2: orchestration-led to agentic core.** v1 (built over a year ago) was heavily orchestration-led with weaker models — tight control over every model call and manual context construction. v2 hands that thinking to an agent that starts from the same scored-and-clustered graph, then adapts when it hits abnormalities in the codebase. Scaffolding like *pulling extra clusters* or *scoring extra files* became **tools the agent calls on demand** rather than fixed pipeline stages. - **Same models, better architecture, cheaper.** Jacob emphasizes v2's quality jump came from architecture, not model swaps — roughly the same model family with version upgrades. The agentic version also produced **cost savings**, largely via better cache performance. - **The constraints that didn't change.** Between v1 and v2, model context limits remained the single biggest bottleneck for wiki-style output, alongside real customer budget constraints and human attention spans. - **Quantitative wiki-health metrics.** Cognition checks whether the top most-active files (by its own scoring) are actually covered; measures citation *depth* and citation *quality*; and tracks the **correlation between wiki size and repo size** — early versions capped wiki size on very large repos, so bigger repos should yield larger and deeper wikis rather than a fixed ceiling. - **Qualitative eval is human-in-the-loop.** Beyond metrics, the team tuned the algorithm by working with its largest customers on their real codebases and with senior engineers who knew what they were looking for in their own repos. - **Primary sources vs derived artifacts.** A primary source is ground truth — code files, commits. A wiki is *derived*, and each additional layer of summarization or rephrasing loses meaning and adds error. Jacob's related rule on context poisoning: for agent-facing wikis, **omitting a fact beats including one that might send the agent down a wrong path**. - **Two modes of useful context.** *Path compression* front-loads something the agent could have found itself in a few grep steps — saving context, tokens, and cost, with modest performance upside but a real risk of misdirection if wrong. *Unknown unknowns* supply what the agent would never have found — a tiny piece of knowledge in the codebase or elsewhere. Jacob calls unknown unknowns by far the biggest unsolved problem in context engineering, and the reason you can't just hand an agent tools and expect it to figure everything out. - **Functionally correct ≠ good software engineer.** On Cognition's recently released **Frontier Code** eval, the question isn't just whether the task is correct but whether the code would be **accepted in a PR by that open-source project's maintainer** — and even Fable scores around **50%**. Jacob's read: the information needed to infer the codebase's patterns is already available to the agent; it just isn't using it yet, and wiki-style pre-computation is a promising way to unlock that. ## Actionable Takeaways 1. **Try DeepWiki by URL substitution.** For any indexed public repo, replace `github` with `deepwiki` in the URL to get auto-generated codebase documentation plus a Q&A interface backed by Devin. 2. **Spend your effort on the table of contents, not per-page prose.** Before generating any pages, decide which systems are key, triage what deserves coverage, and lock canonical terminology. A wrong ToC produces a bad wiki regardless of page-level writing quality. 3. **Always include a glossary section** at the end of the wiki to pin down canonical codebase terminology — it serves human readers and agent consumers equally. 4. **Pre-compute a scored codebase graph before invoking the agent.** Score files and file connections using directory structure, symbol graph, git history, and runtime data when available; cluster the graph into candidate systems; use that as the agent's first-pass input rather than letting it explore blind. 5. **Follow the v1→v2 arc: as models improve, stop micro-orchestrating and start supplying context.** Convert former pipeline stages (pull extra clusters, score extra files) into tools the agent calls when it needs them, so it can adapt to codebase abnormalities on its own. 6. **Instrument wiki quality with concrete metrics:** coverage of your top-scored most-active files, citation depth, citation quality, and the wiki-size-to-repo-size correlation — watch specifically for a size cap on very large repos. 7. **Validate with senior engineers on their own repos.** Metrics don't settle "is this valuable"; sit with experienced engineers who know what they're looking for in a specific codebase and tune the structure to what they expect. 8. **Keep agents pointed at primary sources** (code files, commits) and treat derived wiki text as lossy. When writing agent-facing context, prefer omission over anything possibly incorrect — context poisoning actively degrades performance. 9. **Classify each piece of context you add** as either path compression (saves steps the agent would have taken) or an unknown unknown (something it could never find). Expect modest, risk-bearing gains from the first and the largest upside from the second. 10. **Don't treat RAG and agentic search as an either/or.** Combine pre-computed wikis, user-defined knowledge, and live MCP data sources — Devin uses both indexing and agentic search — and frame every added source as augmenting the agent, not replacing its work. ## Notable Quotes > "The hardest part of creating a wiki is actually the table of contents." — Jacob > "As the models improve, you want to focus less on orchestrating the agent at such a micro level." — Jacob > "Not putting something that is incorrect is better than providing something that might mislead the agent." — Jacob > "Unknown unknowns — I think this is by far the biggest unsolved problem in terms of context engineering." — Jacob > "Codebase intelligence is very far from solved, and it's something we're actively working on at Cognition." — Jacob --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*