Role Creation
A role file (role.yaml) defines your agent — its model, system prompt, tools, guardrails, and everything else. InitRunner gives you multiple ways to create one depending on how much control you want.
Quick Comparison
| Method | Command | Best for |
|---|---|---|
| AI Generate | initrunner create "..." | Fastest start — describe what you want in plain English |
| Interactive Wizard | initrunner init -i | Guided setup with tool configuration prompts |
| Template | initrunner init --template <name> | Non-interactive scaffolding from a known pattern |
| Copy Example | initrunner examples copy <name> | Learning from complete, runnable examples |
| Dashboard | /roles/new in the web UI | Visual form builder or AI generation in the browser |
| Manual YAML | Create role.yaml by hand | Full control over every field |
AI Generation
Generate a complete role from a natural language description:
initrunner create "A code review assistant that reads git diffs and suggests improvements"This creates a role.yaml in the current directory. Review it, tweak if needed, and run it.
Flags
| Flag | Description |
|---|---|
--provider TEXT | Model provider for generation (auto-detected if omitted) |
--output PATH | Output file path (default: role.yaml) |
--name TEXT | Agent name (auto-derived from description if omitted) |
--model TEXT | Model name for the generated role (e.g. gpt-4o, claude-sonnet-4-5-20250929) |
--no-confirm | Skip the YAML preview and write immediately |
How It Works
- Builds a dynamic schema reference by introspecting Pydantic models. This includes all tool types from the registry, trigger types, sink types, and every configurable field with defaults.
- Sends the description plus schema reference to the configured LLM.
- Validates the returned YAML against
RoleDefinition. - If validation fails, retries once by sending the error back to the LLM for correction.
Provider Auto-Detection
When --provider is omitted, InitRunner checks for available API keys in the environment (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.) and uses the first provider found. Falls back to openai.
Example
initrunner create "A Python tutor that executes code examples and explains errors" \
--provider anthropic \
--name python-tutor \
--output tutor-role.yamlInteractive Wizard
Launch the guided wizard:
initrunner init -iThe wizard walks through each section of a role definition, building a complete role.yaml step by step.
Wizard Flow
- Agent name — lowercase with hyphens (e.g.
my-agent) - Description — optional free-text
- Provider — choose from
openai,anthropic,google,groq,mistral,cohere,ollama - Model — choose from a curated list for the selected provider, or type a custom model name
- Base template — pre-populates system prompt, tools, and features (see table below)
- Tool selection — pick tools by number or name, then configure each one
- Memory — enable/disable long-term memory
- Ingestion — enable/disable RAG with source glob and chunking config
- Output file — path to write (default:
role.yaml)
Templates
| Template | Description |
|---|---|
basic | Simple assistant |
rag | Answers from your documents |
memory | Remembers across sessions |
daemon | Runs on schedule / watches files |
api | Declarative REST API tools |
blank | Just the essentials, add everything yourself |
Available Tools
| Tool | Description | Key config fields |
|---|---|---|
filesystem | Read/write files | root_path, read_only |
git | Git operations | — |
python | Execute Python code | — |
shell | Run shell commands | require_confirmation, timeout_seconds |
http | HTTP requests | — |
web_reader | Fetch web pages | — |
sql | Query SQLite databases | — |
datetime | Date/time utilities | — |
mcp | MCP server integration | — |
slack | Send Slack messages | — |
Each selected tool prompts for its key configuration fields. For details on all tools, see Tools.
Anthropic Embedding Warning
When the wizard detects that anthropic is selected as the provider and memory or ingestion is enabled, it displays a warning:
Warning: Anthropic does not provide an embeddings API. RAG and memory features require
OPENAI_API_KEYfor embeddings.
The embedding provider can be overridden via spec.ingest.embeddings or spec.memory.embeddings in the generated role file.
Templates
Scaffold from a built-in template without interactive prompts:
initrunner init --name my-agent --template basicAvailable templates: basic, rag, daemon, memory, ollama, tool, api, skill.
# RAG agent with document search
initrunner init --name doc-search --template rag
# Background daemon that runs on a schedule
initrunner init --name watcher --template daemon
# Agent with long-term memory
initrunner init --name assistant --template memoryCopy an Example
Browse and copy community examples:
initrunner examples list # browse available examples
initrunner examples show file-reader # preview the YAML
initrunner examples copy file-reader # copy files to current directorySee Examples for the full catalog.
Dashboard — Create Role
The web dashboard at /roles/new offers two tabs for role creation.
Form Builder Tab
A structured form with fields for:
- Name, description
- Provider, model (dropdown with curated per-provider options and custom input)
- System prompt
- Tool checkboxes
- Memory and ingestion toggles
- Live YAML preview that updates as you fill in the form
Submitting the form calls POST /api/roles with the generated YAML.
AI Generate Tab
- Enter a natural language description
- Click Generate to produce a
role.yamlvia AI - Review and edit the generated YAML
- Click Save to persist
This calls POST /api/roles/generate to get the YAML, then POST /api/roles to save.
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /api/roles | Create a new role from YAML content |
POST | /api/roles/generate | Generate YAML from a natural language description |
POST /api/roles returns 409 if a role file with the same name already exists.
Manual YAML
For full control, create a role.yaml by hand. Every role file has four top-level keys: apiVersion, kind, metadata, and spec. See Configuration for the full schema reference.
Minimum Viable Role
The smallest valid role needs metadata, a system prompt, and a model:
apiVersion: initrunner/v1
kind: Agent
metadata:
name: my-agent
description: A helpful assistant
spec:
role: |
You are a helpful assistant.
model:
provider: openai
name: gpt-4o-miniAdding Tools
Add a tools list under spec:
spec:
tools:
- type: filesystem
root_path: .
read_only: true
- type: shell
require_confirmation: true
timeout_seconds: 30Adding Memory
Add a memory section so the agent remembers across sessions:
spec:
memory:
max_sessions: 10
max_resume_messages: 20
semantic:
max_memories: 500Run with --resume to pick up where you left off. See Memory for details.
Adding Ingestion / RAG
Add an ingest section to let the agent search your documents:
spec:
ingest:
sources:
- "./**/*.md"
chunking:
strategy: paragraph
chunk_size: 512
chunk_overlap: 50Run initrunner ingest role.yaml to index, then ask questions about your docs. See Ingestion for details.
Adding Triggers and Sinks
Triggers automate when the agent runs. Sinks control where output goes:
spec:
triggers:
- type: cron
schedule: "*/30 * * * *"
- type: watch
paths: ["./src/**/*.py"]
sinks:
- type: file
path: ./reports/output.md
- type: slack
channel: "#alerts"See Triggers and Sinks for all options.
Adding Guardrails
Set resource limits to keep the agent safe:
spec:
guardrails:
max_tokens_per_run: 10000
max_tool_calls: 10
timeout_seconds: 60
max_request_limit: 10See Guardrails for the full reference.
Editing Existing Roles
Dashboard YAML Editor
The role detail page (/roles/{role_id}) includes an editable YAML tab with Save and Reset buttons.
- Save calls
PUT /api/roles/{role_id}with the updated YAML content - Creates a
.bakbackup of the existing file before overwriting - Validates the YAML against
RoleDefinitionbefore writing
CLI Editing
Open the role file in your editor, make changes, then validate:
$EDITOR role.yaml
initrunner validate role.yamlValidation
Check your YAML before running:
initrunner validate role.yamlThis parses the file and validates it against the RoleDefinition schema. Errors are printed with field paths so you can fix them quickly.
Security Notes
- Name validation:
metadata.namemust match^[a-z0-9][a-z0-9-]*[a-z0-9]$ - Directory restrictions: API writes are restricted to configured role directories; path traversal (
..) is rejected - Overwrite protection:
POST /api/rolesreturns409if the file exists; updates viaPUTcreate a.bakbackup before overwriting - Validation before write: YAML is parsed and validated against
RoleDefinitionbefore being written to disk
Next Steps
- Configuration — Full YAML schema reference
- Tools — All available tools and their configuration
- Examples — Complete, runnable agents for common use cases
- Quickstart — Get your first agent running in under five minutes