Skip to content

Agent Templates

The agents stdlib package provides pre-built agent configuration templates for common use cases. Use them with create_agent() to quickly spin up specialized agents.

Usage

haira
import "agents"

provider openai {
    api_key: env("OPENAI_API_KEY")
    model: "gpt-4o"
}

fn main() {
    config = agents.code_reviewer()
    reviewer = create_agent(config, openai, [lint_code])
    result, err = reviewer.ask("Review this function...")
}

Available Templates

TemplateFunctionDescription
Code Revieweragents.code_reviewer()Reviews code for bugs, security, and style
Planneragents.planner()Breaks tasks into actionable plans
Security Revieweragents.security_reviewer()Audits code for security vulnerabilities
Summarizeragents.summarizer()Summarizes text into key points
Data Analystagents.data_analyst()Analyzes data and generates insights
Customer Supportagents.customer_support()Handles customer support queries
TDD Guideagents.tdd_guide()Guides test-driven development
Doc Writeragents.doc_writer()Writes documentation from code

Template Configuration

Each template returns a configuration map with:

haira
{
    "name": "CodeReviewer",
    "system": "You are an expert code reviewer...",
    "temperature": 0.3
}

You can override any field after getting the config:

haira
config = agents.code_reviewer()
config["temperature"] = 0.1  // More deterministic
reviewer = create_agent(config, anthropic, [lint_code, check_tests])

Dynamic Agents

The create_agent() built-in function creates agents at runtime from configuration maps:

haira
fn create_custom_agent(role: string) {
    config = {
        "name": role,
        "system": "You are a ${role}. Be helpful and concise.",
        "temperature": 0.5
    }
    return create_agent(config, openai, [])
}

Next Steps

Released under the Apache-2.0 License.