Skip to content
Tools

Tools

Tools are the actions an agent can invoke. They are exposed to the LLM as JSON-schema function definitions, and any conforming tool_call from the model is dispatched to the matching tool implementation.

The Tool interface

The contract every tool implements lives in internal/tool/tool.go:

type Tool interface {
    Name() string
    Description() string
    Schema() json.RawMessage   // JSON Schema for parameters
    Run(ctx context.Context, params json.RawMessage) (string, error)
}

The output is a plain-text string fed back to the model as a tool message. Errors are surfaced through tool.Result.IsError = true so the model can self-correct without aborting the loop.

The registry, permission gating, and parallel execution semantics are documented in Architecture.

Built-in tools

Tools are registered in internal/tool/builtin/registry.go (NewRegistry). Runtime-only tools are added later by the composition root: task and question after TUI/sub-agent wiring, skill when a catalog is non-empty, LSP tools when ULMI_EXPERIMENTAL_LSP is set, MCP tools when servers connect.

File system

ToolWhat it doesRequired params
readRead one or more files or 1-indexed line ranges (2,000 lines / 100 KiB per file).path or paths
writeCreate or overwrite a file.path, content
editReplace an exact, unique string inside a file.path, old_string, new_string
deleteDelete a single file.path
globFind up to 1,000 files by glob pattern.pattern
grepRegex search with include / exclude filters (200 matches by default).pattern
listShallow or recursive directory tree, capped at 2,000 entries.path
patchApply a unified diff to one or more files (multi-file, fuzzy, create / delete).patch

write, edit, delete, and patch are confined to the workspace root (the directory Ulmi was started in, or the value stored by tool.WithWorkspace). Relative paths resolve inside that root. Absolute paths outside it, .. escapes, and symlinks that resolve outside the root are rejected. Read-only tools (read, glob, grep, list) still accept absolute paths anywhere so the model can inspect files the user points at.

write, edit, delete, and patch integrate with the snapshot manager: the pre-mutation state is captured before modifying the file so /undo can restore it later.

Multi-file patch calls are sequential, not atomic. See the proposed V4A apply_patch migration.

Web

ToolWhat it doesRequired params
webfetchFetch a public URL; return markdown (default), text, or html. Blocks private/local addresses (SSRF).url
websearchSearch the web via Exa hosted MCP (web_search_exa). Optional web.search.api_key (or $EXA_API_KEY copied into that field at load).query
questionAsk the user structured multiple-choice questions (TUI only).questions

Defaults: webfetch / websearch require confirmation (ask); question is allow. Disable search with web.search.enabled: false. All three remain available in /plan and /ask modes.

Shell

ToolWhat it doesRequired params
bashExecute a shell command via /bin/sh -c with a timeout.command (timeout, working_dir optional)

Stdout and stderr are captured. Non-zero exit codes are reported in the output rather than as Go errors so the model can reason about them. The default timeout is 30 seconds and is overridable per call. Model history keeps at most 200 KiB using head-and-tail truncation; the streaming TUI still receives the complete output.

Task management

ToolWhat it does
todo_readReturns the current todo list as JSON.
todo_writeReplaces the entire todo list with a new array of {id, content, status} items.

Statuses are pending, in_progress, completed, cancelled. The list is in-memory and shared across the parent agent and any sub-agents launched via the task tool.

Skills

ToolWhat it doesRequired params
skillLoad a skill’s full instructions into the volatile system message by name. Registered only when at least one skill is installed.name

See Skills. Explicit $skill-name in the composer and the /skills picker still work when the tool is unregistered (empty catalog).

Sub-agents

ToolWhat it doesParams
taskSpawn an isolated sub-agent; returns its final answer (or a background job ID).prompt (required); see below
ParamTypeDescription
promptstringComplete instructions (required).
descriptionstringShort label for logs and /tasks.
agentstringNamed sub-agent profile (explore, implementer, verifier, …).
modelstringOptional provider/model override for this sub-agent.
backgroundboolDeprecated alias — tasks are background by default. Prefer wait.
waitboolWhen true, parent blocks until the sub-agent finishes (foreground).
worktreeboolRun in an isolated git worktree.
gradeboolRun implementer + verifier grader loop (always background unless wait).
contextobjectStructured handoff: files, constraints, parent_summary.
childrenarrayNested task requests materialized under this job (real /tasks tree).

