ctx0 Agents
This document defines the agent system for ctx0, including configuration format, default agents, and how to create custom agents.
Overview
Agents are specialized AI assistants that handle specific types of tasks. Each agent has:
- AGENT.md: System prompt that defines the agent's behavior
- config.json: Structured configuration (tools, model, permissions)
Agents can be invoked by other agents as subagents, enabling composition and delegation.
Agent File Structure
Each agent lives in its own folder under /agents/:
agents/
├── ctx0/ # Agent folder
│ ├── AGENT.md # System prompt (required)
│ ├── config.json # Configuration (required)
│ └── examples/ # Optional: few-shot examples
│ ├── remember-contact.md
│ └── query-emails.md
├── curator/
│ ├── AGENT.md
│ └── config.json
└── {user-agents}/
AGENT.md Format
The AGENT.md file contains YAML frontmatter followed by the system prompt in markdown.
--- name: ctx0 description: The vault navigator for bot0. Use for storing, retrieving, and organizing personal knowledge. tools: - ctx0_remember - ctx0_retrieve - ctx0_sql - ctx0_browse - ctx0_read disallowedTools: - Bash model: inherit permissionMode: default skills: - gmail - slack --- You are ctx0, the vault navigator for bot0. ## Your Role You understand the ctx0 infrastructure and help users organize, retrieve, and manage their personal knowledge base. ## Available Tools - `ctx0_remember` - Store new information in the vault - `ctx0_retrieve` - Semantic search across entries - `ctx0_sql` - Query sync tables (read SKILL.md first!) - `ctx0_browse` - List entries in a path - `ctx0_read` - Read full entry content ## Working with Skills When you need data from external sources (email, slack, calendar): 1. Read the relevant skill: `/skills/gmail/SKILL.md` 2. Understand the schema and query patterns 3. Use `ctx0_sql` to query the sync_* tables 4. Save useful results to `/skills/gmail/_results/` ## Guidelines - Always confirm before storing sensitive information - Use appropriate paths based on content type - Provide sources when retrieving information
Frontmatter Fields
| Field | Required | Description |
|---|---|---|
name | Yes | Unique identifier (lowercase, hyphens allowed) |
description | Yes | When to invoke this agent |
tools | No | Tools the agent can use (inherits all if omitted) |
disallowedTools | No | Tools to deny (removed from inherited/specified list) |
model | No | Model to use: sonnet, opus, haiku, or inherit |
permissionMode | No | Permission handling: default, acceptEdits, dontAsk |
skills | No | Skills to preload into agent context |
subagents | No | Other agents this agent can invoke |
config.json Format
The config.json file contains structured configuration that complements AGENT.md.
{ "name": "ctx0", "description": "The vault navigator for bot0...", "tools": [ "ctx0_remember", "ctx0_retrieve", "ctx0_sql", "ctx0_browse", "ctx0_read" ], "disallowedTools": ["Bash"], "model": "inherit", "permissionMode": "default", "skills": ["gmail", "slack"], "subagents": ["curator"], "isSystem": true, "canBeDisabled": false, "color": "#b366ff" }
Config Fields
| Field | Type | Description |
|---|---|---|
name | string | Agent identifier |
description | string | Short description |
tools | string[] | Allowed tools |
disallowedTools | string[] | Denied tools |
model | string | Model preference |
permissionMode | string | Permission mode |
skills | string[] | Preloaded skills |
subagents | string[] | Agents this can invoke |
isSystem | boolean | System-created agent |
canBeDisabled | boolean | Whether user can disable |
color | string | UI display color (hex) |
Default Agents
Default agents are defined as system entries in code (packages/ctx0/src/system-entries/agents/). They are:
- Available to all users immediately - No database seeding required
- Instantly updatable - Change code, redeploy, all users see updates
- Customizable - Users can "fork" agents by editing them
- Resettable - Users can revert to the system default anytime
See ctx0 System Entries for the full fork-on-edit pattern.
ctx0 - Vault Navigator
The primary agent for interacting with the vault.
Purpose:
- Store new information (ctx0_remember)
- Retrieve context (ctx0_retrieve)
- Query sync data (ctx0_sql)
- Browse vault structure (ctx0_browse)
AGENT.md:
--- name: ctx0 description: The vault navigator for bot0. Use for storing, retrieving, and organizing personal knowledge. Invoke proactively when user mentions remembering, finding, or organizing information. tools: - ctx0_remember - ctx0_retrieve - ctx0_sql - ctx0_browse - ctx0_read model: inherit skills: - gmail - slack - calendar --- You are ctx0, the vault navigator for bot0. You understand the ctx0 infrastructure and help users organize, retrieve, and manage their personal knowledge base. ## Your Role You are a subagent that other agents can invoke for vault operations. When another agent needs to remember something, retrieve context, or query synced data, they delegate to you. ## Vault Structure The vault has locked system folders: - `/agents/` - Agent configurations (including me) - `/skills/` - Database skill definitions - `/tools/` - Tool definitions - `/mcp/` - MCP server configs And flexible user folders: - `/contacts/` - People and organizations - `/projects/` - Work projects - `/knowledge/` - Facts, learnings - `/decisions/` - Important decisions with rationale ## Working with Skills When you need data from external sources (email, slack, calendar): 1. Read the relevant skill: `/skills/gmail/SKILL.md` 2. Understand the schema and query patterns 3. Use `ctx0_sql` to query the sync_* tables 4. Save useful results to `/skills/gmail/_results/` ## When Invoked 1. Understand what the user/agent needs 2. Choose appropriate tool(s) 3. Execute and return results 4. Optionally save valuable results to vault
curator - Vault Organizer
Organizes working memory into the vault structure.
Purpose:
- Process working memory entries
- Decide where to file content
- Create/update vault entries
- Maintain organization
AGENT.md:
--- name: curator description: The vault organizer. Processes working memory and files content into appropriate vault locations. Runs periodically or on-demand. tools: - ctx0_browse - ctx0_read - ctx0_remember subagents: - ctx0 model: sonnet --- You are the curator, responsible for organizing the ctx0 vault. ## Your Role You process entries from `ctx0_working_memory` and file them into the appropriate locations in the vault. ## Process 1. Read unprocessed working memory entries 2. For each entry: - Analyze the content and metadata - Decide the appropriate path (use suggested_path as hint) - Check if related entries exist - Create new entry or update existing 3. Mark entries as processed ## Organization Guidelines | Content Type | Suggested Location | |--------------|-------------------| | Person info | `/contacts/{name}.md` | | Project context | `/projects/{project}/` | | Facts/learnings | `/knowledge/` | | Decisions | `/decisions/` | | Preferences | `/preferences/` | ## When Updating Existing Entries - Preserve existing content structure - Add new information in appropriate sections - Update frontmatter if needed - Note the source of the update ## When Creating New Entries - Use descriptive, URL-safe names - Include appropriate frontmatter - Link to related entries - Add relevant tags
Creating Custom Agents
Step 1: Create Agent Folder
# Create folder structure mkdir -p agents/sales-assistant
Step 2: Write AGENT.md
--- name: sales-assistant description: Helps with sales tasks - finding contacts, drafting emails, tracking deals. Use when discussing sales, leads, or customer outreach. tools: - ctx0_retrieve - ctx0_sql disallowedTools: - ctx0_remember subagents: - ctx0 model: sonnet skills: - gmail - calendar --- You are a sales assistant. You help with sales-related tasks. ## Capabilities - Find relevant contacts using ctx0_retrieve - Query emails about deals using ctx0_sql (via gmail skill) - Check calendar for meeting availability - Draft follow-up emails ## Using ctx0 Subagent When you need to store information (new contacts, deal updates), delegate to the ctx0 subagent: "Use ctx0 to remember that John Smith from Acme Corp is interested in our enterprise plan." ## Guidelines - Always confirm before sending emails - Be concise in communications - Focus on building relationships
Step 3: Write config.json
{ "name": "sales-assistant", "description": "Sales task helper", "tools": ["ctx0_retrieve", "ctx0_sql"], "disallowedTools": ["ctx0_remember"], "subagents": ["ctx0"], "model": "sonnet", "skills": ["gmail", "calendar"], "isSystem": false, "canBeDisabled": true, "color": "#4ade80" }
Subagent Composition
Agents can invoke other agents as subagents, enabling composition.
How Subagents Work
- Parent agent decides to delegate a task
- Parent invokes subagent with a specific task
- Subagent runs in its own context with its own tools
- Subagent returns results to parent
- Parent continues with the results
Defining Subagent Access
In AGENT.md frontmatter:
--- name: my-agent subagents: - ctx0 # Can invoke ctx0 - curator # Can invoke curator ---
In config.json:
{ "subagents": ["ctx0", "curator"] }
Invoking Subagents
In the agent's system prompt, explain how to use subagents:
## Using Subagents When you need to store or retrieve information, delegate to ctx0: "Use ctx0 to remember that [information]" "Ask ctx0 to find information about [topic]" When you need to organize content, delegate to curator: "Have curator file the working memory entries"
Subagent Rules
- Subagents cannot invoke other subagents (prevents infinite nesting)
- Subagents run with their own tool permissions
- Results are returned to the parent agent
- Subagents don't have access to parent's conversation history
Permission Modes
Control how agents handle permission prompts.
| Mode | Behavior |
|---|---|
default | Standard permission checking with prompts |
acceptEdits | Auto-accept file edits |
dontAsk | Auto-deny permission prompts |
bypassPermissions | Skip all permission checks (use with caution) |
Model Selection
Control which model the agent uses.
| Value | Behavior |
|---|---|
inherit | Use same model as parent conversation |
sonnet | Use Claude Sonnet (balanced) |
opus | Use Claude Opus (most capable) |
haiku | Use Claude Haiku (fastest, cheapest) |
Guidelines:
- Use
haikufor simple, fast tasks - Use
sonnetfor most agent work - Use
opusfor complex reasoning - Use
inheritfor consistency with main conversation
Preloading Skills
Skills can be preloaded into an agent's context at startup.
--- name: email-assistant skills: - gmail - calendar ---
When skills are preloaded:
- Full SKILL.md content is injected into agent context
- Agent knows the schema without reading files
- Useful for specialized agents that always need certain skills
Best Practices
Writing Good Descriptions
The description determines when the agent is invoked. Be specific:
# Good - specific triggers description: Helps with sales tasks - finding contacts, drafting emails, tracking deals. Use when discussing sales, leads, or customer outreach. # Bad - too vague description: Helps with work stuff.
Tool Selection
Grant only necessary tools:
# Good - minimal permissions tools: - ctx0_retrieve - ctx0_sql # Bad - grants everything tools: [] # Empty = inherit all
Subagent Delegation
Clear instructions for delegation:
## When to Delegate - Need to remember something → Use ctx0 - Need to organize content → Use curator - Need to search emails → Use gmail skill via ctx0_sql ## How to Delegate Be specific about what you need: "Use ctx0 to remember that Sarah prefers 10am meetings" "Ask ctx0 to find recent emails from investors"
Related Documentation
- ctx0 System Entries - Fork-on-edit pattern for default agents
- ctx0 Vault Structure - Folder organization
- ctx0 Skills - DB-as-skill pattern
- ctx0 Supabase Data Architecture - Database schema