Build Intelligent AI Agent Workflows with Go
Quick Start โข Features โข Examples โข Documentation โข Contributing
GoLangGraph is a Go framework for building AI agent workflows using graph-based execution. Create intelligent agents that can reason, use tools, and execute complex workflows with the performance and reliability of Go.
๐ก Perfect for: Building AI applications, RAG systems, multi-agent workflows, and intelligent automation tools using local LLMs like Ollama.
GoLangGraphStudio -> we are working on a GUI based Studio component for this library GoLangGraphStudio
don't hesitate to contribute !
- ๐ Graph-Based Execution - Build workflows as directed graphs with nodes and edges
- ๐ง AI Agent Framework - Chat, ReAct, and Tool agents with different capabilities
- ๐ Multi-LLM Support - OpenAI, Ollama, and Gemini provider integrations
- ๐ง Built-in Tools - Calculator, web search, file operations, and more
- ๐พ State Management - Thread-safe state containers with persistence options
- ๐ Auto Server - Automatically generate REST APIs for your agents
- ๐ Monitoring & Observability - Grafana dashboards, Prometheus metrics, and comprehensive monitoring
- ๐ณ Production Ready - Docker support, comprehensive testing, and error handling
go get github.com/UnicoLab/GoLangGraph- Go 1.21+
- Ollama (optional, for local LLM testing)
package main
import (
"context"
"fmt"
"log"
"github.com/UnicoLab/GoLangGraph/pkg/agent"
"github.com/UnicoLab/GoLangGraph/pkg/llm"
"github.com/UnicoLab/GoLangGraph/pkg/tools"
)
func main() {
// Create LLM provider manager
llmManager := llm.NewProviderManager()
// Add Ollama provider (requires Ollama running locally)
provider, err := llm.NewOllamaProvider(&llm.ProviderConfig{
Endpoint: "http://localhost:11434",
Model: "gemma3:1b",
})
if err != nil {
log.Fatal(err)
}
llmManager.RegisterProvider("ollama", provider)
// Create tool registry
toolRegistry := tools.NewToolRegistry()
// Create chat agent
config := &agent.AgentConfig{
Name: "chat-agent",
Type: agent.AgentTypeChat,
Model: "gemma3:1b",
Provider: "ollama",
SystemPrompt: "You are a helpful AI assistant.",
Temperature: 0.7,
MaxTokens: 500,
}
chatAgent := agent.NewAgent(config, llmManager, toolRegistry)
// Execute
ctx := context.Background()
execution, err := chatAgent.Execute(ctx, "Hello! Tell me about Go programming.")
if err != nil {
log.Fatal(err)
}
fmt.Printf("๐ค Agent: %s\n", execution.Output)
}// Create ReAct agent with tools
config := &agent.AgentConfig{
Name: "react-agent",
Type: agent.AgentTypeReAct,
Model: "gemma3:1b",
Provider: "ollama",
Tools: []string{"calculator", "web_search"},
MaxIterations: 5,
SystemPrompt: "You are a helpful assistant that can use tools to solve problems.",
}
reactAgent := agent.NewAgent(config, llmManager, toolRegistry)
// Execute complex task
execution, err := reactAgent.Execute(ctx, "What is 25 * 34?")
if err != nil {
log.Fatal(err)
}
fmt.Printf("๐ง ReAct Agent: %s\n", execution.Output)// Create custom graph workflow
graph := core.NewGraph("my-workflow")
// Add processing node
graph.AddNode("process", "Process Input", func(ctx context.Context, state *core.BaseState) (*core.BaseState, error) {
input, _ := state.Get("user_input")
state.Set("processed_input", fmt.Sprintf("Processing: %s", input))
return state, nil
})
// Add response node
graph.AddNode("respond", "Generate Response", func(ctx context.Context, state *core.BaseState) (*core.BaseState, error) {
processed, _ := state.Get("processed_input")
state.Set("response", fmt.Sprintf("Response: %s", processed))
return state, nil
})
// Connect nodes
graph.AddEdge("process", "respond", nil)
graph.SetStartNode("process")
graph.AddEndNode("respond")
// Execute graph
initialState := core.NewBaseState()
initialState.Set("user_input", "Hello, world!")
result, err := graph.Execute(context.Background(), initialState)
if err != nil {
log.Fatal(err)
}
fmt.Printf("๐ Graph Result: %v\n", result.Get("response"))Defaults favour local development. Before exposing GoLangGraph to real traffic, read docs/PRODUCTION.md, which covers:
- Authentication and CORS โ
RequireAuthis off by default, and the allowed-origin list also governs WebSocket upgrades. - Tool sandboxing โ filesystem confinement, the shell allowlist, and SSRF protection for the HTTP tool.
- Durable execution โ checkpointing, resume after a crash, and human-in-the-loop interrupts.
- Health checking โ which probe belongs in a container, and which does not.
- Typed errors, retries, concurrency and observability.
LangGraph compatibility, including the places GoLangGraph intentionally differs, is documented in test/conformance/DEVIATIONS.md and enforced by the conformance suite:
go test -race ./test/conformance/...GoLangGraph follows a modular architecture:
๐ pkg/
โโโ ๐ง core/ # Graph execution engine and state management
โโโ ๐ค agent/ # AI agent implementations (Chat, ReAct, Tool)
โโโ ๐ llm/ # LLM provider integrations (OpenAI, Ollama, Gemini)
โโโ ๐ง tools/ # Built-in tools and tool registry
โโโ ๐พ persistence/ # Database integration and checkpointing
โโโ ๐ server/ # HTTP server and WebSocket support
โโโ ๐๏ธ builder/ # Quick builder patterns for rapid development
โโโ ๐ debug/ # Debugging and visualization tools
Simple conversational agent for basic interactions:
config := &agent.AgentConfig{
Type: agent.AgentTypeChat,
// ... other config
}Reasoning and Acting agent that can use tools:
config := &agent.AgentConfig{
Type: agent.AgentTypeReAct,
Tools: []string{"calculator", "web_search"},
MaxIterations: 5,
// ... other config
}Specialized agent focused on tool usage:
config := &agent.AgentConfig{
Type: agent.AgentTypeTool,
Tools: []string{"file_read", "file_write", "shell"},
// ... other config
}- ๐งฎ Calculator - Mathematical operations
- ๐ Web Search - Information retrieval
- ๐ File Operations - Read/write files
- ๐ HTTP Client - Web requests
- โฐ Time - Date and time operations
- ๐ฅ๏ธ Shell - Command execution
provider, err := llm.NewOpenAIProvider(&llm.ProviderConfig{
APIKey: "your-api-key",
Model: "gpt-4",
})provider, err := llm.NewOllamaProvider(&llm.ProviderConfig{
Endpoint: "http://localhost:11434",
Model: "gemma3:1b",
})provider, err := llm.NewGeminiProvider(&llm.ProviderConfig{
APIKey: "your-gemini-api-key",
Model: "gemini-pro",
})GoLangGraph can automatically generate REST APIs for your agents:
import "github.com/UnicoLab/GoLangGraph/pkg/server"
// Create auto server
config := server.DefaultAutoServerConfig()
config.Port = 8080
config.EnableWebUI = true
config.EnablePlayground = true
autoServer := server.NewAutoServer(config)
// Register your agents
autoServer.RegisterAgent("chat-agent", chatAgentDefinition)
autoServer.RegisterAgent("react-agent", reactAgentDefinition)
// Generate endpoints automatically
autoServer.GenerateEndpoints()
// Start server
ctx := context.Background()
autoServer.Start(ctx)This automatically creates:
- ๐ REST Endpoints:
/api/{agent-id}for each agent - ๐ฎ Web UI: Interactive chat interface at
/ - ๐ง API Playground: Test endpoints at
/playground - ๐ Metrics: System metrics at
/metrics - ๐ Health Checks: Status monitoring at
/health
Explore comprehensive examples in the /examples directory:
- 01-basic-chat - Simple chat agent
- 02-react-agent - ReAct agent with tools
- 03-multi-agent - Multi-agent coordination
- 04-rag-system - RAG implementation
- 05-streaming - Real-time streaming
- 06-persistence - Data persistence
- 07-tools-integration - Advanced tools
- 08-production-ready - Production deployment
- 09-workflow-graph - Complex workflows
- 10-ideation-agents - Creative agent collaboration with monitoring
# Prerequisites: Install Ollama and pull models
ollama serve
ollama pull gemma3:1b
# Run any example
cd examples/01-basic-chat
go run main.go- ๐น Go 1.21+ - Latest Go version
- ๐ฆ Ollama (optional) - For local LLM testing
- ๐ณ Docker (optional) - For containerized development
# Clone repository
git clone https://github.com/UnicoLab/GoLangGraph.git
cd GoLangGraph
# Install dependencies
make install
# Build the project
make build
# Run tests
make test
# Run examples
cd examples/01-basic-chat
go run main.go# Run all tests
make test
# Run tests with coverage
make test-coverage
# Run integration tests
make test-integration
# Code quality checks
make lint # Run linter
make fmt # Format code
make vet # Run go vet
make security # Security scan
# Complete quality check
make check # Run all checks# Build Docker images
make docker-build-agent
# Production deployment
make build-release
# Local development with Ollama
make ollama-setup
make test-local- โ Input Validation - All inputs are validated and sanitized
- ๐ก๏ธ SQL Injection Prevention - Parameterized queries throughout
- ๐ Secure Credential Handling - Environment variable management
- ๐ Audit Logging - Comprehensive execution logging
We welcome contributions! Please see our Contributing Guide for details.
- ๐ด Fork the repository
- ๐ฟ Create a feature branch
- โจ Make your changes and add tests
- ๐งช Run tests:
go test ./... - ๐พ Commit your changes
- ๐ Push and open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
| Resource | Link |
|---|---|
| ๐ Documentation | GoDoc |
| ๐ Issues | GitHub Issues |
| ๐ฌ Discussions | GitHub Discussions |
| ๐ฎ Discord | Join our Discord |
- ๐ Inspired by LangGraph and similar workflow engines
- ๐น Built with the excellent Go ecosystem
- ๐ฅ Special thanks to all contributors