Go SDK
The Go SDK is the primary client for building agents on the Athyr platform. It provides production-ready features including orchestration patterns, middleware, and resilience out of the box.
Installation
go get github.com/athyr-tech/athyr-sdk-go
Requires Go 1.21+ and a running Athyr server.
Quick Start
package main
import (
"context"
"github.com/athyr-tech/athyr-sdk-go/pkg/athyr"
)
func main() {
agent := athyr.MustConnect("localhost:9090",
athyr.WithAgentCard(athyr.AgentCard{
Name: "my-agent",
Description: "My first Athyr agent",
}),
)
defer agent.Close()
resp, _ := agent.Complete(context.Background(), athyr.CompletionRequest{
Model: "llama3",
Messages: []athyr.Message{{Role: "user", Content: "Hello!"}},
})
println(resp.Content)
}
Features
Core Agent
- Connect/Disconnect — Lifecycle management with automatic reconnection
- Pub/Sub Messaging — Subscribe to subjects, publish messages, request/reply
- LLM Completions — Blocking and streaming completions via Athyr backends
- Memory Sessions — Conversation context with automatic summarization
- KV Storage — Key-value buckets for agent state
- Tool Calling — LLM function calling support
Orchestration Patterns
Located in pkg/orchestration/:
| Pattern | Description |
|---|---|
| Pipeline | Sequential agent chain (A → B → C) |
| FanOut | Parallel execution with aggregation |
| Handoff | Dynamic routing via triage agent |
| GroupChat | Multi-agent collaborative discussion |
Middleware
Recover— Panic recoveryTimeout— Request timeoutsRetry— Automatic retries with backoffRateLimit— Concurrency limitingMetrics— Duration/error callbacksValidate— Input validationLogRequests— Request/response logging
Server Pattern
For building agent services that handle requests:
server := athyr.NewServer("localhost:9090",
athyr.WithAgentName("my-service"),
)
athyr.Handle(server, "echo.request", func(ctx athyr.Context, req EchoRequest) (EchoResponse, error) {
return EchoResponse{Echo: req.Message}, nil
})
server.Run(context.Background())
Documentation
Full documentation and examples are maintained in the SDK repository:
- SDK README — Complete feature guide
- API Reference — GoDoc
- Examples — Working code samples
Available Examples
| Example | Demonstrates |
|---|---|
| quickstart | Basic agent setup |
| pipeline | Sequential orchestration |
| fanout | Parallel execution |
| group-chat | Multi-agent collaboration |
| handoff-router | Dynamic routing via triage |
| resilience | Error handling and retries |
| tool-calling | LLM function calling |
Next Steps
- Agents — Agent concepts and lifecycle
- LLM Gateway — LLM provider configuration
- State Management — Memory and KV details