Examples

June 11, 2026 · View on GitHub

Agent Apps (agent-apps/)

Single-agent configurations demonstrating different architecture patterns. Each is a complete creature config runnable with kt run.

kt run examples/agent-apps/<name>
AgentPatternKey Feature
discord_botGroup chat botCustom Discord I/O, ephemeral, native tool calling
planner_agentPlan-execute-reflectScratchpad tracking, critic review
monitor_agentTrigger-driven monitoringNo user input, timer triggers
conversationalStreaming ASR/TTSWhisper input, interactive output sub-agent
rp_agentCharacter roleplayMemory-first, startup trigger
compact_testCompaction stress testAuto-compact with small context

Terrariums (terrariums/)

Multi-agent configurations demonstrating creature coordination.

kt terrarium run examples/terrariums/<name>
TerrariumTopologyCreatures
novel_terrariumPipeline with feedback loopbrainstorm → planner → writer
code_review_teamLoop with gate (review → approve/reject)developer, reviewer, tester
research_assistantStar with coordinatorcoordinator, searcher, analyst

Plugins (plugins/)

Educational plugin examples demonstrating every hook type in the plugin API. See plugins/README.md for the full reference.

PluginHooksDifficulty
hello_pluginLifecycle: on_load, on_agent_start/stopBeginner
tool_timerpre/post_tool_execute, state persistenceBeginner
tool_guardpre_tool_execute, PluginBlockError (blocking)Intermediate
prompt_injectorpre_llm_call (message modification)Intermediate
response_loggerpost_llm_call, on_event, on_interrupt, on_compact_endIntermediate
budget_enforcerpost_llm_call + pre_llm_call (blocking), stateAdvanced
subagent_trackerpre/post_subagent_run, on_task_promotedAdvanced
webhook_notifierAll callbacks, inject_event, switch_modelAdvanced

Code (code/)

Programmatic usage: embedding agents in your own applications.

The key distinction from config-based usage: your program is the orchestrator, agents are workers you invoke. The agent doesn't run itself; you control when, what, and how it processes.

Two complementary surfaces:

# Direct: typed turns on an agent or engine-hosted creature
from kohakuterrarium import Agent, Terrarium

agent = await Agent.build("@kt-biome/creatures/general")
await agent.start()
result = await agent.run("summarize ./notes.md", timeout=300)
print(result.status, result.text, result.usage)

async with Terrarium() as engine:
    worker = await engine.add_creature(
        "@kt-biome/creatures/swe", llm="fast",
        pwd=workdir, session=workdir / "run.kohakutr",
    )
    result = await worker.run(task)
# Compose: pipeline operators over agents and plain callables
from kohakuterrarium.compose import agent, factory

async with await agent("@kt-biome/creatures/swe") as swe:
    result = await (swe >> extract_code >> reviewer)(task)

# Operators: >> (sequence), & (parallel), | (fallback), * (retry)
safe = (expert * 2) | generalist
results = await (analyst & writer & designer)(task)

async for result in (writer >> reviewer).iterate(task):
    if "APPROVED" in result:
        break
ScriptPatternKey API
programmatic_chatAgent as library (baseline)Agent.build, run → TurnResult, run_stream
batch_gradingN work folders, one engineadd_creature(llm=, pwd=, session=), TurnResult
custom_toolsTools from plain functions@kt.tool, add_creature(tools=), SessionReader
terrarium_soloSingle creature on the engineTerrarium.with_creature, chat streaming
terrarium_recipeRun a terrarium from codeTerrarium.from_recipe, engine.channel, subscribe
terrarium_hotplugLive graph merge / splitadd_creature, connect / disconnect, events
discord_adventure_botBot-owned interactionshared engine, dynamic NPC creatures, game state
debate_arenaMulti-agent turn-takingagent(), >>, async for, async with
task_orchestratorDynamic agent topologyfactory(), >>, asyncio.gather
ensemble_votingRedundancy through diversity& (parallel), >> auto-wrap, | fallback, * retry
review_loopWrite → review → revise cycleasync for iterate, >> transforms, persistent agent()
smart_routerClassify → route to specialist>> dict routing, factory(), | fallback
pipeline_transformsData extraction pipeline>> auto-wrap (json.loads, lambdas), mix agents + functions