Built-in sub-agent presets: explore, implementer, verifier, bash-runner (and hidden lsp-explore when LSP is enabled). User-defined profiles use subagent: true in .ulmi/agents/*.md. See Agents → Sub-agents.

Sub-agents run with a fresh history (no access to the parent’s chat). Each named profile can use its own model, tool set, and system prompt. Maximum nesting depth is 3; the loop budget is halved at every level.

Example: explore with context

{
  "agent": "explore",
  "prompt": "Map the authentication flow",
  "wait": true,
  "context": {
    "files": ["internal/auth/login.go"],
    "constraints": ["read-only"],
    "parent_summary": "Refactoring JWT refresh"
  }
}

Example: graded implementation

{
  "agent": "implementer",
  "prompt": "Add retry logic to the HTTP client",
  "grade": true,
  "worktree": true
}

LSP (experimental)

When ULMI_EXPERIMENTAL_LSP=true and a language server is detected, five tools are registered:

ToolWhat it does
lsp_definitionGo to definition for a symbol at file:line:character.
lsp_referencesAll references to the symbol at the given position.
lsp_hoverHover documentation.
lsp_symbolsWorkspace symbol search.
lsp_call_hierarchyIncoming / outgoing call tree.

See LSP.

MCP

Any tool exposed by a connected MCP server is registered as mcp__<server-name>__<tool-name>. The server’s JSON Schema is forwarded unchanged. See MCP.

Examples

read

{ "path": "internal/agent/engine.go", "start_line": 100, "end_line": 150 }

Returns the file with line-number prefixes (100|…).

edit

{
  "path": "internal/api/handler.go",
  "old_string": "return result",
  "new_string": "if err != nil {\n    return fmt.Errorf(\"handle: %w\", err)\n}\nreturn result"
}

old_string must match exactly once. The tool returns a small unified diff with a @@ hunk header (so the TUI can show a line-number gutter and open the file at the change) and, when a snapshot manager is wired in, records the mutation for undo.

grep

{
  "pattern": "func New[A-Z]\\w+",
  "path": "internal/",
  "include": "*.go",
  "exclude": "*_test.go",
  "case_insensitive": false
}

Returns up to 200 matches in file:line:content form, capped to keep the context manageable.

bash

Requires /bin/sh; shell execution is supported on Unix and WSL, not native Windows. File tools remain available on native Windows.

{ "command": "go test ./internal/agent/...", "timeout": 60 }

Combined stdout / stderr is returned plus a [exit: …] line on non-zero exit codes. Subject to the permission system — by default the TUI asks for confirmation.

task

{
  "description": "Audit the auth handler",
  "prompt": "Open internal/api/auth.go, list every place that calls db.Exec without context, and propose fixes."
}

A child agent runs the request and returns a plain-text final answer. The parent agent sees only the answer, not the child’s intermediate reasoning.

websearch

{ "query": "golang context WithCancel Cause", "num_results": 5 }

webfetch

{ "url": "https://pkg.go.dev/context", "format": "markdown" }

question

{
  "questions": [
    {
      "header": "API style",
      "question": "How should the new endpoint accept input?",
      "options": [
        { "label": "JSON body", "description": "POST application/json" },
        { "label": "Query params", "description": "GET with filters" }
      ]
    }
  ]
}

The TUI shows an inline chooser; the tool blocks until the user submits or cancels. Outside the TUI the tool returns no interactive user.

Tool error handling

When a tool returns an error or panics:

  • The registry catches it and emits a tool.Result{IsError: true}.
  • The TUI shows the error in the chat with a ⚠ prefix.
  • The model receives the error as a tool message so it can adapt.

This means a single failed tool call rarely aborts the conversation — the model can read the error, retry, or change strategy.

Adding a new tool

  1. Create a package under internal/tool/tools/<name>/ with a tool.go implementing the Tool interface.
  2. Register statically configured tools in internal/tool/builtin/registry.go (NewRegistry). Runtime-only tools (task, question, skill, LSP, MCP) stay wired from internal/cli.
  3. (Optional) Add a permission entry in internal/permission/permission.go if the tool falls outside the bash / edit categories.
  4. Write unit tests next to the implementation; the _test.go files in the existing tools are good templates.

Schema() must be a JSON Schema object. Do not use oneOf, allOf, or anyOf at the top level: Anthropic’s Messages API rejects them. Express mutual exclusivity in property descriptions and enforce it in Run.

The tool is automatically picked up by every agent unless the agent’s AllowedTools list explicitly opts out.