需自行准备 OpenAI、DeepSeek 等 LLM 提供商的 API key,否则示例无法运行;取消运行必须 cancel 传入 Runner.Run 的 context 并继续排空事件 channel,直接跳出事件循环可能导致 goroutine 阻塞;启用 Skills 与代码执行器时建议关闭代码块自动执行响应处理器,避免助手文本中的代码块被误执行

trpc-agent-go
trpc-groupApache-2.0活跃维护用 Go 构建生产级智能体系统的框架,提供图工作流编排、工具调用、记忆、A2A 与 MCP 协议接入、评测和可观测性,省去从零搭基础设施。
A Go framework for building production agent systems with graph workflows, tools, memory, A2A, AG-UI, MCP, evaluation, and observability.
git clone https://github.com/trpc-group/trpc-agent-go.git
cd trpc-agent-go
export OPENAI_API_KEY="your-api-key-here"
cd examples/runner
go run . -model="gpt-4o-mini" -streaming=trueREADME 未说明,仅要求 Go 1.21 或更高版本及 LLM 提供商 API key
用 Go 原生方式构建可观测、可部署的生产级 Agent 系统框架
用 Go 构建生产级智能体系统的框架,提供图工作流编排、工具调用、记忆、A2A 与 MCP 协议接入、评测和可观测性,省去从零搭基础设施。
核心能力
- 提供 GraphAgent 类型安全图工作流与多条件路由
- 支持链式、并行、循环多 Agent 协作编排
- 内置会话、记忆、工件与知识检索持久化状态
- 集成 MCP 工具、A2A 互通与 AG-UI 前端协议
- 内置 OpenTelemetry 追踪指标与评估基准
容易踩的坑
- model/openai/sdkv3/v1.13.0-beta.1pre-release2026-11-06 · 2026-11-06 10:27 UTC
查看更新说明
First Beta release of
trpc.group/trpc-go/trpc-agent-go/model/openai/sdkv3, providing the OpenAI Responses adapter introduced in #2687.Supports client-managed native history, streaming, local function tools, image/file inputs, and JSON Schema output. Requires Go 1.25 and automatically selects root module
v1.13.0-beta.1.go get trpc.group/trpc-go/trpc-agent-go/model/openai/[email protected]What's Changed
- lsc: update submodule root dependency to v1.12.0 by @liuzengh in https://github.com/trpc-group/trpc-agent-go/pull/2722
- codeexecutor/e2b: separate request and execution timeouts by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2723
- session/mysql: support trimming recent conversations by @liuzengh in https://github.com/trpc-group/trpc-agent-go/pull/2614
- model/openai/sdkv3/responses: add responses api support by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2687
- model/openai/sdkv3: require root v1.13.0-beta.1 by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2728
Full Changelog: https://github.com/trpc-group/trpc-agent-go/compare/v1.12.0...model/openai/sdkv3/v1.13.0-beta.1
- v1.13.0-beta.1pre-release2026-11-06 · 2026-11-06 10:00 UTC
查看更新说明
This prerelease includes the ProviderData APIs used by the OpenAI Responses adapter added in #2687.
The Responses adapter is distributed in the separate
trpc.group/trpc-go/trpc-agent-go/model/openai/sdkv3module and requires Go 1.25. The root module requires Go 1.21.model.Messageandmodel.Infohave new fields. Applications using positional composite literals for these structs must switch to keyed fields.The SDK module prerelease follows the root dependency update and external-consumer validation.
What's Changed
- lsc: update submodule root dependency to v1.12.0 by @liuzengh in https://github.com/trpc-group/trpc-agent-go/pull/2722
- codeexecutor/e2b: separate request and execution timeouts by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2723
- session/mysql: support trimming recent conversations by @liuzengh in https://github.com/trpc-group/trpc-agent-go/pull/2614
- model/openai/sdkv3/responses: add responses api support by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2687
Full Changelog: https://github.com/trpc-group/trpc-agent-go/compare/v1.12.0...v1.13.0-beta.1
- v1.12.0最新正式版2026-11-04 · 2026-11-04 06:49 UTC
What's Changed
- {codeexecutor, internal/workspaceprep, tool/workspaceexec}: scope prepared state per generation by @liuzengh in https://github.com/trpc-group/trpc-agent-go/pull/2423
- knowledge/chunking: preserve whitespace-sensitive content by @hr-chang in https://github.com/trpc-group/trpc-agent-go/pull/2434
- tool/function: allow disabling automatic output schema by @hyprh in https://github.com/trpc-group/trpc-agent-go/pull/2435
- telemetry: report gen_ai.usage.total_tokens on chat spans by @liuzengh in https://github.com/trpc-group/trpc-agent-go/pull/2438
- {agent/a2aagent, session, docs}: coordinate anonymous identity initialization across instances by @XnLemon in https://github.com/trpc-group/trpc-agent-go/pull/2406
- examples/knowledge: add contextual retrieval example by @hr-chang in https://github.com/trpc-group/trpc-agent-go/pull/2439
- test: make QueueModel consume one call per invocation by @yu-xin-c in https://github.com/trpc-group/trpc-agent-go/pull/2445
- {runner, session/summary}: make automatic summaries cancellation-safe by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2436
- docs: clarify caller-executed tool options by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2449
- plugin/toolerror: add structured tool failure handling by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2433
- lsc: add step tool and skill records for evaluation trace by @Flash-LHR in https://github.com/trpc-group/trpc-agent-go/pull/2451
- {agent/codex, agent/claudecode, docs}: add CLI message builders by @Flash-LHR in https://github.com/trpc-group/trpc-agent-go/pull/2454
- session/summary: discard canceled summary results by @yu-xin-c in https://github.com/trpc-group/trpc-agent-go/pull/2455
- dynamicworkflow: add agent model profiles by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2450
- tool/agent: preserve user history for persistent streaming calls by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2452
- feat(sandbox): add macOS denial diagnostics by @cuboya in https://github.com/trpc-group/trpc-agent-go/pull/2422
- {docs, memory/extractor, memory/internal}: add opt-in update policies for auto memory by @print-happy in https://github.com/trpc-group/trpc-agent-go/pull/2233
- internal/flow/llmflow: avoid state clones in streaming telemetry by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2462
- runner: deduplicate event persistence by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2460
- knowledge: align root module versions by @print-happy in https://github.com/trpc-group/trpc-agent-go/pull/2469
- {docs, memory/extractor}: add opt-in assistant episode extraction by @print-happy in https://github.com/trpc-group/trpc-agent-go/pull/2302
- docs: split evaluation guides by @Flash-LHR in https://github.com/trpc-group/trpc-agent-go/pull/2467
- tool/agent: support dynamic model profiles by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2465
- {knowledge, knowledge/embedder, knowledge/embedder/openai}: add opt-in batched embedding ingestion by @hr-chang in https://github.com/trpc-group/trpc-agent-go/pull/2459
- docs: split memory guides by backend by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2471
- {internal/state/summaryfork, internal/state/summaryview}: avoid cloning immutable invocation snapshots by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2476
- agent: add execution trace step node type setter by @Flash-LHR in https://github.com/trpc-group/trpc-agent-go/pull/2478
- model/openai: use max_tokens for DeepSeek by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2480
- lsc: govern Agent Loop performance benchmarks by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2479
- {docs, examples/evaluation/trpcagent}: add remote agent evaluation example by @Flash-LHR in https://github.com/trpc-group/trpc-agent-go/pull/2481
- v1.11.2Release v1.11.22026-08-20 · 2026-08-20 04:54 UTC
查看更新说明
What's Changed
- runner: deduplicate event persistence by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2460
- knowledge: align root module versions by @print-happy in https://github.com/trpc-group/trpc-agent-go/pull/2469
- {internal/state/summaryfork, internal/state/summaryview}: avoid cloning immutable invocation snapshots by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2476
- model/openai: use max_tokens for DeepSeek by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2480
- session/mysql: support legacy summary indexes by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2474
- internal/flow/llmflow: preserve compaction lineage through request transforms by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2485
- internal/skillstage: tolerate chmod denial when restaging skills by @liuzengh in https://github.com/trpc-group/trpc-agent-go/pull/2486
- telemetry/langfuse: restore legacy fallback for empty Input/Output by @liuzengh in https://github.com/trpc-group/trpc-agent-go/pull/2477
Full Changelog: https://github.com/trpc-group/trpc-agent-go/compare/v1.11.1...v1.11.2
- v1.11.1Release v1.11.12026-08-13 · 2026-08-13 02:33 UTC
查看更新说明
What's Changed
- {runner, session/summary}: make automatic summaries cancellation-safe by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2436
- session/summary: discard canceled summary results by @yu-xin-c in https://github.com/trpc-group/trpc-agent-go/pull/2455
- tool/agent: preserve user history for persistent streaming calls by @bytethm in https://github.com/trpc-group/trpc-agent-go/pull/2452
- internal/flow/llmflow: avoid state clones in streaming telemetry by @Rememorio in https://github.com/trpc-group/trpc-agent-go/pull/2462
Full Changelog: https://github.com/trpc-group/trpc-agent-go/compare/v1.11.0...v1.11.1
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
tRPC-Agent-Go is a Go framework for building production agent systems. It provides LLM agents, graph workflows, tool calling, session and memory state, knowledge retrieval, agent self-evolution, evaluation, and OpenTelemetry observability in one Go-native stack.
Use it when you want agent applications that fit Go services: concurrent, observable, easy to deploy, and ready to integrate with A2A, AG-UI, and MCP.
Why tRPC-Agent-Go?
- Go-Native Agent Runtime: Streaming runners, context cancellation, and service-friendly APIs
- GraphAgent: Type-safe graph workflows with multi-conditional routing, functionally equivalent to LangGraph for Go
- Multi-Agent Collaboration: Chain, parallel, and cycle-based workflows
- Rich Tool Ecosystem: Function tools, MCP tools, web search, code execution, and custom services
- Persistent State: Session, memory, artifacts, and knowledge retrieval
- Agent Skills: Reusable
SKILL.mdworkflows with safe execution - Agent Self-Evolution: Hermes-style session reviews that extract, gate,
and publish reusable
SKILL.mdworkflows - Prompt Caching: Automatic cost optimization with 90% savings on cached content
- Evaluation & Benchmarks: Eval sets + metrics to measure quality over time
- Protocol Integration: AG-UI for frontends, A2A for agent interoperability, and MCP for tools
- Production Observability: OpenTelemetry tracing, metrics, and Langfuse examples
Use Cases
Perfect for building:
- Customer Support Bots - Intelligent agents that understand context and solve complex queries
- Data Analysis Assistants - Agents that query databases, generate reports, and provide insights
- DevOps Automation - Smart deployment, monitoring, and incident response systems
- Business Process Automation - Multi-step workflows with human-in-the-loop capabilities
- Research & Knowledge Management - RAG-powered agents for document analysis and Q&A
Key Features
Multi-Agent Orchestration
// Chain agents for complex workflows
pipeline := chainagent.New("pipeline",
chainagent.WithSubAgents([]agent.Agent{
analyzer, processor, reporter,
}))
// Or run them in parallel
parallel := parallelagent.New("concurrent",
parallelagent.WithSubAgents(tasks))
Advanced Memory System
// Persistent memory with search
memory := memorysvc.NewInMemoryService()
agent := llmagent.New("assistant",
llmagent.WithTools(memory.Tools()),
llmagent.WithModel(model))
// Memory service managed at runner level
runner := runner.NewRunner("app", agent,
runner.WithMemoryService(memory))
// Agents remember context across sessions
Rich Tool Integration
// Any function becomes a tool
calculator := function.NewFunctionTool(
calculate,
function.WithName("calculator"),
function.WithDescription("Math operations"))
// MCP protocol support
mcpTool := mcptool.New(serverConn)
Production Observability
// Start Langfuse integration
clean, _ := langfuse.Start(ctx)
defer clean(ctx)
runner := runner.NewRunner("app", agent)
// Run with Langfuse attributes
events, _ := runner.Run(ctx, "user-1", "session-1",
model.NewUserMessage("Hello"),
agent.WithSpanAttributes(
attribute.String("langfuse.user.id", "user-1"),
attribute.String("langfuse.session.id", "session-1"),
))
Agent Skills
// Skills are folders with a SKILL.md spec.
repo, _ := skill.NewFSRepository("./skills")
// Let the agent load and run skills on demand.
tools := []tool.Tool{
skilltool.NewLoadTool(repo),
skilltool.NewRunTool(repo, localexec.New()),
}
NewFSRepository also accepts an HTTP(S) URL (for example, a .zip or
.tar.gz archive). The payload is downloaded and cached locally (set
SKILLS_CACHE_DIR to override the cache location).
NewFSRepository also accepts multiple roots, which is useful for
combining shared skills with user-private skills. In a long-lived
process, call repo.Refresh() after installing, deleting, or renaming a
skill so the next turn sees the updated skill set.
If you wire Skills through LLMAgent with llmagent.WithCodeExecutor(...),
consider also setting
llmagent.WithEnableCodeExecutionResponseProcessor(false) so Markdown fenced
code blocks embedded in assistant text do not auto-execute while skill_run is
enabled.
Agent Self-Evolution
repo, _ := skill.NewFSRepository("./managed_skills")
evo := evolution.NewService(reviewerModel,
evolution.WithManagedSkillsDir("./managed_skills"),
evolution.WithSkillRepository(repo))
defer evo.Close()
runner := runner.NewRunner("app", agent,
runner.WithEvolutionService(evo))
Completed sessions can be reviewed asynchronously, promoted through quality gates, and published back as managed Agent Skills for future turns.
Evaluation & Benchmarks
evaluator, _ := evaluation.New("app", runner, evaluation.WithNumRuns(3))
defer evaluator.Close()
result, _ := evaluator.Evaluate(ctx, "math-basic")
_ = result.OverallStatus
Table of Contents
- tRPC-Agent-Go
Documentation
Ready to dive into tRPC-Agent-Go? Our documentation covers everything from basic concepts to advanced techniques, helping you build powerful AI applications with confidence. Whether you're new to AI agents or an experienced developer, you'll find detailed guides, practical examples, and best practices to accelerate your development journey.
Blog
These blog posts cover the framework overview, core capabilities, and engineering practices—read as needed:
- A Go Agent Framework for Building Intelligent AI Applications
- GraphAgent Seamlessly Combines AI Workflows and Agents
- Quickly Build AG-UI-Based Agent Services
- A Go-Native Implementation of the Anthropic Agent Skills Specification
- Building an Enterprise-Grade, Secure, and Controllable OpenClaw Runtime
- A Complete Guide to AI Agent Automated Evaluation Paradigms and Engineering Practice
- A Complete Guide to Automated Prompt Iteration and Engineering Practice for AI Agents
Quick Start

