Built-ins

September 2, 2026 · View on GitHub

Every built-in tool, sub-agent, input, output, user command, framework command, LLM provider, and LLM preset shipped with KohakuTerrarium.

For the shape of tools vs sub-agents, read concepts/modules/tool and concepts/modules/sub-agent. For task-oriented help, see guides/creatures and guides/custom-modules.

Tools

Built-in tool classes live in src/kohakuterrarium/builtins/tools/. Register them in a creature config under tools: by bare name.

Shell and scripting

bash: Run a shell command. Uses bash by default on every platform (Git Bash on Windows). Pass type="..." to select another supported shell: bash, zsh, sh, fish, pwsh, or powershell. Captures stdout and stderr, truncated to a cap. Direct execution.

  • Args: command (str), working_dir (str, optional), timeout (float, optional).

python: Run a Python subprocess. Respects working_dir and timeout. Direct.

  • Args: code (str), working_dir, timeout.

File operations

read: Read text, image, or PDF content. Records read-state per file. Images are returned as base64 data URLs. PDF support requires pymupdf. Direct.

  • Args: path (str), offset (int, optional), limit (int, optional).

write: Create or overwrite a file. Creates parent directories. Blocks overwrites unless the file was read first (unless new). Direct.

  • Args: path, content, new (bool, optional).

edit: Auto-detects unified-diff (@@) or search/replace form. Refuses binary files. Direct.

  • Args: path, old_text/new_text or diff, replace_all (bool).

multi_edit: Apply an ordered list of edits to one file. Atomic per file. Modes: strict (every edit must apply), best_effort (skip failures), default (partial apply with report). Direct.

  • Args: path, edits: list[{old, new}], mode.

glob: mtime-sorted glob. Respects .gitignore. Early-terminates. Direct.

  • Args: pattern, root (optional), limit (optional).

grep: Regex search across files. Supports ignore_case. Skips binaries. Direct.

  • Args: pattern, path (optional), ignore_case (bool), max_matches.

tree: Directory listing with YAML-frontmatter summaries for markdown files. Direct.

  • Args: path, depth.

notebook_read: Read Jupyter notebooks (.ipynb) as compact markdown summaries, selected cells, or raw JSON. Direct.

  • Args: path, cell, include_outputs, mode.

notebook_edit: Edit Jupyter notebooks by replacing, inserting, deleting, or appending cells while preserving notebook metadata. Direct.

  • Args: path, cell, source, cell_type, action.

Structured data

json_read: Read a JSON document by dot-path. Direct.

  • Args: path, query (dot-path).

json_write: Assign a value at a dot-path. Creates nested objects as needed. Direct.

  • Args: path, query, value.

Web

web_fetch: Fetch a URL as markdown. Tries crawl4aitrafilatura → Jina proxy → httpx + html2text. 100k-char cap, 30s timeout. Direct.

  • Args: url.

web_search: Web search with a DuckDuckGo default plus optional Codex subscription and DeepSeek Responses backends. After kt login codex, select backend: codex; this works independently of the creature's active LLM. DeepSeek requires kt config key set deepseek and backend: deepseek. Either explicit provider backend can use fallback: duckduckgo for transient failures. Direct.

  • Args: query, max_results (int), region (str).

Provider-native media

image_gen: Generate or edit an image through the provider's own native image backend. Currently auto-injected for Codex-backed creatures unless opted out with disable_provider_tools: [image_gen]. The executor never runs it; the provider returns structured image content and the session store persists the generated file into the session artifacts dir.

  • Args: prompt plus provider-specific knobs when explicitly wired: output_format, size, quality, action, background.

Interactive and memory

ask_user: Prompt the user over stdin (CLI or TUI only). Stateful.

  • Args: question.

think: No-op; preserves reasoning as a tool event for the event log. Direct.

  • Args: thought.

scratchpad: Session-scoped KV store. Shared across agents in a session.

  • Args: action (get | set | delete | list), key, value.

search_memory: FTS / semantic / auto search over the session's indexed events. Per-agent filter.

  • Args: query, mode (auto/fts/semantic/hybrid), k, agent.

Communication

send_message: Emit a message to a channel. Resolves creature- local channels first, then the environment's shared channels. Direct.

  • Args: channel, content, sender (optional).

Introspection

