Kowalski Agent Template
A flexible foundation for building custom AI agents in the Kowalski ecosystem. This crate provides a robust agent base, builder patterns, configuration, and ready-to-use templates for rapid agent development.
Description
kowalski-agent-template is designed to make it easy to create new, specialized AI agents by composing tools, task handlers, and configuration. It provides a TemplateAgent abstraction, a builder for ergonomic construction, and a set of templates (such as general-purpose and research agents) to jumpstart development.
Dependencies
- kowalski-core — Core agent abstractions, tools, and types
- kowalski-tools — Ready-to-use tools (web search, PDF, data, code, etc.)
- tokio — Async runtime
- reqwest — HTTP client
- serde — Serialization/deserialization
- serde_json — JSON support
- async-trait — Async trait support
- log — Logging
- thiserror — Error handling
- futures — Async utilities
- bytes — Byte buffers
- tower, tower-http — Middleware and HTTP utilities
- tracing, tracing-subscriber — Structured logging and tracing
- url — URL parsing
- regex — Regular expressions
- markdown — Markdown parsing
- env_logger — Logging backend
Architecture
kowalski-agent-template/
├── src/
│ ├── agent.rs # TemplateAgent and TaskHandler traits
│ ├── builder.rs # AgentBuilder for ergonomic agent construction
│ ├── config.rs # TemplateAgentConfig and defaults
│ ├── lib.rs # Library entry point
│ └── templates/ # Predefined agent templates
│ ├── general.rs # General-purpose agent template
│ ├── research.rs # Research-focused agent template
│ └── mod.rs
- TemplateAgent: Core agent abstraction with tool/task handler registration and execution
- AgentBuilder: Builder pattern for ergonomic agent construction
- Templates: Predefined agent blueprints for common use cases
- Config: Extensible configuration for agent behavior and system prompts
Core Functionality & Examples
1. TemplateAgent: The Extensible Agent
The TemplateAgent struct provides a flexible base for building custom agents. It supports:
- Tool registration (for pluggable capabilities)
- Task handler registration (for custom logic)
- System prompt configuration
- Async task execution
use TemplateAgent;
use ;
use Config;
let config = default;
let agent = new.await?;
// Register tools and handlers as needed
2. AgentBuilder: Ergonomic Construction
The AgentBuilder pattern allows you to fluently compose an agent with custom tools, prompts, and settings.
use AgentBuilder;
use WebSearchTool;
let builder = new
.await
.with_system_prompt
.with_tool
.with_temperature;
let agent = builder.build.await?;
3. Configuration
The TemplateAgentConfig struct provides flexible configuration for agent behavior, including concurrency, timeouts, user agent, and system prompt.
use TemplateAgentConfig;
let config = default;
println!;
4. Templates: Ready-to-Use Agent Blueprints
GeneralTemplate
A general-purpose agent with basic tools (web search, PDF processing) and customizable prompt/temperature.
use GeneralTemplate;
let builder = create_default_agent.await?;
let agent = builder.build.await?;
You can also create a custom general agent:
let builder = create_agent.await?;
let agent = builder.build.await?;
ResearchTemplate
A research-focused agent with web search and PDF analysis tools, and a research-oriented system prompt.
use ResearchTemplate;
let builder = create_agent.await?;
let agent = builder.build.await?;
How to Extend
- Add new tools: Implement the
Tooltrait and register with your agent or builder. - Add new task handlers: Implement the
TaskHandlertrait for custom logic. - Create new templates: Compose new agent blueprints in the
templates/directory. - Customize configuration: Use or extend
TemplateAgentConfigfor new settings.
Future Enhancements
- More agent templates for specific domains (e.g., coding, data analysis, customer support)
- Dynamic tool loading and plugin support
- Advanced orchestration (multi-agent, federated agents)
- Persistent agent state and conversation history
- Integration with external APIs and databases
- Enhanced configuration and environment support