The demo above shows a tRPC-Agent-Go service streaming agent events to an AG-UI client while the agent plans, calls tools, and updates the interface.
Prerequisites
- Go 1.21 or later
- LLM provider API key (OpenAI, DeepSeek, etc.)
- 5 minutes to build your first intelligent agent
Run the Example
Get started in 3 simple steps:
# 1. Clone and setup
git clone https://github.com/trpc-group/trpc-agent-go.git
cd trpc-agent-go
# 2. Configure your LLM
export OPENAI_API_KEY="your-api-key-here"
export OPENAI_BASE_URL="your-base-url-here" # Optional
# 3. Run your first agent!
cd examples/runner
go run . -model="gpt-4o-mini" -streaming=true
What you'll see:
- Interactive chat with your AI agent
- Real-time streaming responses
- Tool usage (calculator + time tools)
- Multi-turn conversations with memory
Try asking: "What's the current time? Then calculate 15 * 23 + 100"
Basic Usage
package main
import (
"context"
"fmt"
"log"
"trpc.group/trpc-go/trpc-agent-go/agent/llmagent"
"trpc.group/trpc-go/trpc-agent-go/model"
"trpc.group/trpc-go/trpc-agent-go/model/openai"
"trpc.group/trpc-go/trpc-agent-go/runner"
"trpc.group/trpc-go/trpc-agent-go/tool"
"trpc.group/trpc-go/trpc-agent-go/tool/function"
)
func main() {
// Create model.
modelInstance := openai.New("deepseek-chat",
openai.WithVariant(openai.VariantDeepSeek),
)
// Create tool.
calculatorTool := function.NewFunctionTool(
calculator,
function.WithName("calculator"),
function.WithDescription("Execute addition, subtraction, multiplication, and division. "+
"Parameters: a, b are numeric values, op takes values add/sub/mul/div; "+
"returns result as the calculation result."),
)
// Enable streaming output.
genConfig := model.GenerationConfig{
Stream: true,
}
// Create Agent.
agent := llmagent.New("assistant",
llmagent.WithModel(modelInstance),
llmagent.WithTools([]tool.Tool{calculatorTool}),
llmagent.WithGenerationConfig(genConfig),
)
// Create Runner.
runner := runner.NewRunner("calculator-app", agent)
// Execute conversation.
ctx := context.Background()
events, err := runner.Run(ctx,
"user-001",
"session-001",
model.NewUserMessage("Calculate what 2+3 equals"),
)
if err != nil {
log.Fatal(err)
}
// Process event stream.
for event := range events {
if event.Object == "chat.completion.chunk" {
fmt.Print(event.Response.Choices[0].Delta.Content)
}
}
fmt.Println()
}
func calculator(ctx context.Context, req calculatorReq) (calculatorRsp, error) {
var result float64
switch req.Op {
case "add", "+":
result = req.A + req.B
case "sub", "-":
result = req.A - req.B
case "mul", "*":
result = req.A * req.B
case "div", "/":
result = req.A / req.B
default:
return calculatorRsp{}, fmt.Errorf("invalid operation: %s", req.Op)
}
return calculatorRsp{Result: result}, nil
}
type calculatorReq struct {
A float64 `json:"A" jsonschema:"description=First integer operand,required"`
B float64 `json:"B" jsonschema:"description=Second integer operand,required"`
Op string `json:"Op" jsonschema:"description=Operation type,enum=add,enum=sub,enum=mul,enum=div,required"`
}
type calculatorRsp struct {
Result float64 `json:"result"`
}
Dynamic Agent per Request
Sometimes your Agent must be created per request (for example: different
prompt, model, tools, sandbox instance). In that case, you can let Runner build
a fresh Agent for every Run(...):
r := runner.NewRunnerWithAgentFactory(
"my-app",
"assistant",
func(ctx context.Context, ro agent.RunOptions) (agent.Agent, error) {
// Use ro to build an Agent for this request.
a := llmagent.New("assistant",
llmagent.WithInstruction(ro.Instruction),
)
return a, nil
},
)
events, err := r.Run(ctx,
"user-001",
"session-001",
model.NewUserMessage("Hello"),
agent.WithInstruction("You are a helpful assistant."),
)
_ = events
_ = err
Stop / Cancel a Run
If you want to interrupt a running agent, cancel the context you passed to
Runner.Run (recommended). This stops model calls and tool calls safely and
lets the runner clean up.
Important: do not just “break” your event loop and walk away — the agent goroutine may keep running and can block on channel writes. Always cancel, then keep draining the event channel until it is closed.
Option A: Ctrl+C (terminal programs)
Convert Ctrl+C into context cancellation:
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()
events, err := r.Run(ctx, userID, sessionID, message)
if err != nil {
return err
}
for range events {
// Drain until the runner stops (ctx canceled or run completed).
}
Option B: Cancel from your code
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
events, err := r.Run(ctx, userID, sessionID, message)
if err != nil {
return err
}
go func() {
time.Sleep(2 * time.Second)
cancel()
}()
for range events {
// Keep draining until the channel is closed.
}
Option C: Cancel by requestID (for servers / background runs)
requestID := "req-123"
events, err := r.Run(ctx, userID, sessionID, message,
agent.WithRequestID(requestID),
)
mr := r.(runner.ManagedRunner)
_ = mr.Cancel(requestID)
For more details (including detached cancellation, resume, and server cancel
routes), see docs/mkdocs/en/runner.md and docs/mkdocs/en/agui.md.
Examples
The examples directory contains runnable demos covering every major feature.
Not sure where to start? Pick a path by what you want to build:
- First multi-turn agent: examples/runner
- Controllable graph workflow: examples/graph
- Agent frontend or streaming UI: examples/agui
- A2A interoperability: examples/a2aagent
- RAG and knowledge retrieval: examples/knowledge
- Evaluation and prompt iteration: examples/evaluation
- Skills and local automation: examples/skillrun
1. Tool Usage
- examples/agenttool – Wrap agents as callable tools.
- examples/multitools – Multiple tools orchestration.
- examples/duckduckgo – Web search tool integration.
- examples/fileinput – Provide files as inputs.
- examples/agenttool shows streaming and non-streaming patterns.
2. LLM-Only Agent
Example: examples/llmagent
- Wrap any chat-completion model as an
LLMAgent. - Configure system instructions, temperature, max tokens, etc.
- Receive incremental
event.Eventupdates while the model streams.
3. Multi-Agent Runners
Example: examples/multiagent
- ChainAgent – linear pipeline of sub-agents.
- ParallelAgent – run sub-agents concurrently and merge results.
- CycleAgent – iterate until a termination condition is met.
4. Graph Agent
Example: examples/graph
-
GraphAgent – demonstrates building and executing complex, conditional workflows using the
graphandagent/graphpackages. It shows how to construct a graph-based agent, manage state safely, implement conditional routing, and orchestrate execution with the Runner. -
Multi-conditional fan-out routing:
// Return multiple branch keys and run targets in parallel.
sg := graph.NewStateGraph(schema)
sg.AddNode("router", func(ctx context.Context, s graph.State) (any, error) {
return nil, nil
})
sg.AddNode("A", func(ctx context.Context, s graph.State) (any, error) {
return graph.State{"a": 1}, nil
})
sg.AddNode("B", func(ctx context.Context, s graph.State) (any, error) {
return graph.State{"b": 1}, nil
})
sg.SetEntryPoint("router")
sg.AddMultiConditionalEdges(
"router",
func(ctx context.Context, s graph.State) ([]string, error) {
return []string{"goA", "goB"}, nil
},
map[string]string{"goA": "A", "goB": "B"}, // Path map or ends map
)
sg.SetFinishPoint("A").SetFinishPoint("B")
5. Memory
Example: examples/memory
- In‑memory and Redis memory services with CRUD, search and tool integration.
- How to configure, call tools and customize prompts.
6. Knowledge
Example: examples/knowledge
- Basic RAG example: load sources, embed to a vector store, and search.
- How to use conversation context and tune loading/concurrency options.
7. Telemetry & Tracing
Example: examples/telemetry
- OpenTelemetry hooks across model, tool and runner layers.
- Export traces to OTLP endpoint for real-time analysis.
8. MCP Integration
Example: examples/mcptool
- Wrapper utilities around trpc-mcp-go, an implementation of the Model Context Protocol (MCP).
- Provides structured prompts, tool calls, resource and session messages that follow the MCP specification.
- Enables dynamic tool execution and context-rich interactions between agents and LLMs.
9. AG-UI Demo
Example: examples/agui
- Exposes a Runner through the AG-UI (Agent-User Interaction) protocol.
- Built-in Server-Sent Events (SSE) server, plus client samples (for example, CopilotKit and TDesign Chat).
10. Evaluation
Example: examples/evaluation
- Evaluate an agent with repeatable eval sets and pluggable metrics.
- Includes local file-backed runs and in-memory runs.
11. Agent Skills
Examples: examples/skillrun, examples/skillfind
- Skills are folders with a
SKILL.mdspec + optional docs/scripts. - Built-in tools:
skill_load,skill_list_docs,skill_select_docs,skill_run, and (when the executor supports interactive sessions)skill_exec,skill_write_stdin,skill_poll_session,skill_kill_session. skill_runis the default one-shot command runner in an isolated workspace.skill_execand the session tools cover interactive stdin/TTY flows without inlining full scripts into the prompt. They are registered only when the code executor exposesInteractiveProgramRunner(or falls back to a local engine that does).skill.NewFSRepository(...)can scan multiple roots, such as a shared skills directory plus a user-private directory. Use(*skill.FSRepository).Refresh()after skill installation or removal in long-lived processes.- Prefer using
skill_runonly for commands required by the selected skill docs, not for generic shell exploration. - When
LLMAgentusesWithCodeExecutor(...)only to supportskill_run, disable the response code execution processor withllmagent.WithEnableCodeExecutionResponseProcessor(false). The skill-focused examples (examples/skill,examples/skillrun,examples/skilldynamicschema, andexamples/structuredoutputskills) follow this pattern so fenced code blocks embedded in assistant text do not auto-execute. examples/skillfinddemonstrates a real end-to-end discovery flow: the model uses a built-inskill-findskill to search the public web, install a public GitHub skill into a user-private directory, refresh the repository, and use the new skill in the same conversation. Local execution stays off by default and can be enabled explicitly when you want to run an installed skill.
12. Agent Self-Evolution
Example: examples/evolution
- Reviews completed sessions in the background and extracts reusable
SKILL.mdworkflows. - Supports revision storage, quality gates, human approval, and warm-start behavior when skills are available on later runs.
- Runner integration is a single option:
runner.WithEvolutionService(...).
13. Artifacts
Example: examples/artifact
- Save and retrieve versioned files (images, text, reports) produced by tools.
- Supports multiple backends (in-memory, S3, COS).
14. A2A Interop
Example: examples/a2aadk
- Agent-to-Agent (A2A) interop with an ADK Python A2A server.
- Demonstrates streaming, tool calls, and code execution across runtimes.
15. Gateway Server
Example: openclaw
- A minimal OpenClaw-like gateway server.
- Stable session ids and per-session serialization.
- Basic safety controls: allowlist + mention gating.
- OpenClaw-like implementation (Telegram + gateway): openclaw
Other notable examples:
- examples/humaninloop – Human in the loop.
- examples/codeexecution – Secure code execution.
See individual README.md files in each example folder for usage details.
Architecture Overview
Architecture
Execution Flow
- Runner orchestrates the entire execution pipeline with session management
- Agent processes requests using multiple specialized components
- Planner determines the optimal strategy and tool selection
- Tools execute specific tasks (API calls, calculations, web searches)
- Memory maintains context and learns from interactions
- Knowledge provides RAG capabilities for document understanding
- Evolution reviews completed sessions and turns reusable procedures into managed skills
Key packages:
| Package | Responsibility |
|---|---|
agent | Core execution unit, responsible for processing user input and generating responses. |
runner | Agent executor, responsible for managing execution flow and connecting Session/Memory Service capabilities. |
model | Supports multiple LLM models (OpenAI, DeepSeek, etc.). |
tool | Provides various tool capabilities (Function, MCP, DuckDuckGo, etc.). |
session | Manages user session state and events. |
memory | Records user long-term memory and personalized information. |
knowledge | Implements RAG knowledge retrieval capabilities. |
planner | Provides Agent planning and reasoning capabilities. |
artifact | Stores and retrieves versioned files produced by agents and tools (images, reports, etc.). |
skill | Loads and executes reusable Agent Skills defined by SKILL.md. |
evolution | Reviews completed sessions and publishes reusable procedures as managed Agent Skills. |
event | Defines event types and streaming payloads used across Runner and servers. |
evaluation | Evaluates agents on eval sets using pluggable metrics and stores results. |
server | Exposes HTTP servers (Gateway, AG-UI, A2A) for integration and UIs. |
telemetry | OpenTelemetry tracing and metrics instrumentation. |
Using Built-in Agents
For most applications you do not need to implement the agent.Agent
interface yourself. The framework already ships with several ready-to-use
agents that you can compose like Lego bricks:
| Agent | Purpose |
|---|---|
LLMAgent | Wraps an LLM chat-completion model as an agent. |
ChainAgent | Executes sub-agents sequentially. |
ParallelAgent | Executes sub-agents concurrently and merges output. |
CycleAgent | Loops over a planner + executor until stop signal. |
Multi-Agent Collaboration Example
// 1. Create a base LLM agent.
base := llmagent.New(
"assistant",
llmagent.WithModel(openai.New("gpt-4o-mini")),
)
// 2. Create a second LLM agent with a different instruction.
translator := llmagent.New(
"translator",
llmagent.WithInstruction("Translate everything to French"),
llmagent.WithModel(openai.New("gpt-3.5-turbo")),
)
// 3. Combine them in a chain.
pipeline := chainagent.New(
"pipeline",
chainagent.WithSubAgents([]agent.Agent{base, translator}),
)
// 4. Run through the runner for sessions & telemetry.
run := runner.NewRunner("demo-app", pipeline)
events, _ := run.Run(ctx, "user-1", "sess-1",
model.NewUserMessage("Hello!"))
for ev := range events { /* ... */ }
The composition API lets you nest chains, cycles, or parallels to build complex workflows without low-level plumbing.
Contributing
We love contributions! Join our growing community of developers building the future of AI agents.
Ways to Contribute
- Report bugs or suggest features via Issues
- Improve documentation - help others learn faster
- Submit PRs - bug fixes, new features, or examples
- Share your use cases - inspire others with your agent applications
Quick Contribution Setup
# Fork & clone the repo
git clone https://github.com/YOUR_USERNAME/trpc-agent-go.git
cd trpc-agent-go
# Run tests to ensure everything works
go test ./...
go vet ./...
# Make your changes and submit a PR!
Please read CONTRIBUTING.md for detailed guidelines and coding standards.
Acknowledgements
Enterprise Validation
Special thanks to Tencent's business units including Tencent Yuanbao, Tencent Video, Tencent News, IMA, and QQ Music for their invaluable support and real-world validation. Production usage drives framework excellence!
Open Source Inspiration
Inspired by amazing frameworks like ADK, Agno, CrewAI, AutoGen, and many others. Standing on the shoulders of giants!
Star History
License
Licensed under the Apache 2.0 License - see LICENSE file for details.
GitHub Repository • Report Issues • Join Discussions
If tRPC-Agent-Go is useful for your Go agent projects, stars are welcome.
Empowering developers to build the next generation of intelligent applications