Agent-Optimized Documentation Generation with OpenWiki CLI

LangChain2026
View original source

LangChain developed OpenWiki, an open-source CLI tool that generates and maintains repository documentation specifically optimized for AI agents rather than human consumption. The problem addressed is that traditional documentation is designed for human readers with narrative flow and visual elements, while AI coding agents need self-contained, retrievable fragments with predictable structure. OpenWiki automatically generates markdown-based wikis following Google's Open Knowledge Format with structured front matter, cross-references, and change logs, then maintains them through automated GitHub Actions. Early evaluation on DeepSWE benchmarks showed 30-40% reduction in token consumption and tool calls while maintaining or slightly improving task success rates, demonstrating more efficient agent navigation of codebases.

Industry

Tech

Technologies

OpenWiki represents LangChain’s approach to solving a fundamental challenge in production LLM systems: providing AI coding agents with optimized context about codebases. The project emerged from a strategic question posed by the CEO about what would be the next major advancement in AI after personal agents, with the answer being general-purpose memory systems. Rather than attempting to solve memory broadly, the team focused on code-based documentation as a well-defined domain where a general-purpose solution could be built and later expanded.

Core Thesis and Design Philosophy

The project is built on three foundational principles that differentiate it from traditional documentation approaches. First, the documentation is explicitly built for agents rather than humans. This represents a significant paradigm shift in how documentation should be structured. Traditional documentation for humans requires narrative flow, storytelling elements, quick-start guides with background context, cohesive page-level narratives, and visual elements like screenshots and videos. In contrast, agent-optimized documentation requires self-contained concepts since agents retrieve fragments rather than reading entire pages, predictable and precise headings to enable effective filtering and searching, and optimization for context window constraints to avoid including token-heavy elements like base64 strings that could consume 50,000 tokens unnecessarily.

The second principle centers on developer experience and adoption. As a developer tool, OpenWiki needed trivial setup with minimal friction. The CLI approach was chosen specifically because it represents familiar territory for developers and enables single-command installation through NPM and single-command initialization. The third principle addresses the maintenance challenge: documentation must update itself automatically. While generating initial documentation is relatively straightforward with modern LLMs, keeping documentation synchronized with evolving codebases without manual intervention represents the harder technical problem.

Technical Implementation and Architecture

OpenWiki generates a structured set of markdown files following a specific pattern inspired by Andrej Karpathy’s LLM wiki. Every wiki includes a quickstart.md file that provides high-level repository overview and serves as the entry point for agents. The system organizes documentation into directories based on the agent’s assessment of the codebase structure rather than following rigid templates. The team deliberately chose to provide minimal guidance on directory structure, number of files, or specific topics to document, instead giving guidance on file size and ensuring each file focuses on a specific topic. This design prevents agents from needing to gather context from multiple locations when reading individual files.

A critical technical decision was adopting Google’s Open Knowledge Format, which was at version 0.1 during initial development with plans to support the newly released v0.2. OKF defines a deterministic YAML front matter for every markdown file containing type, title, description, resource references, tags, and timestamps, with support for arbitrary additional fields. This structured metadata provides significant advantages for retrieval operations, enabling filtering by document type, tag-based searching, and quick discovery of related content through resource links. The format’s emphasis on cross-linking between documents through markdown links allows agents to discover related context efficiently by following references from one document to another.

Each directory includes an index file providing quick overview of contents and a log file functioning as a changelog. The changelog serves dual purposes: it enables agents to understand the documentation’s evolution history, and it provides a human-readable summary of changes since documentation is checked into the codebase and developers need visibility into what has changed during automated updates. The guidance to users is to consult the changelog first and only dive into individual files if deeper context is needed.

Initialization and Update Workflows

The initialization workflow begins with the setup wizard where users configure API keys, select their model provider from among 10-15 supported options, and set instructions that serve as high-level prompts providing repo-specific context. The system then automatically generates several critical files including a GitHub Actions workflow configured with a daily cron job to maintain the wiki, modifications to AGENTS.md or CLAUDE.md files injecting instructions about OpenWiki’s existence and usage, and the initial wiki structure itself.

