Skip to content
Agents

Agents

An agent in Ulmi is a profile that combines:

  • A system prompt describing the agent’s role.
  • An operational mode that constrains capabilities (build, plan, ask, or custom).
  • An allowed tool set (subset of the global tool registry).
  • An optional permission policy override (bash, edit, …).
  • An optional preferred model or model group.

Agent definitions live in internal/agent and the runtime contract is the small agent.Def struct in builtin.go.

Built-in agents

NameModeToolsDefault permission overridesDescription
buildbuildAll registered toolsbash: askDefault coding agent — full access.
planplanread, glob, grep, list, webfetch, websearch, questionedit: deny, bash: denyRead-only planning agent.
askaskread, glob, grep, list, webfetch, websearch, questionedit: deny, bash: denyRead-only Q&A agent (no plan ritual).

Definitions live in internal/agent/builtin.go.

Switching agents

ulmi --agent plan                 # CLI flag

Inside the TUI:

  • /mode opens the mode picker (leader+A) with build, plan, ask, and any user-defined agents. The active session mode is pre-selected and marked (active).
  • /agents browses sub-agent jobs across sessions (not only the current chat).
  • /attach <id> opens attach for a short or full job ID.
  • /export-subtask <id> writes a markdown transcript to the cwd.
  • CLI: ulmi tasks list --json, ulmi tasks export <id>.
  • Ctrl+X A is the leader-key shortcut.

When you switch agents mid-conversation, Ulmi rebuilds the system prompt and replaces (or prepends) the system message in the current history. The rest of the conversation is preserved.

User-defined agents

Authoring an agent is two files away: a markdown file with a YAML frontmatter block. Place it in any of:

  1. Global: ~/.config/ulmi/agents/<name>.md
  2. Project: .ulmi/agents/<name>.md (overrides the global one)

The simplest agent is just a system prompt:

---
name: go-expert
description: "Idiomatic Go specialist"
---

You are an expert Go programmer. Always:

- Use the standard library before reaching for dependencies.
- Wrap errors with %w and add context.
- Keep functions small and tested.

Frontmatter reference

name: backend-pro                # required (or derived from filename)
description: "Backend Go specialist"
model: anthropic/claude-sonnet-4-5   # optional — pin a model
model_group: smart                # optional — pick from a model_groups entry
tools:                            # optional — restrict to this list
  - read
  - write
  - edit
  - glob
  - grep
  - bash
permissions:                      # optional — overrides config defaults
  bash: ask
  edit: allow
  rules:
    - pattern: "**/*.go"
      edit: allow
subagent: true                    # optional — invokable via task tool /batch
background: false                 # optional — default to async execution
readonly: false                   # optional — restrict to read-only tools
hidden: false                     # optional — hide from task tool description
rubric: "Tests pass; no TODOs"  # optional — grader loop rubric

The body of the file (everything after the closing ---) becomes the system prompt. Ulmi always appends a Working directory: … line and the list of tools available to the agent so the model knows its context.

If name is omitted in the frontmatter, the file’s basename (without .md) is used as the agent name. See internal/agent/userdef.go for the parser.

Scaffolding a new agent

ulmi agent create --name go-expert
ulmi agent create --name reviewer --description "Pull-request reviewer" --dir ~/.config/ulmi/agents

The command writes a template you can edit. See internal/agent/userdef.go for the AgentFileTemplate function used as the starting point.

Listing agents

ulmi agent list

This prints every built-in and user-defined agent the loader can find, along with their source file, allowed tools, and pinned model (if any).

Choosing a model per agent

There are three ways to bind a model to an agent (highest priority first):

  1. The --model CLI flag (overrides everything for the session).
  2. The agents.<name>.model (or model_group) field in your config.
  3. The frontmatter model: (or model_group:) field of the agent markdown.

If both model and model_group are set, model wins. When a model_group is selected, the registry resolves it to its first concrete entry at startup and falls back to the next entry if streaming fails.

Sub-agents (task tool)

