agentleFS
MuvonMuvon/octomind/AGENTS.md

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.

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
  1. Very specific:

    Test: cargo test (debug build — what CI runs.

    line 11
  2. Distinctive:

    No wrapper methods, no speculative abstractions, no magic numbers.

    line 70
  3. Very specific:

    All config defaults in config-templates/default.toml — never hardcode values

    line 71
  4. Distinctive:

    Every changed line traces to the request — no opportunistic cleanups

    line 99
  5. Very specific:

    Use std::println! / std::eprintln!

    line 132
  6. Very specific:

    Add session-scoped state outside init_session_services or to only some of the four entry points

    line 134
  7. Very specific:

    Put inline #[cfg(test)] mod tests {} bodies in production files

    line 135
  8. Very specific:

    Use "stdin" as the MCP server type — the value is "stdio"

    line 137
  9. Very specific:

    Use [role] tables — roles are [[roles]] with name = "..."

    line 138
  10. Distinctive:

    Add unrequested features or opportunistic cleanups

    line 141

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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-cov with *_tests.rs excluded so percentages describe product code
  • Cross-compile/dist: make build-all / make dist (uses cross, see Cross.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

TaskStart here
Add an MCP toolschema 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/defaultconfig-templates/default.toml FIRST, then the matching type in src/config/
Config load / merge / role resolutionsrc/config/loading.rs (load()), src/config/merge.rs (get_merged_config_for_role())
Tool not found / routing bugssrc/mcp/tool_map.rs get_server_for_tool() → src/mcp/mod.rs try_execute_tool_call()
Session-scoped statesrc/session/context.rs init_session_services() — task-local SessionId via with_session_id
Session main loopsrc/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 executionsrc/session/chat/response.rs, response/tool_execution.rs, response/tool_result_processor.rs
Skill auto-activation / validatorssrc/mcp/runtime/skill_auto.rs (run_activation, run_validators)
Compressionsrc/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 supervisorsrc/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
Workflowssrc/workflow/ (schema.rs, run.rs, validate.rs) + templates config-templates/workflow*.toml
Taps (shareable project agents)src/agent/ (registry, taps, resolver, deps)
Layers / guardrails / pipessrc/session/layers/, src/session/guardrails.rs, src/session/pipe.rs
ACP / WebSocket serverssrc/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 / telemetrysrc/sandbox/, src/embeddings/, src/telemetry.rs
CLI subcommandssrc/commands/ (run, tap, untap, workflow, config, send, server, acp, …)
Path / directory constantssrc/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 .rs file
  • Tabs not spaces (rustfmt.toml), LF, 120-col limit; cargo fmt --all before every commit
  • Unit test bodies in sibling <name>_tests.rs files; the production file only declares #[cfg(test)] #[path = "<name>_tests.rs"] mod tests; — never inline mod tests {} bodies
  • Logging via crate::log_debug! / log_info! / log_error! / log_conditional! (defined in src/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 in src/lib.rs and suspend the spinner) — never std::println!
  • MCP tool failures are values: Ok(McpToolResult::error(...)), never Err(); 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()?; anyhow throughout, thiserror only where callers match variants
  • No std::sync::Mutex across .await (deadlock) — tokio::sync::Mutex or an actor; session-keyed state only via the task-local SessionId, 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() (see src/mcp/hint_accumulator.rs)
  • Dynamic tools: register_dynamic_server_tools() in tool_map.rs; local project tools: executable scripts in <workdir>/.agents/tools/ (auto-discovered by src/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 --all clean · cargo clippy --all-targets --all-features -- -D warnings exits 0 · cargo check --all-targets --all-features exits 0 · cargo test passes
  • New .rs files carry the Apache header; test bodies in sibling *_tests.rs
  • Session-scoped changes: rg init_session_services confirms all four entry points covered
  • Config changes: config-templates/default.toml updated first; a key added, renamed, moved or removed also raises version there and adds a step to plan() in src/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.md rows) and the Hermes skill skills/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: protoc required to build; rg + ast-grep on 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-static plus CXXFLAGS_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}.rs pattern (landlock is Linux-only; libc/proctitle are 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 glibc cargo build --release binary 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 /info and kept in the cost record's supervisor_accounting part
  • SessionInfo (src/session/mod.rs) — the persisted per-session record; add there (with #[serde(default)] + resume coverage) only when a metric must survive restart
  • src/telemetry.rs::Event — the exact anonymous wire schema; an event is reported remotely only if it is defined there and populated by record_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, the max_identical_rounds hard stop, and the plan state shown by /plan

Gotchas

  • mcp-*.toml loads AFTER all base *.toml regardless of sort order — the intended override mechanism
  • auto_bind is exact-match against the role name (the tap agent name, e.g. "developer") — use the same name in both places
  • A non-empty allowed_tools silently drops unlisted tools; get_merged_config_for_role auto-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 from model (the legacy [compression.decision] spelling is migrated away)
  • Log macros live in src/config/mod.rs; src/lib.rs only shadows the print macros
  • Builtin servers (each its own arm in route_builtin_tool() + tool_map): core (code, incl. conditional recall), orchestration (tap, schedule, monitor), runtime (mcp, skill, capability), local (.agents/tools/ scripts)
  • get_available_functions is every callable tool; get_model_functions is 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 — always Ok(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_services or 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]] with name = "..."
  • Omit the Apache 2.0 header from a new .rs file
  • Hold std::sync::Mutex across .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.md for depth
  • doc/reference/03-config-reference.md, doc/reference/04-environment-variables.md — every field and env var
  • bench/README.md — token-efficiency benchmark protocol and baseline advancing

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.