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, orcustom). - 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
| Name | Mode | Tools | Default permission overrides | Description |
|---|---|---|---|---|
build | build | All registered tools | bash: ask | Default coding agent — full access. |
plan | plan | read, glob, grep, list, webfetch, websearch, question | edit: deny, bash: deny | Read-only planning agent. |
ask | ask | read, glob, grep, list, webfetch, websearch, question | edit: deny, bash: deny | Read-only Q&A agent (no plan ritual). |
Definitions live in
internal/agent/builtin.go.
Switching agents
ulmi --agent plan # CLI flagInside the TUI:
/modeopens the mode picker (leader+A) withbuild,plan,ask, and any user-defined agents. The active session mode is pre-selected and marked(active)./agentsbrowses 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 Ais 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:
- Global:
~/.config/ulmi/agents/<name>.md - 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 rubricThe 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/agentsThe 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 listThis 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):
- The
--modelCLI flag (overrides everything for the session). - The
agents.<name>.model(ormodel_group) field in your config. - The frontmatter
model:(ormodel_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
agentparameter (built-in presets:explore,implementer,verifier,bash-runner; plus user-defined agents withsubagent: truein 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: truewhen the parent must block on the result. Monitor jobs with/tasksor the pinned Running tasks strip (Ctrl+XthenB, orCtrl+↓). Background jobs are persisted in the SQLitesubtaskstable (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, andcontext.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_loopsbudget at deeper nesting levels (halved per level, floored at 3). - Maximum nesting depth defaults to
3and is configurable viaagents.max_depthinulmi.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
exploreandimplementerpresets include thetasktool so they can spawn further nested sub-agents. Leaf profiles likeverifierdo not. - Nesting: calling
taskmultiple times from the same agent creates siblings (flat/taskslist). For a real tree, either:- use one
taskcall with achildrenarray, or - let a running sub-agent call
taskitself (ParentJobID is set from context).
- use one
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
| Command | Purpose |
|---|---|
/tasks | Dashboard 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: falseThe 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:
- Stable base (cached): the agent body or the auto-generated
build/planprompt, aWorking directory: …line from the status directory, and a short tool index. Tool JSON schemas are sent separately intools[], sorted by name. - 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).