info: Load on-demand documentation for any tool or sub-agent. Delegates to skill manifests under src/kohakuterrarium/builtin_skills/ and per-agent overrides. Direct.

  • Args: target (tool or sub-agent name).

stop_task: Cancel a running background task or trigger by id. Direct.

  • Args: job_id (job id from any tool call; or the trigger id returned by add_timer/watch_channel/add_schedule).

Setup-able triggers (exposed as tools via type: trigger)

Each universal trigger class is wrapped as its own tool via modules/trigger/callable.py:CallableTriggerTool. A creature opts in by listing the trigger's setup_tool_name under tools: with type: trigger. The tool's description is prefixed with **Trigger**: so the LLM knows calling it installs a long-lived side-effect. All three return immediately with the installed trigger id; the trigger itself runs in the background.

add_timer (wraps TimerTrigger): Install a periodic timer.

  • Args: interval (seconds, required), prompt (required), immediate (bool, default false).

watch_channel (wraps ChannelTrigger): Listen on a named channel.

  • Args: channel_name (required), prompt (optional, supports {content}), filter_sender (optional).
  • The agent's own name is auto-set as ignore_sender to prevent self-triggering.

add_schedule (wraps SchedulerTrigger): Clock-aligned schedule.

  • Args: prompt (required); exactly one of every_minutes, daily_at (HH:MM), hourly_at (0-59).

Group tools

These mutate or inspect the graph the caller belongs to. They split into two tiers:

Basic: registered on every creature in a graph. The tool body gates per-call (e.g., group_send enforces the privileged-recipient rule for non-privileged callers):

  • send_channel: Broadcast a message to a channel the caller is wired to send on. Args: channel, content.
  • group_send: Direct point-to-point send to another creature in the caller's graph (bypasses channels). Non-privileged callers can only target privileged recipients (workers report to supervisors, not peer-workers). Args: target_creature_id, content.

Privileged: registered ONLY on privileged nodes:

  • group_add_node: Spawn a creature into the caller's graph. Args: config_path (file or @pkg/ref), optional name, llm, pwd. Returns the new creature's id.
  • group_remove_node: Stop and remove a creature from the graph. May trigger an auto-split if it was a bridge. Args: creature_id.
  • group_start_node / group_stop_node: Start or stop a creature without removing it. Args: creature_id.
  • group_channel: CRUD on channels and per-creature wiring. Args: actioncreate | delete | wire | unwire, channel, optional creature_id and direction. Cross-graph wires route through Terrarium.connect and may auto-merge.
  • group_wire: CRUD on output-wiring edges. Args: actionadd | remove, plus an edge spec (from, to, optional with_content, prompt).
  • group_status: Snapshot the caller's graph: creatures (with status, privilege, parent), channels (with history pointers, connected creatures), output wires, and the available catalog to spawn from. Args: none.

Sub-agents

Shipped sub-agent configs under src/kohakuterrarium/builtins/subagents/. Reference them in a creature config under subagents: by name.

All builtin sub-agents load default_plugins: ["auto-compact"] and the unified budget plugin with minimal runtime options: turn soft/hard 40/60, tool-call soft/hard 75/100, and no walltime budget.

NameToolsPurpose
workerread, write, bash, glob, grep, edit, multi_editFix bugs, refactor, run validations.
coordinatorsend_message, scratchpadDecompose → dispatch → aggregate.
exploreglob, grep, read, tree, bashRead-only exploration.
planexplore tools + thinkRead-only planning.
researchweb_search, web_fetch, read, write, think, scratchpadExternal research.
criticread, glob, grep, tree, bashCode review.
responsereadUser-facing copy generator. Typically output_to: external.
memory_readtree, read, grep over the memory folderRecall from agent memory.
memory_writetree, read, writePersist findings into memory.
summarize(no tools)Condense conversation for handoff or reset.

Inputs

Shipped input modules under src/kohakuterrarium/builtins/inputs/.

cli: Stdin prompt. Options: prompt, exit_commands.

cli_nonblocking: Same surface as cli but returns control to the event loop between keystrokes (useful when triggers fire during input).

none: No input. For trigger-only agents.

Audio/ASR implementations are not built-ins. The conversational example ships opt-in ASRModule/Whisper custom input files under examples/agent-apps/conversational/custom/; load them with type: custom.

