Templates Section
Overview
The Templates section provides access to reusable agent configurations that can accelerate agent development. Templates are agents with no team assignment (team_id: null
) that can be accessed by all teams for creating new agents.
1. Templates Dashboard
Templates Main Interface - Browse and manage agent templates
The templates interface (AgentList
component) provides:
- Template Table: View all available templates with ID, title, and creation date
- Add Agent Button: Create new agents (which can become templates)
- Template Actions: Duplicate and delete templates (with permissions)
- Data Table Features: Enhanced sorting, filtering, and search capabilities
- Permission-Based Access: Create and delete actions based on user permissions
2. Creating Templates from Agents
Saving an Agent as Template
You can convert any existing agent into a reusable template:
- Navigate to Agents: Go to the agents list in your team
- Select Agent: Find the agent you want to save as a template
- Save as Template: Click the template action button
- Template Creation: The system creates a copy with:
team_id
set tonull
(making it globally accessible)- Title appended with "(Template)"
- New unique ID generated
- All worker configurations and connections preserved
Template Auto-Generation
The system includes an AgentTemplateGenerator
that can create templates from descriptions:
Automated Template Creation:
- AI-Powered Generation: Uses available AI models (GPT-4, Claude, etc.) to generate templates
- Description-Based: Creates agents based on natural language descriptions
- Fallback System: Uses specialized templates when AI generation isn't available
- Structured Output: Generates proper agent configurations with workers and prompts
Generation Process:
- Model Selection: System selects best available AI model from API keys
- Prompt Building: Constructs generation prompt from user description
- Template Generation: AI creates structured agent configuration
- Response Parsing: Converts AI output into valid agent template
- Fallback Handling: Uses pre-built specialized templates if generation fails
3. Template Management Interface
Database Structure
Template Storage:
- Templates are stored in the
agents
table withteam_id: null
- Query:
SELECT id, title, description, type, created_at FROM agents WHERE team_id IS NULL
- Ordered by creation date (newest first)
Template Actions
Available Actions (Permission-Based):
- Duplicate Template: Creates a copy with "(copy)" suffix appended to title
- Delete Template: Permanently removes template from database
- Create New Agent: Navigate to agent creation (can later be saved as template)
Permission System:
- Create Templates: Requires
canCreate("templates")
permission - Delete Templates: Requires
canDelete("templates")
permission - Actions are only visible/accessible based on user permissions
Data Table Features
Enhanced Data Table (EnhancedDataTable
):
- Sortable Columns: Sort by ID, title, or creation date
- Resizable Columns: Adjust column widths as needed
- Row Selection: Click rows to navigate to agent details
- Empty State: Shows "No agent templates found." when no templates exist
- Loading State: Displays spinner while fetching templates
4. Using Templates
From Templates Page
- Access Templates: Navigate to the templates section
- Browse Available Templates: View table of all templates with ID, title, and creation date
- Select Template: Click on a template row to view details
- Duplicate for Use: Use the duplicate action to create a copy you can modify
When Creating New Agents
Template Worker
The system includes a template
worker type for Handlebars-based templating:
Template Worker Features:
- Type:
template
worker with conditional support - Inputs: Template string input
- Outputs: Processed template output
- Processing: Uses Handlebars templating for compilation and execution
- User Fields: Supports custom user-defined template variables
5. Error Handling and Notifications
Template Creation Feedback
Success Messages:
- Save as Template: "Agent saved as template - '[agent.title]' has been successfully saved as a template."
- Duplicate Template: "Agent duplicated - A copy of '[template.title]' was created."
- Delete Template: "Agent deleted - '[template.title]' has been deleted."
Error Handling:
- Save Errors: Shows "Error saving as template" with specific error details
- Duplicate Errors: "Error duplicating agent" with error message
- Delete Errors: "Error deleting agent" with error description
- Loading Errors: Console logging of fetch errors with empty array fallback
Query Management
React Query Integration:
- Templates Query:
['agents-template']
for template list - Cache Invalidation: Automatically updates both agents and templates queries after operations
- Loading States: Proper loading indicators during async operations
- Error Boundaries: Graceful error handling with user feedback