octomind
AGENTS.md659 starsChanged 44 days agoApache-2.0View on GitHub
Open-source AI coding agent and agent runtime: one Rust binary, any model (multi-provider via octolib), MCP-native. Sessions run interactively (CLI), non-interactively (--format), or as daemons (ACP stdio / WebSocket). TOML config is the single source of truth — model, tools, roles, compression and plugins all derive from it. Rust 1.95+ (MSRV enforced), tokio async, clap CLI.
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- octomindSkill
The file
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Test: cargo test (debug build — what CI runs.
- Distinctive: line 70
No wrapper methods, no speculative abstractions, no magic numbers.
- Very specific: line 71
All config defaults in config-templates/default.toml — never hardcode values
- Distinctive: line 99
Every changed line traces to the request — no opportunistic cleanups
- Very specific: line 132
Use std::println! / std::eprintln!
- Very specific: line 134
Add session-scoped state outside init_session_services or to only some of the four entry points
- Very specific: line 135
Put inline #[cfg(test)] mod tests {} bodies in production files
- Very specific: line 137
Use "stdin" as the MCP server type — the value is "stdio"
- Very specific: line 138
Use [role] tables — roles are [[roles]] with name = "..."
- Distinctive: line 141
Add unrequested features or opportunistic cleanups
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Octomind — AGENTS.md
Open-source AI coding agent and agent runtime: one Rust binary, any model (multi-provider via octolib), MCP-native. Sessions run interactively (CLI), non-interactively (--format), or as daemons (ACP stdio / WebSocket). TOML config is the single source of truth — model, tools, roles, compression and plugins all derive from it. Rust 1.95+ (MSRV enforced), tokio async, clap CLI.
Commands
- Setup:
cargo build· Hooks:pip install pre-commit && pre-commit install(fmt + clippy + check run on every commit) - Dev:
cargo run· Build:cargo build/cargo build --release(make build) - One-shot gate:
make dev(fmt + clippy + test) - Fmt:
cargo fmt --all· Check-only:make fmt-check - Lint:
cargo clippy --all-targets --all-features -- -D warnings - Test:
cargo test(debug build — what CI runs;make test=cargo test --release, slower first run) - Coverage:
make coverage—cargo llvm-covwith*_tests.rsexcluded so percentages describe product code - Cross-compile/dist:
make build-all/make dist(usescross, seeCross.toml) · Release packaging:build.sh - Bench (token-efficiency vs committed baseline): protocol in
bench/README.md - Build/test environment prereqs are per-OS — see Platforms below
Where to look
| Task | Start here |
| Add an MCP tool | schema in that server's get_all_functions() — src/mcp/core/functions.rs, src/mcp/orchestration/mod.rs, src/mcp/runtime/mod.rs → implement in same module → match arm in src/mcp/mod.rs route_builtin_tool() → register in src/mcp/tool_map.rs |
Add a session command (/foo) | src/session/chat/session/commands/<name>.rs returning CommandResult → mod + routing arm in commands/mod.rs process_command() → new CommandOutput variant if the result shape is new → constant + row in the fixed-size BUILTIN_COMMANDS array in src/session/chat/commands.rs (bump the length; Reach::CliOnly hides it from WebSocket clients) |
| Change a config field/default | config-templates/default.toml FIRST, then the matching type in src/config/ |
| Config load / merge / role resolution | src/config/loading.rs (load()), src/config/merge.rs (get_merged_config_for_role()) |
| Tool not found / routing bugs | src/mcp/tool_map.rs get_server_for_tool() → src/mcp/mod.rs try_execute_tool_call() |
| Session-scoped state | src/session/context.rs init_session_services() — task-local SessionId via with_session_id |
| Session main loop | src/session/chat/session/main_loop.rs (init_session_runtime()) |
What the model is told when nobody can answer (piped, JSONL, workflow step, tap child) | src/session/prompt.rs no_reply_section() · delegated flag src/agent/inputs.rs is_delegated(), set in src/acp/agent.rs initialize |
| Response / tool execution | src/session/chat/response.rs, response/tool_execution.rs, response/tool_result_processor.rs |
| Skill auto-activation / validators | src/mcp/runtime/skill_auto.rs (run_activation, run_validators) |
| Compression | src/session/chat/conversation_compression/ (decision.rs, apply.rs, schema.rs, attention/) |
Code mode (code tool: scripts that call external MCP tools) | src/mcp/code/ (mod.rs split + execute, catalog.rs signatures, check.rs + checker.js type check, engine.rs sandbox) → definitions sent to the model: get_model_functions in src/mcp/mod.rs → compiler bundle: assets/typescript/vendor.sh |
| Plugin host (events, protocol, transports, install, workdir) | src/plugins/ (host.rs, protocol.rs, events.rs, install.rs, state.rs, workdir.rs) + config src/config/plugins.rs |
| Session pieces that outlived the built-in supervisor | src/session/accounting/, src/session/self_report.rs, src/session/recite.rs, src/session/notice.rs, src/session/repeat_guard.rs, src/mcp/tool_shape.rs, src/acp/handback.rs |
| Workflows | src/workflow/ (schema.rs, run.rs, validate.rs) + templates config-templates/workflow*.toml |
| Taps (shareable project agents) | src/agent/ (registry, taps, resolver, deps) |
| Layers / guardrails / pipes | src/session/layers/, src/session/guardrails.rs, src/session/pipe.rs |
| ACP / WebSocket servers | src/acp/agent.rs, src/websocket/server.rs |
| MCP elicitation (who answers, routing, timers) | src/mcp/elicitation.rs (answerers, pending questions), src/mcp/client.rs (IN_FLIGHT_CALLS, calls_awaiting_elicitation, create_elicitation), terminal prompt src/session/chat/elicitation.rs |
| Sandbox / embeddings / telemetry | src/sandbox/, src/embeddings/, src/telemetry.rs |
| CLI subcommands | src/commands/ (run, tap, untap, workflow, config, send, server, acp, …) |
| Path / directory constants | src/directories.rs |
Architecture: flows that matter
Config → role → tools. Config::load() merges every *.toml in the config dir alphabetically (arrays concat + dedup by name; tables deep-merge), then mcp-*.toml files AFTER base files — they always win for same-named servers (intended override path; mcp persist writes <config_dir>/mcp-<name>.toml with auto_bind). get_merged_config_for_role(role) collects explicit server_refs UNION exact-match auto_bind hits → initialize_mcp_for_role() spawns stdio/http servers, registers builtins, builds TOOL_MAP (tool name → server) → try_execute_tool_call() dispatches.
Session lifecycle (critical invariant). Four entry points share one init contract; session-scoped state goes inside init_session_services() and ALL four must keep calling it (rg init_session_services): CLI + non-interactive (main_loop.rs init_session_runtime()), ACP new_session and ACP initialize (src/acp/agent.rs), WebSocket (src/websocket/server.rs) — always inside with_session_id. Never call init_inbox_for_session / init_job_manager / similar directly.
Elicitation answerer (the one per-entry-point exception). Who answers a session's MCP elicitations depends on the entry point and its client, so it is NOT set in init_session_services: each entry point calls crate::mcp::elicitation::set_answerer itself — interactive CLI Terminal (main_loop.rs, also on /new-style switches), WebSocket Client while the connection owning the output bound with elicitation_v1 (SessionStream::set_owner; no live owner ends open questions), ACP Client when initialize advertised clientCapabilities.elicitation. No answerer = declined. cleanup_session clears it and cancels open questions. Processes that may answer call accept_elicitations() (main.rs, run_interactive_session).
Runs nobody can answer. A question in a piped run, a workflow step or a tap child ends the run with the work undone, so octomind, not the agent prompt, tells the model how to behave there. no_reply_section() (src/session/prompt.rs) adds one section, chosen by who reads the reply: <delegated_run> when the ACP client is another octomind agent (is_delegated(), set in src/acp/agent.rs initialize from AGENT_CLIENT_NAME; every tap run), else <autonomy> for NonInteractive and Jsonl output (piped octomind run, --format jsonl, workflow steps). Interactive CLI, WebSocket and IDE ACP sessions get neither, so the agent's own rules about asking apply there. Both sections share NO_REPLY_RULES: change that text in one place and re-test it on several models (the tap's prompt-comprehension skill). Tap agent prompts, skills and workflow steps never restate these rules; they state only which actions need the user's explicit yes and, where the field has one, the default to use when the user cannot be asked.
Processing pipeline. User input → /command (CommandResult or TreatAsUserInput) → run_activation hook (main_loop only; skill auto-activation) → guardrails/pipe → workflows → layers → tool execution loop → run_validators hook (response.rs only) → spending check → output. /done is intercepted by the CLI main loop and the ACP prompt path, but the ACP octomind/command ext-method and WebSocket messages reach process_command() directly — its DONE_COMMAND arm is live code, not a leftover; keep it working.
Conventions
- Apache 2.0 header (verbatim, below) on every new
.rsfile - Tabs not spaces (
rustfmt.toml), LF, 120-col limit;cargo fmt --allbefore every commit - Unit test bodies in sibling
<name>_tests.rsfiles; the production file only declares#[cfg(test)] #[path = "<name>_tests.rs"] mod tests;— never inlinemod tests {}bodies - Logging via
crate::log_debug!/log_info!/log_error!/log_conditional!(defined insrc/config/mod.rs): positional args only (log_debug!("x={}", x)— clippy cannot see through inline captures), no trailing comma. Log decisions and state transitions, not step-by-step tracing - Printing via the crate macros (
println!etc. shadow std insrc/lib.rsand suspend the spinner) — neverstd::println! - MCP tool failures are values:
Ok(McpToolResult::error(...)), neverErr(); validate params explicitly, wrap internal errors:match call.parameters.get("key") { Some(Value::String(s)) if !s.trim().is_empty() => s.clone(), _ => return Ok(McpToolResult::error(call.tool_name.clone(), call.tool_id.clone(), "key: non-empty string required".into())), } - Fail fast:
.expect()/.context()?;anyhowthroughout,thiserroronly where callers match variants - No
std::sync::Mutexacross.await(deadlock) —tokio::sync::Mutexor an actor; session-keyed state only via the task-localSessionId, never process globals - No wrapper methods, no speculative abstractions, no magic numbers; comments explain why; delete dead code instead of commenting it out
- All config defaults in
config-templates/default.toml— never hardcode values - Conventional Commits
type(scope): subject(!= breaking); scopes = top-level modules (mcp,session,plugins,config,workflow,acp, …); CHANGELOG is generated from subjects at release - Misuse hints guide, never block: append a 💡 hint only when the better tool is actually enabled — gate on
crate::mcp::tool_map::get_server_for_tool("tool").is_some()(seesrc/mcp/hint_accumulator.rs) - Dynamic tools:
register_dynamic_server_tools()intool_map.rs; local project tools: executable scripts in<workdir>/.agents/tools/(auto-discovered bysrc/mcp/core/local_tool.rs)
Copyright header (every .rs file)
// Copyright 2026 Muvon Un Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.Done
cargo fmt --allclean ·cargo clippy --all-targets --all-features -- -D warningsexits 0 ·cargo check --all-targets --all-featuresexits 0 ·cargo testpasses- New
.rsfiles carry the Apache header; test bodies in sibling*_tests.rs - Session-scoped changes:
rg init_session_servicesconfirms all four entry points covered - Config changes:
config-templates/default.tomlupdated first; a key added, renamed, moved or removed also raisesversionthere and adds a step toplan()insrc/config/migrations.rs, with a test that upgrades a file of the previous version - CLI flag, config key, install or login changes: the skills other LLMs install updated too —
../octomind-plugin/plugins/octomind/skills/cli/SKILL.md(+ its../octomind-plugin/evidence/cli.mdrows) and the Hermes skillskills/octomind/SKILL.md - Every changed line traces to the request — no opportunistic cleanups
Platforms
One codebase for Linux, macOS and Windows — CI runs the full test suite on all three (stable on each OS + beta/nightly on Ubuntu; nightly is allowed to fail). Platform-sensitive facts:
- Everywhere:
protocrequired to build;rg+ast-grepon PATH for tests (tests spawn them as subprocesses) - ONNX Runtime: Linux tests need the static lib via
ORT_LIB_LOCATION(see the download step in.github/workflows/ci.yml); Windows/macOS auto-download prebuilts when it is unset - Windows MSVC quirks:
RUSTFLAGS=-C target-feature=-crt-staticplusCXXFLAGS_x86_64_pc_windows_msvc=-MD— a mixed static/dynamic CRT causes LNK2038 / unresolved__imp_*link errors - The first embedding test downloads the HF model
muvon/octomind-embed(~130 MB) into the octolib cache:~/.cache/octolib/huggingface(Linux),~/Library/Caches/octolib/huggingface(macOS),~/AppData/Local/octolib/huggingface(Windows) - OS-specific code lives in cfg-gated modules — follow the
src/sandbox/{linux,macos}.rspattern (landlockis Linux-only;libc/proctitleare Unix-only; sandbox backends exist for Linux and macOS only). Don't sprinkle one-off#[cfg]where a module split exists - A test that cannot pass on every OS must be explicitly gated with the reason stated in code — silent per-OS divergence hides regressions
- musl/static release builds compile ORT from source in Alpine (see ci.yml
musl-build+Cross.toml); a plain glibccargo build --releasebinary is what runs in the Debian bench containers
Boundaries (telemetry, accounting)
Separate systems — wiring a metric into one does NOT make it appear in the others:
src/session/accounting/— what plugins and background folds spent on a session's behalf; shown in/infoand kept in the cost record'ssupervisor_accountingpartSessionInfo(src/session/mod.rs) — the persisted per-session record; add there (with#[serde(default)]+ resume coverage) only when a metric must survive restartsrc/telemetry.rs::Event— the exact anonymous wire schema; an event is reported remotely only if it is defined there and populated byrecord_session. Audit each lifecycle path (CLI/piped/daemon exit, ACP disconnect, workflow, WebSocket — WS emits no session row today)- Adaptive controllers may stay session-keyed and ephemeral (cleared by
cleanup_session) — don't persist just to observe - Supervising and learning are not part of octomind: the Besydr program does them as a plugin (see
src/plugins/,src/config/plugins.rs). Octomind keeps its own agent loop, compaction, guardrails, themax_identical_roundshard stop, and the plan state shown by/plan
Gotchas
mcp-*.tomlloads AFTER all base*.tomlregardless of sort order — the intended override mechanismauto_bindis exact-match against the role name (the tap agent name, e.g."developer") — use the same name in both places- A non-empty
allowed_toolssilently drops unlisted tools;get_merged_config_for_roleauto-appends"<server>:*"for auto-bind servers — beware when constructing configs manually - In TOML config files, scalar keys must come BEFORE nested table headers in a section — a scalar placed after
[x.y]is parsed as a field of that table and silently ignored - The compression decision/summary model is
[compression.model], separate frommodel(the legacy[compression.decision]spelling is migrated away) - Log macros live in
src/config/mod.rs;src/lib.rsonly shadows the print macros - Builtin servers (each its own arm in
route_builtin_tool()+tool_map):core(code, incl. conditionalrecall),orchestration(tap,schedule,monitor),runtime(mcp,skill,capability),local(.agents/tools/scripts) get_available_functionsis every callable tool;get_model_functionsis what the model is sent — pick by purpose (routing/display vs request size)- Dynamic tools are session-owned — a tool registered in one session is rejected when called from another (intentional isolation)
Never
- Return
Err()from MCP tool execution — alwaysOk(McpToolResult::error(...)) - Use
std::println!/std::eprintln!— breaks the spinner and the output path - Swallow errors with
unwrap_or_else(|_| default) - Add session-scoped state outside
init_session_servicesor to only some of the four entry points - Put inline
#[cfg(test)] mod tests {}bodies in production files - Hardcode config values — defaults belong in
config-templates/default.toml - Use
"stdin"as the MCP server type — the value is"stdio" - Use
[role]tables — roles are[[roles]]withname = "..." - Omit the Apache 2.0 header from a new
.rsfile - Hold
std::sync::Mutexacross.await - Add unrequested features or opportunistic cleanups
References
CONTRIBUTING.md— full dev guide (setup, Rust patterns, commit scopes, pre-commit detail)doc/README.md— doc index ·doc/dev/02-architecture.md,doc/dev/03-mcp-server-development.mdfor depthdoc/reference/03-config-reference.md,doc/reference/04-environment-variables.md— every field and env varbench/README.md— token-efficiency benchmark protocol and baseline advancing
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