Two further input types are resolved dynamically:

  • tui: mounted by the Textual app when running under TUI mode.
  • custom / package: loaded via module + class fields.

Outputs

Shipped output modules under src/kohakuterrarium/builtins/outputs/.

stdout: Print to stdout. Options: prefix, suffix, stream_suffix, flush_on_stream.

stdout_prefixed: stdout with a per-line prefix, useful for tagging side outputs.

console_tts: Console-only TTS shim that prints the synthesized text character-by-character with a configurable char_delay. Intended for demos and testing; there is no audio backend.

dummy_tts: Silent TTS that fires the usual TTS lifecycle events without any output. Useful in tests.

Additional routed types:

  • tui: renders into the Textual TUI widget tree.
  • custom / package: loaded via module + class.

There is no plain tts registry key. Real TTS backends (Fish, Edge, OpenAI, etc.) are shipped as custom/package outputs that subclass TTSModule.


User commands

Slash commands available inside input modules. Under src/kohakuterrarium/builtins/user_commands/.

CommandAliasesPurpose
/help/h, /?List commands.
/status/infoModel, message count, tools, jobs, compact state.
/clearClear conversation (the session log retains history).
/model [name]/llmShow current model or switch profile. Accepts canonical provider/name[@variations].
/compactManual context compaction.
/regen/regenerate, /retryRe-run the last assistant turn as a sibling branch.
/edit <message_index> <new content>(none)Edit a past user message and re-run from that point as a new branch.
/branch [<turn> <branch_id>|latest]/brList or switch the live branch for regen/edit alternatives.
/fork [event_id] [--name name](none)Copy the current session into a new .kohakutr file for alternate exploration.
/plugin [list|enable|disable|toggle] [name]/pluginsInspect or toggle plugins.
/skill [list|enable|disable|toggle|show] [name]/skillsInspect or toggle procedural skills.
/<skill-name> [args](none)User-invoke path for an enabled procedural skill when no built-in slash command shadows that name.
/exit/quit, /qGraceful exit. On web, a force flag may be required.

Framework commands

Inline directives the LLM can emit instead of a tool call. They talk to the framework directly (no tool round-trip). Defined under src/kohakuterrarium/commands/.

Framework commands use the same syntax family as tool calls: they follow the creature's configured tool_format (bracket / XML / native). The default bracket form with bare-identifier placeholders:

  • [/info]tool_or_subagent[info/]: Load a tool's, sub-agent's, or procedural skill's documentation on demand.
  • [/read_job]job_id[read_job/]: Read output from a background job. Supports --lines N and --offset M in the body.
  • [/jobs][jobs/]: List running jobs with IDs.
  • [/wait]job_id[wait/]: Block the current turn until a background job finishes.
  • [/skill]skill_name [args][skill/]: Return a procedural skill body to the model for explicit invocation.

Command names share a namespace with tool names; the command for reading job output is called read_job to avoid colliding with the read file-reader tool. Defined under src/kohakuterrarium/commands/.


LLM providers

Built-in provider types (backends):

ProviderBackend typeTransportNotes
codexcodexOpenAI Responses APIRouted via CodexOAuthProvider. No base_url → ChatGPT-subscription OAuth (kt login codex); with a base_url → API-key auth against a custom OpenAI-Responses endpoint (no OAuth). Ships provider-native tools such as image_gen.
openaiopenaiOpenAI /chat/completionsAPI-key auth (OPENAI_API_KEY).
openrouteropenaiOpenAI-compat against OpenRouterAPI-key auth (OPENROUTER_API_KEY); unified reasoning param.
anthropicanthropicAnthropic-compatible Messages APIAPI-key auth (ANTHROPIC_API_KEY). Uses the official anthropic SDK. Claude-specific knobs go through extra_body (thinking.*, output_config.*). Prompt-caching markers are auto-applied unless disabled.
geminiopenaiGoogle's OpenAI-compat endpointAPI-key auth (GEMINI_API_KEY).
mimoopenaiXiaomi MiMokt login mimo.
kimi-codeanthropicKimi Code Anthropic-compatible endpointAPI-key auth (KIMI_CODE_API_KEY).
glm-codinganthropicGLM Coding Plan Anthropic-compatible endpointAPI-key auth (GLM_CODING_API_KEY) with Bearer-token wiring.

