Browse documentation

Technical documentation / Reference

Tools and safety model

Feature docs index · Repository README

Choose a tool below, then check its path, output, and credential limits before use. Shell guardrails are not an OS sandbox.

ToolContract
readRead known local files or internal resources. Local output supplies tags and line anchors for hash_edit; see reading files.
bash / shellRun non-interactive commands in the active cwd with configurable preflight, timeout, and bounded output. The host shell has no OS sandbox; see environment profiles.
hash_editApply hashline patches to existing UTF-8 files using latest current-session read tags, line anchors, stale-tag recovery, optional block ops, whole-file MV, and regular-file-only REM. Use for anchored changes to existing files.
writeCreate or fully replace a file; both path and content are required. Empty content is allowed, replacement is atomic, parent directories are created recursively, UTF-8 content is capped at 1 MiB, and final symlink targets are rejected. Relative paths resolve from cwd; absolute behavior follows capabilities.tools.write.absolute_paths. Use for new files or complete replacements.
grepBounded, in-process content search with OR patterns, ranked/raw modes, pagination, and partial-scan metadata. No external rg is needed.
findFuzzy path discovery with pagination and Git/Perforce ignore rules; directory listings are cached, not file contents.
list_filesReturn raw shallow direct child files/directories; does not read or honor ignore files. find and grep use shared git/P4-aware traversal where applicable.
ast_grepEmbedded AST search, read-only rewrite previews, and outlines; no external CLI needed. Directory requests use shared Git/Perforce-aware walking of visible regular files. Explicit file requests bypass ignore filters but retain path checks. Empty visible worksets return successful no-match.
view_imageInspect one local image through a configured vision model. Requires absolute path and prompt; supports png, jpg, jpeg, gif, and webp; enforces max_image_bytes; sends image bytes only to configured capabilities.tools.view_image.vision_model (openai-codex/openai Responses API, Anthropic Messages API, or OpenAI-compatible custom provider). Never falls back to active chat model.
subagentsRun independent delegated tasks in bounded parallel child sessions, optionally selecting a discovered subagent identity.
webPublic research and programming documentation. search accepts a query; open accepts a public URL or cached reference. See below.

Shell commands

bash requires command and a nonblank intent that briefly explains why the command is needed. The transcript card shows intent above command, then result summary. timeout is optional (1–300 seconds, default 30). Runtime aliases shell and cmd also require intent.

AST search and outlines

ast_grep defaults to operation: "search". Search requires pattern and accepts optional rewrite for a read-only diff preview. Use operation: "outline" to inspect symbols before reading source.

Neither operation needs an installed CLI. Embedded AST libraries infer language from file extension unless you supply one. Project configs and custom grammars are not loaded.

{"operation":"outline","path":"src","language":"rust","limit":30}

URL routing

Use the narrowest tool that meets the request:

NeedToolUse
Public unauthenticated plain text, Markdown, JSON, or HTML ordinary GETweb openBounded native fetch/readability; no JavaScript or interaction.
Public research and page textwebSearch and open; no browser interaction or CSS extraction.
Custom or non-public HTTP workbashCustom methods, headers, bodies, redirect control, binary downloads, private/local services, or an explicit request.

URL open applies bounded readability extraction to substantial HTML and converts short HTML to Markdown. Never block or rewrite curl.

web contract

Use one operation per call. Omit unused fields or set them to null:

{"operation":"search","query":"Rust official release notes","limit":5,"domainFilter":["rust-lang.org","-old.rust-lang.org"],"recencyFilter":"month"}
{"operation":"open","url":"https://www.rust-lang.org/"}
{"operation":"open","reference":"web:<reference from a result>"}

Visible tool output

Mission Control shows pending and completed tool activity with safe status, metadata, and bounded output. Pending write/hash_edit entries do not include file contents or replacement payloads. web shows query/result/truncation metadata and redacts credential-shaped text. read shows requested paths. Subagent summaries omit raw child output. Shared summaries live in src/output/tool_summary.rs.

When opt-in LSP edit injection has fresh diagnostics, they are appended to the successful write/hash_edit tool result. Mission Control may show successful hash_edit changes as a bounded changed-line transcript preview and a larger activity-detail diff. Both are display-only, not provider tool results or JSONL session data.

subagents displays a bounded aggregate summary rather than raw child output.

Reading files

Use paths for known local files or skills:

{ "paths": ["README.md:1-200"] }

Finding paths

Discover paths without reading contents:

{ "query": "lib", "kind": "mixed", "path": "src", "limit": 20, "offset": 0 }

Rules:

Searching contents

{ "patterns": ["fn run"], "path": "src", "limit": 20, "context": 2 }

Editing files

Anchor patches to the latest read tags:

{ "input": "[README.md#A1B2]\nSWAP 10.=10:\n+new line" }

Rules:

Inspecting images

Configure an explicit vision provider/model before use:

{
  "capabilities": {
    "tools": {
      "view_image": {
        "vision_model": {
          "provider": "local-vision",
          "model": "vision-model-id"
        },
        "absolute_paths": true,
        "max_image_bytes": 5242880
      }
    }
  }
}

Rules:

LSP edit diagnostics are opt-in and workspace-bound. Missing, slow, crashed, stale, or indexing servers skip injection without changing write or hash_edit success. They complement project checks and do not replace cargo check, tests, linters, or repository-specific verification.

Safety boundaries

Token-triggered streaming reminders

TTSR is disabled by default. When agent.reminders.enabled is true, rules inspect assistant streaming deltas and completed tool-call arguments mid-turn. Regex rules stay dormant until a match; on a match, magi-code aborts the current stream, records a hidden local ttsr_injection JSONL event, injects the configured system reminder, and retries the turn.

Built-in rules cover destructive commands, secret exfiltration, credential routing, cwd widening, and force push patterns when TTSR is enabled. User rules live in agent.reminders.rules settings as { "pattern": "...", "reminder": "..." } objects. TTSR is separate from hooks: hooks run at phase boundaries around tool/assistant events, while TTSR can interrupt provider streaming before a tool executes or assistant text completes.

Edit this page on GitHub ↗