Creating Custom Agents
This guide walks you through creating custom agents in Solace Agent Mesh. You’ll learn how to define agent configurations, set up tools, configure behaviors, and enable agent-to-agent communication.Understanding Agents
Agents in Solace Agent Mesh are specialized AI components that:- Have specific instructions and personas
- Use LLM models for reasoning and decision-making
- Have access to specific tools and capabilities
- Can communicate with other agents via the A2A protocol
- Maintain session state and manage artifacts
Creating Your First Agent
log:
stdout_log_level: INFO
log_file_level: DEBUG
log_file: my_agent.log
# Include shared configuration for broker and models
!include shared_config.yaml
apps:
- name: my_agent_app
app_base_path: .
app_module: solace_agent_mesh.agent.sac.app
broker:
<<: *broker_connection
app_config:
namespace: ${NAMESPACE}
supports_streaming: true
agent_name: "MyCustomAgent"
display_name: "My Custom Agent"
model: *planning_model
instruction: |
You are a helpful assistant specialized in [your domain].
Your primary responsibilities are:
- [Responsibility 1]
- [Responsibility 2]
- [Responsibility 3]
Always provide clear, actionable responses.
Add tools that your agent can use. Agents can access built-in tools, custom Python functions, or MCP servers:
tools:
# Built-in tool groups
- tool_type: builtin-group
group_name: "artifact_management"
- tool_type: builtin-group
group_name: "data_analysis"
# Individual built-in tools
- tool_type: builtin
tool_name: "time_delay"
# Custom Python tools
- tool_type: python
component_module: "my_package.tools"
function_name: "my_custom_function"
See Creating Custom Tools for details on building your own tools.
session_service:
type: "memory" # or "persistent" for database-backed sessions
default_behavior: "PERSISTENT" # or "RUN_BASED" for stateless
artifact_service:
type: "filesystem" # or "s3" for cloud storage
base_path: "/tmp/samv2"
artifact_scope: "namespace" # Share artifacts across the namespace
artifact_handling_mode: "reference" # Show metadata, not full content
enable_embed_resolution: true
enable_artifact_content_instruction: true
agent_card:
description: |
This agent specializes in [domain]. It can [capability 1],
[capability 2], and [capability 3].
defaultInputModes: ["text"]
defaultOutputModes: ["text", "file"]
skills:
- id: "skill_1"
name: "Skill Name"
description: "What this skill does"
examples:
- "Example task 1"
- "Example task 2"
tags: ["category1", "category2"]
- id: "skill_2"
name: "Another Skill"
description: "What this other skill does"
examples:
- "Example task 3"
tags: ["category3"]
Be specific in your skill descriptions and examples. This helps other agents understand when to delegate tasks to your agent.
# Publish agent card for discovery
agent_card_publishing:
interval_seconds: 10
# Enable discovery by other agents
agent_discovery:
enabled: true
# Configure inter-agent communication
inter_agent_communication:
allow_list: ["*"] # Allow all agents, or specify: ["AgentA", "AgentB"]
request_timeout_seconds: 120
Complete Example: Data Processing Agent
Here’s a complete example of a specialized data processing agent:data_processor_agent.yaml
Advanced Agent Features
Input and Output Schemas
Define schemas to validate agent inputs and outputs:Agent Initialization and Cleanup
Run custom code when your agent starts or stops:Tool Output Configuration
Control how tool outputs are handled:Running Your Agent
Start your agent using the SAM CLI:- Connect to the Solace broker
- Initialize services and tools
- Publish its agent card for discovery
- Begin listening for tasks
Testing Your Agent
# Start the Web UI gateway in another terminal
sam run configs/gateways/webui.yaml
# Visit http://localhost:8000 and interact with your agent
Troubleshooting
Debug Logging
Increase log verbosity to troubleshoot:Health Checks
Monitor agent health:Best Practices
Next Steps
- Creating Custom Tools - Add specialized tools to your agents
- MCP Integration - Integrate Model Context Protocol servers
- Workflow Development - Orchestrate multiple agents
- Building Gateways - Create custom interfaces for your agents
Real-World Examples
Check out these production-ready agent examples in the source:examples/agents/web_search_agent.yaml- Web search and research capabilitiesexamples/agents/research_agent.yaml- Deep research workflowsexamples/agents/orchestrator_example.yaml- Multi-agent orchestration