Canonical backend types are openai, anthropic, and codex. Legacy codex-oauth backend type values are silently migrated on read (see configuration reference).

LLM presets

Shipped in src/kohakuterrarium/llm/presets.py. Use them as llm: or --llm values.

Naming convention (post-2026-04 refactor):

  • Direct / native-API variants are the primary name (claude-opus-4.7, gemini-3.1-pro, mimo-v2-pro).
  • OpenRouter-routed variants use the -or suffix (claude-opus-4.7-or).
  • OpenAI is an exception: gpt-5.4 stays bound to the Codex OAuth provider; the direct OpenAI API variant uses -api, OpenRouter uses -or.
  • Legacy names (claude-opus-4.6-direct, or-gpt-5.4, gemini-3.1-pro-direct, mimo-v2-pro-direct, …) survive as aliases so existing configs keep working.

OpenAI via Codex OAuth

  • gpt-5.3-codex-spark (ChatGPT Pro research preview; text-only)
  • gpt-5.5
  • gpt-5.4 (aliases: gpt5, gpt54)
  • gpt-5.3-codex (gpt53)
  • gpt-5.1
  • gpt-4o-codex (aliases: gpt4o, gpt-4o)
  • gpt-4o-mini-codex (alias: gpt-4o-mini)

OpenAI Direct API (-api suffix)

  • gpt-5.4-api (legacy alias: gpt-5.4-direct)
  • gpt-5.4-mini-api (gpt-5.4-mini-direct)
  • gpt-5.4-nano-api (gpt-5.4-nano-direct)
  • gpt-5.3-codex-api (gpt-5.3-codex-direct)
  • gpt-5.1-api (gpt-5.1-direct)
  • gpt-4o-api (gpt-4o-direct)
  • gpt-4o-mini-api (gpt-4o-mini-direct)

OpenAI via OpenRouter (-or suffix)

  • gpt-5.4-or (legacy alias: or-gpt-5.4)
  • gpt-5.4-mini-or (or-gpt-5.4-mini)
  • gpt-5.4-nano-or (or-gpt-5.4-nano)
  • gpt-5.3-codex-or (or-gpt-5.3-codex)
  • gpt-5.1-or (or-gpt-5.1)
  • gpt-4o-or (or-gpt-4o)
  • gpt-4o-mini-or (or-gpt-4o-mini)

Anthropic Claude Direct (no suffix: primary)

Routed through the native Anthropic-compatible Messages API. Effort via extra_body.output_config.effort.

  • claude-opus-4.7 (aliases: claude-opus, opus)
  • claude-opus-4.6 (legacy alias: claude-opus-4.6-direct)
  • claude-sonnet-4.6 (aliases: claude, claude-sonnet, sonnet; legacy: claude-sonnet-4.6-direct)
  • claude-haiku-4.5 (aliases: claude-haiku, haiku; legacy: claude-haiku-4.5-direct)

Anthropic Claude via OpenRouter (-or suffix)

  • claude-opus-4.7-or
  • claude-opus-4.6-or
  • claude-sonnet-4.6-or
  • claude-sonnet-4.5-or
  • claude-haiku-4.5-or
  • claude-sonnet-4-or (legacy alias: claude-sonnet-4)
  • claude-opus-4-or (legacy alias: claude-opus-4)

Google Gemini Direct (OpenAI-compat)

  • gemini-3.1-pro (aliases: gemini, gemini-pro; legacy: gemini-3.1-pro-direct)
  • gemini-3-flash (gemini-flash; legacy: gemini-3-flash-direct)
  • gemini-3.1-flash-lite (gemini-lite; legacy: gemini-3.1-flash-lite-direct)

Google Gemini via OpenRouter (-or suffix)

  • gemini-3.1-pro-or
  • gemini-3-flash-or
  • gemini-3.1-flash-lite-or
  • nano-banana (image-generation model, OpenRouter)

Google Gemma (OpenRouter)

  • gemma-4-31b (aliases: gemma, gemma-4)
  • gemma-4-26b

Qwen (OpenRouter)

  • qwen3.5-plus (qwen)
  • qwen3.5-flash
  • qwen3.5-397b
  • qwen3.5-27b
  • qwen3-coder (qwen-coder)
  • qwen3-coder-plus

