Documentation
ΒΆ
Overview ΒΆ
Package agentmesh provides a production-grade multi-agent orchestration framework using Pregel-style bulk-synchronous parallel (BSP) graph processing.
Architecture ΒΆ
AgentMesh is built on three main layers:
- Execution Engine (pkg/pregel) - Public BSP runtime API for parallel computation and custom extensions
- Graph Orchestration (pkg/graph) - Workflow construction, state management, and scheduling
- Agent Layer (pkg/agent, pkg/model, pkg/tool) - High-level APIs for building LLM-powered agents
Quick Start ΒΆ
Build a simple ReAct agent:
import (
"github.com/hupe1980/agentmesh/pkg/agent"
"github.com/hupe1980/agentmesh/pkg/model/openai"
"github.com/hupe1980/agentmesh/pkg/tool"
"github.com/hupe1980/agentmesh/pkg/message"
)
type WeatherArgs struct {
Location string `json:"location"`
}
// Create tools
weatherTool, _ := tool.NewFuncTool("get_weather",
"Get current weather for a location",
func(ctx context.Context, args WeatherArgs) (map[string]any, error) {
return map[string]any{
"location": args.Location,
"temperature": 22,
"conditions": "Sunny",
}, nil
},
)
// Build the agent
compiled, _ := agent.NewReAct(
openai.NewModel(),
[]tool.Tool{weatherTool},
)
// Execute
messages := []message.Message{
message.NewSystemMessageFromText("You are a helpful assistant."),
message.NewHumanMessageFromText("What's the weather in Paris?"),
}
result, _ := graph.Last(compiled.Run(ctx, messages))
Core Packages ΒΆ
For graph construction:
import "github.com/hupe1980/agentmesh/pkg/graph"
For agent building:
import "github.com/hupe1980/agentmesh/pkg/agent"
For LLM models:
import "github.com/hupe1980/agentmesh/pkg/model/openai" import "github.com/hupe1980/agentmesh/pkg/model/anthropic"
For tools:
import "github.com/hupe1980/agentmesh/pkg/tool"
For observability:
import "github.com/hupe1980/agentmesh/pkg/metrics" import "github.com/hupe1980/agentmesh/pkg/trace" import "github.com/hupe1980/agentmesh/pkg/logging"
Features ΒΆ
- Parallel graph execution with Pregel-style BSP model (~430ns overhead per node)
- Channel-based state management (Topic, LastValue, BinaryOp channels)
- Automatic checkpointing and state persistence
- Time-travel debugging by replaying from any superstep
- Retry policies with configurable exponential backoff
- Subgraph composition for modular workflows
- OpenTelemetry metrics and distributed tracing
- Human-in-the-loop pause/resume capabilities
- Conditional routing based on node outputs
- Message retention limits for conversation management
- ReAct and RAG agent patterns
Examples ΒΆ
See the examples/ directory for comprehensive examples:
- examples/basic_agent/ - Simple ReAct agent with tools
- examples/streaming/ - Real-time execution result streaming
- examples/conditional_flow/ - Dynamic routing
- examples/parallel_tasks/ - Parallel node execution
- examples/checkpointing/ - State persistence and recovery
- examples/time_travel/ - Debug with superstep replay
- examples/observability/ - OpenTelemetry integration
- examples/human_pause/ - Human-in-the-loop workflows
- examples/subgraph/ - Reusable graph components
- examples/message_retention/ - Conversation history management
Production Features ΒΆ
MaxIterations:
compiled, _ := g.Build(
graph.WithMaxIterations(100),
)
Checkpointing:
store := checkpoint.NewMemory()
compiled, _ := g.Build(
graph.WithCheckpointer(store),
graph.WithCheckpointInterval(1),
)
result, _ := graph.Last(compiled.Run(ctx, messages,
graph.WithRunID(threadID),
))
Retry Policies:
g.Node("api_call", apiCallFunc, "next").
WithRetryPolicy(&graph.RetryPolicy{
MaxAttempts: 3,
InitialBackoff: 100 * time.Millisecond,
MaxBackoff: 1 * time.Second,
Multiplier: 2.0,
})
Observability:
inst := graph.NewInstrumentation(metricsProvider, traceProvider) ctx, span := inst.TraceNodeExecution(ctx, nodeName, superstep) inst.RecordNodeExecution(ctx, nodeName, duration, err)
Documentation ΒΆ
For detailed documentation, see:
- README.md - Project overview and quick start
- docs/getting-started.md - Comprehensive tutorial
- docs/architecture.md - Pregel BSP design deep-dive
- docs/agents.md - ReAct and RAG agent patterns
- docs/tools.md - Building and using tools
- docs/models.md - LLM provider integration
- docs/observability.md - Metrics and tracing setup
API Documentation ΒΆ
Complete API reference: https://pkg.go.dev/github.com/hupe1980/agentmesh
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
examples
|
|
|
a2a_integration/client
command
|
|
|
a2a_integration/server
command
|
|
|
a2a_integration/tool_usage
command
|
|
|
basic_agent
command
|
|
|
basic_rag
command
|
|
|
blogwriter
command
|
|
|
builder_api
command
This is a port of the builder_api example showing the simplified API.
|
This is a port of the builder_api example showing the simplified API. |
|
checkpoint_encryption
command
Package main demonstrates checkpoint encryption for secure state storage.
|
Package main demonstrates checkpoint encryption for secure state storage. |
|
checkpoint_signing
command
Package main demonstrates checkpoint signing for tamper detection.
|
Package main demonstrates checkpoint signing for tamper detection. |
|
checkpointing
command
Package main demonstrates checkpointing for fault tolerance and resume.
|
Package main demonstrates checkpointing for fault tolerance and resume. |
|
circuit_breaker
command
|
|
|
conditional_flow
command
|
|
|
conversational_agent
command
Package main demonstrates the Conversational agent pattern.
|
Package main demonstrates the Conversational agent pattern. |
|
custom_observability
command
Package main demonstrates custom observability with metrics collection.
|
Package main demonstrates custom observability with metrics collection. |
|
custom_scheduler
command
Package main demonstrates custom scheduler usage in AgentMesh.
|
Package main demonstrates custom scheduler usage in AgentMesh. |
|
docker_tool
command
|
|
|
document_loader
command
|
|
|
graph_introspection
command
Package main demonstrates graph introspection capabilities.
|
Package main demonstrates graph introspection capabilities. |
|
graph_validation
command
|
|
|
human_approval
command
Package main demonstrates human-in-the-loop approval workflow.
|
Package main demonstrates human-in-the-loop approval workflow. |
|
human_pause
command
Package main demonstrates pausing workflow for human input.
|
Package main demonstrates pausing workflow for human input. |
|
langchaingo
command
|
|
|
managed_values
command
Package main demonstrates managed values in AgentMesh.
|
Package main demonstrates managed values in AgentMesh. |
|
mcp_tools
command
Package main demonstrates using MCP (Model Context Protocol) tools with AgentMesh.
|
Package main demonstrates using MCP (Model Context Protocol) tools with AgentMesh. |
|
mermaid_flowchart
command
Package main demonstrates generating Mermaid flowcharts from graphs.
|
Package main demonstrates generating Mermaid flowcharts from graphs. |
|
message_retention
command
Package main demonstrates message retention and history management.
|
Package main demonstrates message retention and history management. |
|
middleware
command
|
|
|
model_router
command
|
|
|
namespaces
command
Package main demonstrates namespace-based state isolation.
|
Package main demonstrates namespace-based state isolation. |
|
observability
command
Package main demonstrates observability with the event bus.
|
Package main demonstrates observability with the event bus. |
|
parallel_tasks
command
|
|
|
reflection_agent
command
|
|
|
retry_policy
command
Package main demonstrates retry policies for resilient node execution.
|
Package main demonstrates retry policies for resilient node execution. |
|
semantic_caching
command
|
|
|
streaming
command
Package main demonstrates real-time streaming execution in AgentMesh.
|
Package main demonstrates real-time streaming execution in AgentMesh. |
|
structured_output
command
|
|
|
subgraph
command
Package main demonstrates subgraph composition using graph.Subgraph().
|
Package main demonstrates subgraph composition using graph.Subgraph(). |
|
supervisor_agent
command
|
|
|
time_travel
command
Package main demonstrates time-travel debugging with checkpoints.
|
Package main demonstrates time-travel debugging with checkpoints. |
|
vectorstore
command
|
|
|
viz_ui_demo
command
|
|
|
wasm_tool
command
|
|
|
internal
|
|
|
chanutil
Package chanutil provides utility functions for working with Go channels.
|
Package chanutil provides utility functions for working with Go channels. |
|
floatconv
Package floatconv provides utilities for converting between float32 and float64 slices.
|
Package floatconv provides utilities for converting between float32 and float64 slices. |
|
jsonschema
Package jsonschema provides automatic JSON Schema generation from Go types.
|
Package jsonschema provides automatic JSON Schema generation from Go types. |
|
safeconv
Package safeconv provides safe integer conversions that handle overflow.
|
Package safeconv provides safe integer conversions that handle overflow. |
|
safego
Package safego provides utilities for safe goroutine execution with panic recovery.
|
Package safego provides utilities for safe goroutine execution with panic recovery. |
|
validate
Package validate provides reusable validation helpers to standardize error messages and reduce code duplication across the agentmesh codebase.
|
Package validate provides reusable validation helpers to standardize error messages and reduce code duplication across the agentmesh codebase. |
|
pkg
|
|
|
a2a
Package a2a provides A2A (Agent-to-Agent) Protocol integration for AgentMesh.
|
Package a2a provides A2A (Agent-to-Agent) Protocol integration for AgentMesh. |
|
agent
Package agent provides a high-level API for building LLM-powered agents with tool-calling capabilities, built on top of the graph execution engine.
|
Package agent provides a high-level API for building LLM-powered agents with tool-calling capabilities, built on top of the graph execution engine. |
|
cache
Package cache provides semantic caching capabilities for model requests and responses.
|
Package cache provides semantic caching capabilities for model requests and responses. |
|
cache/redis
Package redis provides a distributed semantic cache using Redis with vector search.
|
Package redis provides a distributed semantic cache using Redis with vector search. |
|
checkpoint
Package checkpoint provides interfaces and implementations for persisting graph execution state.
|
Package checkpoint provides interfaces and implementations for persisting graph execution state. |
|
checkpoint/awskms
Package awskms provides AWS KMS encryption support for checkpoints.
|
Package awskms provides AWS KMS encryption support for checkpoints. |
|
checkpoint/dynamodb
Package dynamodb provides DynamoDB-based checkpoint persistence using AWS SDK for Go v2.
|
Package dynamodb provides DynamoDB-based checkpoint persistence using AWS SDK for Go v2. |
|
checkpoint/sql
Package sql provides SQL-based checkpoint persistence using database/sql.
|
Package sql provides SQL-based checkpoint persistence using database/sql. |
|
checkpoint/vault
Package vault provides HashiCorp Vault transit encryption support for checkpoints.
|
Package vault provides HashiCorp Vault transit encryption support for checkpoints. |
|
embedding
Package embedding provides interfaces and implementations for converting text into vector embeddings.
|
Package embedding provides interfaces and implementations for converting text into vector embeddings. |
|
embedding/openai
Package openai provides OpenAI embedding functionality for the agentmesh framework.
|
Package openai provides OpenAI embedding functionality for the agentmesh framework. |
|
event
Package event provides a unified event system for publishing and subscribing to execution events across all components (graph, model, tool, node).
|
Package event provides a unified event system for publishing and subscribing to execution events across all components (graph, model, tool, node). |
|
graph
Package graph provides structured errors for the graph package.
|
Package graph provides structured errors for the graph package. |
|
graph/middleware
Package middleware provides reusable middleware for graph node execution.
|
Package middleware provides reusable middleware for graph node execution. |
|
loader
Package loader provides document loading and text splitting utilities for ingesting content into vector stores.
|
Package loader provides document loading and text splitting utilities for ingesting content into vector stores. |
|
logging
Package logging provides a minimal logging interface and adapters for AgentMesh.
|
Package logging provides a minimal logging interface and adapters for AgentMesh. |
|
memory
Package memory provides long-term memory storage for multi-session conversations.
|
Package memory provides long-term memory storage for multi-session conversations. |
|
message
Package message provides types for representing multi-modal conversational messages between humans, AI assistants, tools, and systems.
|
Package message provides types for representing multi-modal conversational messages between humans, AI assistants, tools, and systems. |
|
metrics
Package metrics provides OpenTelemetry metrics collection for graph execution and agent performance.
|
Package metrics provides OpenTelemetry metrics collection for graph execution and agent performance. |
|
metrics/opentelemetry
Package opentelemetry provides an OpenTelemetry-backed implementation of the agentmesh metrics.Provider interface.
|
Package opentelemetry provides an OpenTelemetry-backed implementation of the agentmesh metrics.Provider interface. |
|
model
Package model provides interfaces and adapters for integrating Large Language Models (LLMs) into agent workflows.
|
Package model provides interfaces and adapters for integrating Large Language Models (LLMs) into agent workflows. |
|
model/amazonbedrock
Package amazonbedrock provides a model adapter for Amazon Bedrock foundation models.
|
Package amazonbedrock provides a model adapter for Amazon Bedrock foundation models. |
|
model/anthropic
Package anthropic provides integration with the Anthropic AI API for large language models.
|
Package anthropic provides integration with the Anthropic AI API for large language models. |
|
model/gemini
Package gemini provides Google Gemini model integration for the agentmesh framework.
|
Package gemini provides Google Gemini model integration for the agentmesh framework. |
|
model/langchaingo
Package langchaingo provides an adapter for using LangChainGo (github.com/tmc/langchaingo) models within AgentMesh workflows.
|
Package langchaingo provides an adapter for using LangChainGo (github.com/tmc/langchaingo) models within AgentMesh workflows. |
|
model/middleware
Package middleware provides reusable middleware for model executors.
|
Package middleware provides reusable middleware for model executors. |
|
model/ollama
Package ollama provides sentinel errors for the Ollama model package.
|
Package ollama provides sentinel errors for the Ollama model package. |
|
model/openai
Package openai provides integration with the OpenAI API for large language models.
|
Package openai provides integration with the OpenAI API for large language models. |
|
pregel
Package pregel provides a generic Bulk Synchronous Parallel (BSP) computation engine implementing Google's Pregel model for distributed graph processing.
|
Package pregel provides a generic Bulk Synchronous Parallel (BSP) computation engine implementing Google's Pregel model for distributed graph processing. |
|
pregel/redis
Package redis provides a Redis-backed implementation of pregel.MessageBus for distributed graph execution.
|
Package redis provides a Redis-backed implementation of pregel.MessageBus for distributed graph execution. |
|
prompt
Package prompt provides a simple template system for LLM prompts with variable substitution.
|
Package prompt provides a simple template system for LLM prompts with variable substitution. |
|
quota
Package quota provides structured errors for quota violations.
|
Package quota provides structured errors for quota violations. |
|
retrieval
Package retrieval provides functionality for document retrieval and result merging in RAG workflows.
|
Package retrieval provides functionality for document retrieval and result merging in RAG workflows. |
|
retrieval/amazonbedrock
Package amazonbedrock provides retrievers powered by Amazon Bedrock agents.
|
Package amazonbedrock provides retrievers powered by Amazon Bedrock agents. |
|
retrieval/amazonkendra
Package amazonkendra provides retrievers backed by Amazon Kendra indexes.
|
Package amazonkendra provides retrievers backed by Amazon Kendra indexes. |
|
retrieval/langchaingo
Package langchaingo integrates retrievers backed by the LangChain Go SDK.
|
Package langchaingo integrates retrievers backed by the LangChain Go SDK. |
|
schema
Package schema provides utilities for creating and working with JSON schemas for structured output in AgentMesh.
|
Package schema provides utilities for creating and working with JSON schemas for structured output in AgentMesh. |
|
testutil
Package testutil provides testing utilities for the agentmesh framework.
|
Package testutil provides testing utilities for the agentmesh framework. |
|
tool
Package tool provides abstractions for defining and executing tools that agents can use to perform actions and retrieve information.
|
Package tool provides abstractions for defining and executing tools that agents can use to perform actions and retrieve information. |
|
tool/a2a
Package a2a provides tools for integrating external A2A agents into AgentMesh workflows.
|
Package a2a provides tools for integrating external A2A agents into AgentMesh workflows. |
|
tool/docker
Package docker provides Docker-based tool sandboxing for secure execution of containerized commands with resource limits and network isolation.
|
Package docker provides Docker-based tool sandboxing for secure execution of containerized commands with resource limits and network isolation. |
|
tool/langchaingo
Package langchaingo provides adapters for using langchaingo tools (github.com/tmc/langchaingo/tools) within AgentMesh workflows.
|
Package langchaingo provides adapters for using langchaingo tools (github.com/tmc/langchaingo/tools) within AgentMesh workflows. |
|
tool/mcp
Package mcp provides integration with the Model Context Protocol (MCP).
|
Package mcp provides integration with the Model Context Protocol (MCP). |
|
tool/middleware
Package middleware provides reusable middleware for tool executors.
|
Package middleware provides reusable middleware for tool executors. |
|
tool/wasm
Package wasm provides WebAssembly-based tool sandboxing for secure execution of untrusted code with memory isolation and resource limits.
|
Package wasm provides WebAssembly-based tool sandboxing for secure execution of untrusted code with memory isolation and resource limits. |
|
trace
Package trace provides OpenTelemetry distributed tracing for graph execution flows.
|
Package trace provides OpenTelemetry distributed tracing for graph execution flows. |
|
trace/opentelemetry
Package opentelemetry provides an OpenTelemetry-backed implementation of the agentmesh trace.Provider interface.
|
Package opentelemetry provides an OpenTelemetry-backed implementation of the agentmesh trace.Provider interface. |
|
vectorstore
Package vectorstore provides interfaces and implementations for vector storage backends.
|
Package vectorstore provides interfaces and implementations for vector storage backends. |
|
vectorstore/memory
Package memory provides an in-memory VectorStore implementation.
|
Package memory provides an in-memory VectorStore implementation. |
|
vectorstore/pgvector
Package pgvector provides a PostgreSQL pgvector-backed VectorStore implementation.
|
Package pgvector provides a PostgreSQL pgvector-backed VectorStore implementation. |
|
vectorstore/pinecone
Package pinecone provides a Pinecone-backed VectorStore implementation.
|
Package pinecone provides a Pinecone-backed VectorStore implementation. |
|
vectorstore/qdrant
Package qdrant provides a Qdrant-backed VectorStore implementation.
|
Package qdrant provides a Qdrant-backed VectorStore implementation. |
|
vectorstore/s3vectors
Package s3vectors provides an Amazon S3 Vectors-backed VectorStore implementation.
|
Package s3vectors provides an Amazon S3 Vectors-backed VectorStore implementation. |
|
vectorstore/weaviate
Package weaviate provides a Weaviate-backed VectorStore implementation.
|
Package weaviate provides a Weaviate-backed VectorStore implementation. |
|
viz
Package viz provides real-time visualization and debugging for AgentMesh graphs and agents.
|
Package viz provides real-time visualization and debugging for AgentMesh graphs and agents. |
|
viz/middleware
Package middleware provides visualization middleware for graph execution.
|
Package middleware provides visualization middleware for graph execution. |
Click to show internal directories.
Click to hide internal directories.