Skip to main content

What are Agents?

Agents are the core building blocks of Agate applications. They are modular, reusable components that encapsulate specific functionality and can interact with users, manage state, and communicate with other agents.

Agent Types

Interactive Agents

Interactive agents provide user interfaces and handle user input:

Background Agents

Background agents run tasks without direct user interaction:

Creating Custom Agents

Basic Agent Structure

All agents must implement the Agent interface:

Example: File Watcher Agent

Agent Communication

Agents can communicate through the message bus:

Agent Lifecycle

Registration

Lifecycle Hooks

Best Practices

Each agent should have a single, well-defined responsibility. This makes them easier to test, maintain, and reuse.
Implement robust error handling. Agents should gracefully handle errors and communicate issues through the message bus or logging.
Always clean up resources in the Stop() method. This includes closing files, network connections, and stopping goroutines.
Make agents configurable through constructor parameters or configuration objects rather than hardcoding values.

Next Steps

Shell Management

Learn about shell integration

UI Components

Explore UI component system