The generation process involves the agent examining the repository code, creating a documentation plan, and analyzing git history. The git history analysis is particularly important as it provides understanding of how the codebase has evolved rather than just its current snapshot, including commit messages and titles that provide context about development decisions. After the agent writes the documentation, a deterministic post-processing pass ensures OKF compliance, generates index and changelog files, and updates metadata files.

The update workflow operates through the scheduled GitHub Action. Before executing, it checks the git history against a tracked state in last_update.json to determine if any changes have occurred since the last run. If no changes are detected, the workflow terminates early to avoid unnecessary processing. When changes exist, the agent fetches every commit merged since the last run and updates documentation accordingly. The default daily schedule may need adjustment for high-velocity repositories with thousands of daily commits, potentially moving to four, six, or eight-hour intervals. After updating, the system automatically opens a pull request for review and merging.

Evaluation and Performance Metrics

The evaluation approach, while acknowledged as early-stage, draws on the DeepSWE benchmark, which focuses on coding agent capabilities. The team runs a subset of DeepSWE tasks in two conditions: without OpenWiki as a baseline, and with automatically generated wikis. The initial results showed task success rates of seven to eight successful completions without OpenWiki versus nine to ten with OpenWiki, representing slight improvement but not dramatic gains in correctness. However, the efficiency gains were substantial, with 30-40% reductions in token consumption, approximately 30% fewer tool calls, fewer code searches, and reduced output verbosity.

These metrics align with the core value proposition that better documentation enables agents to navigate codebases more efficiently. The token reduction is particularly significant from a production operations perspective, directly impacting API costs and latency. The team committed to publishing more comprehensive benchmark results as evaluation infrastructure matured, recognizing that robust evaluation is critical for a developer tool making efficiency claims.

Lessons Learned and Course Corrections

A significant assumption that proved incorrect was that only agents would consume the documentation. The initial design philosophy explicitly deprioritized human readability under the assumption that agents write most code in modern workflows and therefore documentation should be agent-first. User feedback quickly revealed that humans still want to read code documentation, which in retrospect makes sense given that humans remain involved in engineering workflows even with extensive agent assistance.

This realization led to incorporating diagrams into the generated documentation, including sequence diagrams, state diagrams, and flowcharts. While originally omitted because they seemed less important for text-processing agents, diagrams significantly improved human comprehension. The team noted that agents can generate these diagrams, which suggests they may also be able to consume them effectively, potentially providing value for both audiences. This represents a practical example of the tension between optimization for a single use case versus meeting broader user needs in production systems.

Integration with Agent Workflows

The current integration mechanism relies on modifying AGENTS.md and CLAUDE.md files to inform agents about OpenWiki’s existence, what it contains, how to access it, and when to reference it. This approach provides basic awareness but represents just the starting point for agent integration. The planned evolution includes dedicated search and retrieval tools that leverage the structured OKF metadata for filtering and querying operations. Early prototypes of these retrieval tools in unmerged pull requests showed promising gains, suggesting that explicit tool-based access could further improve agent efficiency beyond passive awareness through instruction files.

Open Source Strategy and Adoption

The decision to open source OpenWiki under an MIT license reflects both adoption strategy and philosophical alignment with developer culture. Making the tool freely available on NPM with support for multiple LLM providers lowers adoption barriers significantly. More importantly, the open source approach enables forking and customization for specific workflows and use cases. The team recognized that while they built OpenWiki in a general way, individual teams likely have specific requirements around how agents should read documentation or particular domain needs that benefit from customization. The repository has attracted significant engagement with substantial stars and forks, indicating developers are both using it directly and adapting it for their own contexts.

Production Considerations and Future Direction

The roadmap focuses on two main areas that are fundamental to production LLMOps. First, improving prompts through investment in evaluation infrastructure, specifically targeting better analysis of large repositories and more effective self-updating mechanisms. The DeepSWE evaluation framework provides foundation for systematic prompt improvement. Second, developing sophisticated search and retrieval tools that fully leverage the structured metadata OKF provides, enabling filtering by type, tag-based queries, and more intelligent context gathering than simple text search.