Any agent that has access to the task tool can spawn an isolated child agent. The child:

  • Runs with a fresh conversation history (it cannot see the parent’s chat).
  • Completes via Engine.Send (blocking, not streamed). Streaming child tokens is deferred until the Session view needs live tokens.
  • Can target a named sub-agent profile via the agent parameter (built-in presets: explore, implementer, verifier, bash-runner; plus user-defined agents with subagent: true in frontmatter).
  • Inherits a per-agent model, tool set, and system prompt when a named profile is selected (multi-provider routing supported).
  • Supports background by default (returns a job ID immediately). Set wait: true when the parent must block on the result. Monitor jobs with /tasks or the pinned Running tasks strip (Ctrl+X then B, or Ctrl+↓). Background jobs are persisted in the SQLite subtasks table (linked to the parent chat session) and restored when you resume that session via /sessions, --continue, or --session.
  • Ask-level permission prompts from background sub-agents surface in the parent TUI with the sub-agent name labeled on the confirm dialog.
  • Type @ in the input to mention a running sub-agent (@agent:name:id) alongside file mentions.
  • Completion shows a toast + optional terminal desktop notification (OSC 9). When a wave of top-level background jobs finishes, the parent agent is auto-resumed with a synthetic user message containing each job’s status and truncated result (so it can continue without wait: true).
  • Accepts structured handoff via context.files, context.constraints, and context.parent_summary.
  • Can run in an isolated git worktree (worktree: true).
  • Supports a grader loop (grade: true) that runs implementer + verifier until PASS or max rounds.
  • Gets a reduced max_loops budget at deeper nesting levels (halved per level, floored at 3).
  • Maximum nesting depth defaults to 3 and is configurable via agents.max_depth in ulmi.yaml. Deeper attempts return an error to the model.
  • Nested jobs appear as a tree in /tasks (indent + (+N) descendants), with breadcrumb path (main › explore › verifier) in attach/peek and depth-aware progress lines (depth-2 · verifying · round 1/2).
  • The built-in explore and implementer presets include the task tool so they can spawn further nested sub-agents. Leaf profiles like verifier do not.
  • Nesting: calling task multiple times from the same agent creates siblings (flat /tasks list). For a real tree, either:
    1. use one task call with a children array, or
    2. let a running sub-agent call task itself (ParentJobID is set from context).
agents:
  max_depth: 3   # default; raise to allow deeper task nesting
  cheap_model: openai/gpt-4.1-mini  # explore / verifier / bash-runner / lsp-explore
  # named profiles (from markdown / optional model overrides) …

explore, verifier, bash-runner, and lsp-explore inherit agents.cheap_model when they have no explicit model. implementer and the parent session keep the active model. Extended thinking stays off unless models.<id>.thinking_budget is set.

User-defined sub-agents

Place markdown files in .ulmi/agents/ or ~/.config/ulmi/agents/:

---
name: security-auditor
subagent: true
description: "Audit auth and API handlers"
model: anthropic/claude-haiku-3-5
readonly: true
tools: [read, glob, grep, list]
rubric: "No hardcoded secrets; input validated"
---
You are a security auditor…

Slash commands

CommandPurpose
/tasksDashboard of running/completed sub-agent jobs
/batch <agent> [flags] <prompt>Fan-out parallel sub-agents (--glob, --parallel, --background, --worktree, --grade)

Overlay keys, the pinned task strip, and the message queue: TUI Multitasking.

Task permissions

Restrict which sub-agents a parent may invoke in ulmi.yaml:

task_permissions:
  rules:
    - pattern: "implementer"
      allow: true
    - pattern: "verifier"
      allow: true
    - pattern: "*"
      allow: false

The factory wiring is in internal/agent/subagent.go and the tool itself in internal/tool/tools/task/tool.go.

System prompt construction

The final prompt sent to the model is two leading system messages:

  1. Stable base (cached): the agent body or the auto-generated build / plan prompt, a Working directory: … line from the status directory, and a short tool index. Tool JSON schemas are sent separately in tools[], sorted by name.
  2. Volatile trailer (not cached as a prefix): mode preamble, /goal, then any matched Skills catalog and active bodies.

The builder is in internal/agent/prompt.go. The TUI splits stable vs volatile in applySystemPrompt (session_mode.go).