dmr-devkit is an embeddable Go LLM Agent runtime: agent loop, tool system, tape audit trail, workflow orchestration, A2A server, LLM client, and OpenAI-compatible provider — without the full CLI or plugin ecosystem.
This document uses a progressive disclosure structure. Choose your reading depth based on current needs:
| Level | Time | Best For | Document |
|---|---|---|---|
| L1 — Core Overview | 5 min | First contact; quick architecture understanding | docs/agents/01-overview.md |
| L2 — Module Deep Dive | 15–30 min | Building agents, adding tools, orchestrating workflows | docs/agents/02-devkit.md onward |
| L3 — Advanced Topics | As needed | Performance tuning, custom storage, contributing code | docs/agents/08-compact.md onward |
Rule: When working on tasks related to this project, AI Agents must read L1 first, then select the appropriate L2 document based on task type. Only enter L3 for specific problems (performance tuning, storage customization).
dmr-devkit lets you embed a fully-featured LLM Agent with no config files, no CLI — just tens of lines of Go.
| Project | Purpose | Dependency |
|---|---|---|
| dmr-devkit (this repo) | Embeddable Agent runtime library + okf/ knowledge-format subtree |
Does not depend on dmr |
| dmr (private CLI) | Production deployment: config, Web, Cron, packaged plugins | Depends on this module |
| okf-devkit (sibling) | OKF 应用层:okfctl CLI、Web Playground、MCP Server |
Depends on this module (okf/ + agent runtime) |
okf/子树:OKF (Open Knowledge Format) 知识格式库——bundle 解析/校验、 知识图谱、FTS5 搜索、8 个消费者工具(okfListConcepts/okfSearchConcepts/okfGetConcept/okfGetIndex/okfGetNeighbors/okfGetBacklinks/okfCheckStale/okfGetTrusted)、frontmatter/markdown 解析、.okf.yaml加严配置。子包:okf/{bundle,graph,search,service,vcs,frontmatter,markdown,config,tools}。okf/tools把service.Service包成 dmrtool.Tool(ReadTools/WriteTools聚合),okf-devkit playground 与 dmr 的 okf 插件共用此接线。 任意 dmr 消费者可直接 importgithub.com/seanly/dmr-devkit/okf/<pkg>; okf-devkit 提供其上的应用层(CLI / Playground / MCP Server)。权威规范见okf/SPEC.md(中译okf/SPEC-CN.md)。
┌─────────────────────────────────────────────────────────────┐
│ Kit (devkit wiring) │
│ ┌─────────┐ ┌─────────┐ ┌──────────┐ ┌─────────────┐ │
│ │ Agent │ │ Client │ │ TapeMgr │ │ Hooks/Plugins│ │
│ │ (loop) │ │(LLM comm)│ │ (storage)│ │ (extension) │ │
│ └────┬────┘ └────┬────┘ └────┬─────┘ └──────┬──────┘ │
│ │ │ │ │ │
│ └────────────┴────────────┴───────────────┘ │
│ devkit.Build │
└─────────────────────────────────────────────────────────────┘
- Agent (
agent/): Multi-turn conversation loop — LLM call → tool execution → result feedback → repeat - Client (
client/): LLM communication layer, streaming/non-streaming, OpenAI-compatible protocol - TapeManager (
tape/): Persistent audit trail storage (memory/file/SQLite/PostgreSQL) - Hooks (
agent/hooks.go): Extension point; dmr'splugin.Managerinjects through here
- Minimal dependencies —
devkit.Buildonly needsModel+APIKey - Tape isolation — Each conversation uses an independent tape, concurrency-safe
- Tool discovery — Non-core tools are lazily loaded, reducing context footprint
- Auto-compaction — Automatically summarizes history when context exceeds thresholds
- A2A interoperability — Based on
a2a-gov2 protocol; interoperable with the community, not Google ADK
// Minimal runnable Agent (~20 lines of effective code)
kit, _ := devkit.Build(ctx, devkit.Options{
Model: "gpt-4o-mini",
APIKey: os.Getenv("AI_API_KEY"),
Tools: []*tool.Tool{{ /* ... */ }},
})
res, _ := kit.Agent.Run(ctx, "default", "Hello", 0)- docs/agents/02-devkit.md —
devkit.Build,Options,Kitcomplete guide- Environment configuration, auth methods (APIKey / OAuth2)
- Storage backend selection (memory/file/database)
- System prompt customization
- Complete example code
-
docs/agents/03-agent-loop.md — Agent loop deep dive
- Execution flow: Run → LLM → Tool → Result → Loop
- Max step limits and anti-loop mechanisms
- Tool whitelist and run modes
- Subagent delegation
- Reactive handoff
-
docs/agents/04-tools.md — Tool system
- ToolSpec / Handler / ToolContext
- Tool groups: core / extended / mcp
- Dynamic descriptions and lazy loading
- Tool result truncation and externalization
- Built-in tools (toolSearch, vision, etc.)
-
docs/agents/05-workflow.md — Workflow orchestration
- Sequential: sequential execution, previous output feeds next input
- Parallel: parallel branches, result aggregation
- Graph: directed graph with conditional branching and loops
- Loop: loop nodes with interrupt and resume support
- devkit integration:
kit.AsAgentNode, dedicated tape isolation
-
docs/agents/06-tape.md — Tape storage system
- Entry types: message, tool_call, tool_result, anchor, event
- Context window and anchor mechanism
- Storage backends: Memory, File, SQLite (with FTS5), PostgreSQL
- Query and export
-
docs/agents/07-a2a.md — A2A service exposure
- Agent Card and JSON-RPC endpoint
- Tape modes: per-Task isolation vs fixed shared
- Streaming output (SSE)
- Interoperability with dmr A2A plugin
-
docs/agents/08-plugins.md — Plugins and extensions
agent.Hooksinterface and lifecycle- Capabilities model (CapHTTP, etc.)
- Tool registration hooks
- System prompt fragment injection
- Integration with dmr
plugin.Manager
-
docs/agents/09-compact.md — Context compaction and optimization
- Preemptive compaction
- Prompt compaction strategies
- Micro-compaction and tool result externalization
- Token estimation and threshold configuration
-
docs/agents/10-internals.md — Internal implementation details
- Package dependency graph and interface boundaries
- Tape serialization format
- Concurrency model and locking strategy
- Testing strategy and mocking approaches
| Variable | Description | Example |
|---|---|---|
AI_MODEL |
Model ID | gpt-4o, claude-sonnet-4-6 |
AI_API_KEY |
API key | sk-... |
AI_API_BASE |
Custom API base URL | https://api.example.com/v1 |
| Package | Key Type/Function | Purpose |
|---|---|---|
devkit |
Build(ctx, opts) → *Kit |
Wire up Agent |
agent |
Agent.Run(tape, prompt, 0) |
Execute conversation |
workflow |
Sequential, Parallel, Graph |
Orchestrate multi-step tasks |
tool |
Tool{Spec, Handler} |
Define callable tools |
tape |
TapeManager, TapeStore |
Store conversation history |
a2aserver |
Mount(mux, opts, runner) |
Expose A2A HTTP service |
Filesystem-first agent authoring (agent/ layout, SO tools, webhook channels) lives in the sibling project dmr-forge — use forge run, forge serve, forge info.
examples/devkit_agent/— Minimal agent + toolsexamples/workflow_agent/— Sequential + Parallel workflowsexamples/a2a_devkit_server/— A2A HTTP serviceexamples/mcp_agent/— MCP tool integrationexamples/basic_demo.go— Pure LLM client (republicpackage)
This project already has the following documentation. Their relationship with AGENTS.md:
| Document | Content | AGENTS.md Level |
|---|---|---|
README.md |
Project intro, installation, skill installation | L0 |
docs/README.md |
Documentation index | L0 |
docs/devkit.md |
devkit English overview | L1–L2 |
docs/devkit/README.md |
devkit Chinese docs entry | L1–L2 |
docs/devkit/*.md |
Per-topic detailed Chinese docs | L2–L3 |
docs/skills/README.md |
Claude Code Skills index | Development aid |
docs/cwd-management.md |
Working directory management | L2 |
tools/script/README.md |
Script tool protocol (--config, discovery, I/O) |
L2 |
AGENTS.md does not replace the above documents. It provides AI Agents with a reading-order-constrained progressive navigation. Human developers can still read detailed docs directly under
docs/devkit/.