The project addresses several production LLMOps challenges that extend beyond documentation generation itself. The automated maintenance through GitHub Actions demonstrates continuous integration of LLM-generated content into development workflows. The changelog mechanism provides auditability and transparency into what the LLM system is changing, addressing governance concerns about automated content updates. The token optimization focus directly targets operational costs in production systems where token consumption scales with usage. The evaluation framework, while early, represents the kind of systematic measurement needed to validate that LLM-based tools actually provide claimed benefits rather than just sounding promising.

From a balanced perspective, the evaluation results should be interpreted cautiously given the early stage and limited scope of benchmarking. The modest improvement in task success rates suggests OpenWiki may be more about efficiency optimization than capability improvement, which is valuable but different from enabling agents to accomplish tasks they previously could not. The token reduction metrics are more compelling and easier to verify objectively. The assumption that documentation should be agent-only proved incorrect, suggesting that the stated design philosophy required practical compromise, though the addition of diagrams seems like a reasonable middle ground that doesn’t fundamentally compromise the agent-optimized structure.

The approach of starting with code documentation as a constrained domain before expanding to general-purpose memory represents sound engineering practice for LLM systems, focusing on a specific, measurable use case rather than attempting to solve memory comprehensively from the start. The emphasis on developer experience and trivial setup recognizes that sophisticated LLM tooling still needs to meet basic usability standards to achieve adoption. The open source strategy aligns with how developer tools gain traction while acknowledging that general-purpose solutions often need customization for specific contexts, making the codebase accessible for forking a pragmatic choice.

More Like This

Context Engineering and Agent Development at Scale: Building Open Deep Research

LangChain2025

Lance Martin from LangChain discusses the emerging discipline of "context engineering" through his experience building Open Deep Research, a deep research agent that evolved over a year to become the best-performing open-source solution on Deep Research Bench. The conversation explores how managing context in production agent systems—particularly across dozens to hundreds of tool calls—presents challenges distinct from simple prompt engineering, requiring techniques like context offloading, summarization, pruning, and multi-agent isolation. Martin's iterative development journey illustrates the "bitter lesson" for AI engineering: structured workflows that work well with current models can become bottlenecks as models improve, requiring engineers to continuously remove structure and embrace more general approaches to capture exponential model improvements.

code_generationsummarizationchatbot+39

Building Custom Agents at Scale: Notion's Multi-Year Journey to Production-Ready Agentic Workflows

Notion2026

Notion, a knowledge work platform serving enterprise customers, spent multiple years (2022-2026) iterating through four to five complete rebuilds of their agent infrastructure before shipping Custom Agents to production. The core problem was enabling users to automate complex workflows across their workspaces while maintaining enterprise-grade reliability, security, and cost efficiency. Their solution involved building a sophisticated agent harness with progressive tool disclosure, SQL-like database abstractions, markdown-based interfaces optimized for LLM consumption, and a comprehensive evaluation framework. The result was a production system handling over 100 tools, serving majority-agent traffic for search, and enabling workflows like automated bug triaging, email processing, and meeting notes capture that fundamentally changed how their company and customers operate.

chatbotquestion_answeringsummarization+52

Production Skills Framework for Agentic LLM Workflows

WorkOS2026

WorkOS developed a comprehensive approach to productionizing LLM workflows through "skills" - reusable, composable units of work that encapsulate specific tasks, constraints, and domain knowledge in markdown files with optional scripts. The problem addressed was the repetitive nature of LLM interactions where context must be reloaded from scratch in every conversation, leading to inconsistent outputs and wasted time. Their skills framework enables teams to codify workflows once, share them across team members and projects, and achieve more consistent, deterministic results. The solution has been applied across multiple use cases including code installation automation, content generation, image/video creation, and internal tooling, with WorkOS shipping production tools like their CLI that leverage skills to automate developer onboarding and authentication setup.

code_generationcustomer_supportcontent_moderation+21