Moonshot Kimi (OpenRouter)

  • kimi-k2.5 (kimi)
  • kimi-k2-thinking

Moonshot Kimi Code Direct (Anthropic-compatible)

  • kimi-for-coding (kimi-code)

MiniMax (OpenRouter)

  • minimax-m2.7 (minimax)
  • minimax-m2.5

Xiaomi MiMo Direct (no suffix: primary)

  • mimo-v2-pro (mimo; legacy alias: mimo-v2-pro-direct)
  • mimo-v2-flash (legacy alias: mimo-v2-flash-direct)

Xiaomi MiMo via OpenRouter (-or suffix)

  • mimo-v2-pro-or
  • mimo-v2-flash-or

GLM (Z.ai, OpenRouter)

  • glm-5
  • glm-5-turbo (alias: glm)

GLM Coding Plan Direct (Anthropic-compatible)

  • glm-5.1 (glm-code, glm-coding)
  • glm-5-turbo
  • glm-4.7
  • glm-4.5-air

xAI Grok (OpenRouter)

  • grok-4 (grok)
  • grok-4.20
  • grok-4.20-multi
  • grok-4-fast (grok-fast)
  • grok-4.1-fast
  • grok-code-fast (grok-code)
  • grok-3
  • grok-3-mini

Mistral (OpenRouter)

  • mistral-large-3 (aliases: mistral, mistral-large)
  • mistral-medium-3.1 (mistral-medium)
  • mistral-medium-3
  • mistral-small-4 (mistral-small)
  • mistral-small-3.2
  • magistral-medium (magistral)
  • magistral-small
  • codestral
  • devstral-2 (devstral)
  • devstral-medium
  • devstral-small
  • pixtral-large
  • ministral-3-14b (ministral)
  • ministral-3-8b

Preset token windows (max_context / max_output) are set per preset; see src/kohakuterrarium/llm/presets.py for the exact values, or kt config llm show <name>. controller.max_tokens overrides max_output; to adjust the compaction window, set compact.max_tokens.

Built-in preset merging also picks up llm_presets contributed by installed packages; see Package manifest in configuration.md.

Variation groups

A variation group lets one preset expose multiple knobs without duplicating the entry. Select with the preset@group=option shorthand in llm: / --llm, or via controller.variation_selections; see Variation selector in the configuration reference.

Presets not listed here have no variation group; their defaults are fixed.

OpenAI: Codex OAuth

PresetGroupOptions
gpt-5.3-codex-sparkreasoninglow, medium, high, xhigh
gpt-5.5reasoningnone, low, medium, high, xhigh
gpt-5.5speednormal, fast (maps to service_tier: priority)
gpt-5.4reasoningnone, low, medium, high, xhigh
gpt-5.4speednormal, fast (maps to service_tier: priority)
gpt-5.3-codexreasoningnone, low, medium, high, xhigh
gpt-5.1reasoningnone, low, medium, high, xhigh

OpenAI: Direct API (-api suffix)

Patches extra_body.reasoning.effort.

PresetGroupOptions
gpt-5.4-api, gpt-5.4-mini-api, gpt-5.4-nano-api, gpt-5.3-codex-api, gpt-5.1-apireasoningnone, low, medium, high, xhigh

OpenAI: OpenRouter (-or suffix)

Patches extra_body.reasoning.effort via OpenRouter's unified param.

PresetGroupOptions
gpt-5.4-or, gpt-5.4-mini-or, gpt-5.4-nano-or, gpt-5.3-codex-or, gpt-5.1-orreasoningminimal, low, medium, high, xhigh

Anthropic: Direct

Patches extra_body.output_config.effort via the compat layer.

PresetGroupOptions
claude-opus-4.7reasoninglow, medium, high, xhigh, max
claude-opus-4.6, claude-sonnet-4.6reasoninglow, medium, high, max

Haiku 4.5 uses the older extended-thinking (budget_tokens) and has no variation group.

Anthropic: OpenRouter (-or suffix)

Patches extra_body.reasoning.effort. xhigh is only honoured by Opus 4.7.

PresetGroupOptions
claude-opus-4.7-orreasoningminimal, low, medium, high, xhigh
claude-opus-4.6-or, claude-sonnet-4.6-or, claude-sonnet-4.5-or, claude-opus-4-or, claude-sonnet-4-orreasoningminimal, low, medium, high
claude-haiku-4.5-orreasoningoff, low, medium, high

Google Gemini: Direct

Patches extra_body.google.thinking_config.thinking_level.

PresetGroupOptions
gemini-3.1-prothinkinglow, medium, high
gemini-3-flash, gemini-3.1-flash-litethinkingminimal, low, medium, high

Google Gemini: OpenRouter

PresetGroupOptions
gemini-3.1-pro-or, gemini-3-flash-or, gemini-3.1-flash-lite-orreasoningminimal, low, medium, high

Gemma / Qwen / Kimi / MiMo / GLM: OpenRouter

Share the same OpenRouter unified reasoning group (unless noted).

PresetGroupOptions
gemma-4-31b, gemma-4-26breasoningminimal, low, medium, high
qwen3.5-plus, qwen3.5-flash, qwen3.5-397b, qwen3.5-27b, qwen3-coder, qwen3-coder-plusreasoningminimal, low, medium, high
kimi-k2.5reasoningminimal, low, medium, high
mimo-v2-pro, mimo-v2-flash, mimo-v2-pro-or, mimo-v2-flash-orreasoningminimal, low, medium, high
glm-5, glm-5-turboreasoningminimal, low, medium, high

kimi-k2-thinking has always-on thinking and no variation group.

Mistral: OpenRouter

PresetGroupOptions
mistral-small-4reasoningnone, high

Other Mistral presets (mistral-large-3, mistral-medium-*, mistral-small-3.2, codestral, devstral-*, pixtral-large, ministral-*) are not reasoning models. magistral-medium and magistral-small have always-on reasoning and no variation group.

Grok / MiniMax: OpenRouter

Grok 4.x (grok-4, grok-4.20, grok-4.20-multi, grok-4-fast, grok-4.1-fast, grok-code-fast) has mandatory non-configurable reasoning. grok-3 / grok-3-mini are legacy non-reasoning models. minimax-m2.7 / minimax-m2.5 have mandatory reasoning. None expose a variation group.


Prompt plugins

Shipped prompt plugins (loaded by prompt/aggregator.py). Ordered by priority (lower = earlier).

PriorityNameEmits
50ToolListPluginTool name + one-line description.
45FrameworkHintsPluginFramework command examples (info, read_job, jobs, wait, native tool usage) and tool-call format examples.
40EnvInfoPlugincwd, platform, date/time.
30ProjectInstructionsPluginLoads CLAUDE.md and .claude/rules.md.

Custom prompt plugins subclass BasePlugin and register via the plugins field in a creature config. See plugin-hooks.md for lifecycle and callback hooks.

Separate from prompt plugins, tools may also contribute one-line or short paragraph guidance into the aggregated ## Tool guidance section.


Compose algebra

Operator precedence: * > | > & > >>.

OperatorMeaning
a >> bSequence (auto-flatten). >> {key: fn} forms a Router.
a & bProduct (asyncio.gather; broadcast input).
a | bFallback (catch exception, try next).
a * NRetry (N additional attempts).

Factories: Pure, Sequence, Product, Fallback, Retry, Router, Iterator. Wrapping helpers: agent(config_path) for persistent agents, factory(config) for ephemeral per-call agents.

Runnable methods: .map(f) (post-transform output), .contramap(f) (pre-transform input), .fails_when(pred) (raise on a predicate).


MCP surface

Built-in MCP meta-tools (exposed when mcp_servers is configured):

  • mcp_list: list connected servers and their tools.
  • mcp_call: invoke a tool on a specific server.
  • mcp_connect: connect to a server declared in config.
  • mcp_disconnect: tear down a connection.

Server tools are surfaced in the system prompt under ## Available MCP Tools. Transports: stdio (subprocess), streamable_http (modern HTTP MCP), and legacy http/sse SSE endpoints.

Python surface: MCPServerConfig, MCPClientManager in kohakuterrarium.mcp.


Extensions

A package's kohaku.yaml may contribute creatures, terrariums, tools, plugins, io, triggers, skills, commands, user_commands, prompts, framework_hints, llm_presets, and python_dependencies. kt extension list inventories them. Python modules resolve by module:class refs; configs resolve via @pkg/path. See Package manifest in configuration.md.


See also