trpc-group/trpc-agent-go

GitHub: trpc-group/trpc-agent-go

一个基于 Go 语言的生产级 AI Agent 框架,提供图工作流、多智能体编排、工具调用和可观测性等完整能力。

Stars: 1356 | Forks: 166

English | [中文](README.zh_CN.md) # tRPC-Agent-Go [![Go Reference](https://pkg.go.dev/badge/trpc.group/trpc-go/trpc-agent-go.svg)](https://pkg.go.dev/trpc.group/trpc-go/trpc-agent-go) [![Go Report Card](https://goreportcard.com/badge/github.com/trpc-group/trpc-agent-go)](https://goreportcard.com/report/github.com/trpc-group/trpc-agent-go) [![LICENSE](https://img.shields.io/badge/license-Apache--2.0-green.svg)](https://github.com/trpc-group/trpc-agent-go/blob/main/LICENSE) [![Releases](https://img.shields.io/github/release/trpc-group/trpc-agent-go.svg?style=flat-square)](https://github.com/trpc-group/trpc-agent-go/releases) [![Tests](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/b8d69b89d2000018.svg)](https://github.com/trpc-group/trpc-agent-go/actions/workflows/prc.yml) [![Coverage](https://codecov.io/gh/trpc-group/trpc-agent-go/branch/main/graph/badge.svg)](https://app.codecov.io/gh/trpc-group/trpc-agent-go/tree/main) [![Documentation](https://img.shields.io/badge/Docs-Website-blue.svg)](https://trpc-group.github.io/trpc-agent-go/) **tRPC-Agent-Go 是一个用于构建生产级 agent 系统的 Go 框架。** 它在一个原生的 Go 技术栈中提供了 LLM agent、graph 工作流、工具调用、session 和 memory 状态、知识检索、评估以及 OpenTelemetry 可观测性。 当你需要适配 Go 服务的 agent 应用时,就可以使用它:支持并发、 可观测、易于部署,并且可以随时与 A2A、AG-UI 和 MCP 集成。 **为什么选择 tRPC-Agent-Go?** - **Go 原生 agent runtime**:流式 runner、context 取消机制以及对服务友好的 API - **GraphAgent**:类型安全的 graph 工作流,支持多条件路由, 在功能上相当于 Go 版的 LangGraph - **多 agent 协作**:支持链式、并行和基于循环的工作流 - **丰富的工具生态**:Function 工具、MCP 工具、网页搜索、代码 执行和自定义服务 - **持久化状态**:session、memory、artifacts 和知识检索 - **Agent Skills**:可重用的 `SKILL.md` 工作流与安全执行 - **Prompt 缓存**:自动成本优化,缓存内容可节省 90% 的成本 - **评估与基准测试**:评估数据集 + 指标,用于随时衡量质量 - **协议集成**:前端集成 AG-UI,agent 互操作性集成 A2A,工具集成 MCP - **生产级可观测性**:OpenTelemetry tracing、metrics 和 Langfuse 示例 ## 使用场景 **非常适合构建:** - **客户支持机器人** - 理解上下文并解决复杂查询的智能 agent - **数据分析助手** - 查询数据库、生成报告并提供洞察的 agent - **DevOps 自动化** - 智能部署、监控和事件响应系统 - **业务流程自动化** - 具有人机交互能力的多步骤工作流 - **研究与知识管理** - 基于 RAG 的文档分析和问答 agent ## 核心特性
### 多 agent 编排 ``` // 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)) ``` ### 高级 Memory 系统 ``` // 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 ```
### 丰富的工具集成 ``` // Any function becomes a tool calculator := function.NewFunctionTool( calculate, function.WithName("calculator"), function.WithDescription("Math operations")) // MCP protocol support mcpTool := mcptool.New(serverConn) ``` ### 生产级可观测性 ``` // 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 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` 也支持 HTTP(S) URL(例如 `.zip` 或 `.tar.gz` 归档文件)。payload 会被下载并缓存在本地(设置 `SKILLS_CACHE_DIR` 可覆盖缓存位置)。 `NewFSRepository` 还支持多个根目录,这对于 将共享 skills 与用户私有的 skills 结合使用非常有用。在长期运行的 进程中,在安装、删除或重命名 skill 后调用 `repo.Refresh()`,以便下一轮能看到更新后的 skill 集合。 如果你通过 `LLMAgent` 和 `llmagent.WithCodeExecutor(...)` 来配置 Skills, 建议同时设置 `llmagent.WithEnableCodeExecutionResponseProcessor(false)`,这样在启用了 `skill_run` 时, 助手文本中嵌入的 Markdown 代码块就不会自动执行。 ### 评估与基准测试 ``` evaluator, _ := evaluation.New("app", runner, evaluation.WithNumRuns(3)) defer evaluator.Close() result, _ := evaluator.Evaluate(ctx, "math-basic") _ = result.OverallStatus ```
## 目录 - [tRPC-Agent-Go](#trpc-agent-go) - [使用场景](#use-cases) - [核心特性](#key-features) - [多 agent 编排](#multi-agent-orchestration) - [高级 Memory 系统](#advanced-memory-system) - [丰富的工具集成](#rich-tool-integration) - [生产级可观测性](#production-observability) - [Agent Skills](#agent-skills) - [评估与基准测试](#evaluation--benchmarks) - [目录](#table-of-contents) - [文档](#documentation) - [博客](#blog) - [快速开始](#quick-start) - [前置条件](#prerequisites) - [运行示例](#run-the-example) - [基本用法](#basic-usage) - [停止/取消运行](#stop--cancel-a-run) - [示例](#examples) - [1. 工具使用](#1-tool-usage) - [2. 纯 LLM agent](#2-llm-only-agent) - [3. 多 agent runner](#3-multi-agent-runners) - [4. Graph agent](#4-graph-agent) - [5. Memory](#5-memory) - [6. 知识库](#6-knowledge) - [7. 遥测与 tracing](#7-telemetry--tracing) - [8. MCP 集成](#8-mcp-integration) - [9. AG-UI Demo](#9-ag-ui-demo) - [10. 评估](#10-evaluation) - [11. Agent Skills](#11-agent-skills) - [12. Artifacts](#12-artifacts) - [13. A2A 互操作性](#13-a2a-interop) - [14. 网关服务器](#14-gateway-server) - [架构概览](#architecture-overview) - [**执行流程**](#execution-flow) - [使用内置 agent](#using-built-in-agents) - [多 agent 协作示例](#multi-agent-collaboration-example) - [贡献](#contributing) - [**贡献方式**](#ways-to-contribute) - [**快速贡献配置**](#quick-contribution-setup) - [致谢](#acknowledgements) - [**企业级验证**](#enterprise-validation) - [**开源灵感**](#open-source-inspiration) - [Star 历史](#star-history) - [许可证](#license) - [**GitHub 仓库** • **报告问题** • **参与讨论**](#github-repository--report-issues--join-discussions) ## 文档 准备好深入了解 tRPC-Agent-Go 了吗?我们的[文档](https://trpc-group.github.io/trpc-agent-go/)涵盖了从基础概念到高级技巧的所有内容,帮助你自信地构建强大的 AI 应用。无论你是 AI agent 新手还是经验丰富的开发者,都可以找到详细的指南、实用的示例和最佳实践,以加速你的开发之旅。 ### 博客 这些博客文章涵盖了框架概述、核心功能和工程实践——可根据需要阅读: - [构建智能 AI 应用的 Go Agent 框架](docs/mkdocs/en/blog/trpcagentgo.md) - [GraphAgent 无缝结合 AI 工作流和 Agent](docs/mkdocs/en/blog/graphagent.md) - [快速构建基于 AG-UI 的 Agent 服务](docs/mkdocs/en/blog/agui.md) - [Anthropic Agent Skills 规范的 Go 原生实现](docs/mkdocs/en/blog/skill.md) - [构建企业级、安全可控的 OpenClaw Runtime](docs/mkdocs/en/blog/openclaw.md) - [AI Agent 自动化评估范式与工程实践完全指南](docs/mkdocs/en/blog/evaluation.md) - [AI Agent 自动化 Prompt 迭代与工程实践完全指南](docs/mkdocs/en/blog/promptiter.md) ## 快速开始 ![AG-UI report agent demo](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/fac63f9203000024.gif) 上面的 demo 展示了一个 tRPC-Agent-Go 服务在 agent 进行规划、调用工具和更新界面的同时, 将 agent 事件流式传输到 AG-UI 客户端。 ### 前置条件 - Go 1.21 或更高版本 - LLM 提供商 API key(OpenAI、DeepSeek 等) - 5 分钟时间来构建你的第一个智能 agent ### 运行示例 **只需 3 个简单步骤即可开始:** ``` # 1. 克隆和设置 git clone https://github.com/trpc-group/trpc-agent-go.git cd trpc-agent-go # 2. 配置你的 LLM export OPENAI_API_KEY="your-api-key-here" export OPENAI_BASE_URL="your-base-url-here" # Optional # 3. 运行你的第一个 agent! cd examples/runner go run . -model="gpt-4o-mini" -streaming=true ``` **你将会看到:** - 与你的 AI agent 进行**交互式聊天** - **实时流式**响应 - **工具调用**(计算器 + 时间工具) - 带有 memory 的**多轮对话** 试着问:“现在几点了?然后计算 15 \* 23 + 100” ### 基本用法 ``` 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"` } ``` ### 按请求动态生成 Agent 有时你的 Agent 必须**针对每个请求**创建(例如:不同的 prompt、模型、工具、sandbox 实例)。在这种情况下,你可以让 Runner 为每次 `Run(...)` 构建一个新的 Agent: ``` 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 ``` ### 停止 / 取消运行 如果你想中断正在运行的 agent,**请取消**你传递给 `Runner.Run` 的 context(推荐)。这会安全地停止模型调用和工具调用, 并让 runner 进行清理。 重要提示:**不要**仅仅在你的事件循环中执行“break”然后离开——agent goroutine 可能仍在运行,并可能阻塞在 channel 的写入上。请务必先取消, 然后继续读取事件 channel,直到它被关闭。 #### 选项 A:Ctrl+C(终端程序) 将 Ctrl+C 转换为 context 取消: ``` 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). } ``` #### 选项 B:从你的代码中取消 ``` 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. } ``` #### 选项 C:通过 `requestID` 取消(适用于服务器 / 后台运行) ``` requestID := "req-123" events, err := r.Run(ctx, userID, sessionID, message, agent.WithRequestID(requestID), ) mr := r.(runner.ManagedRunner) _ = mr.Cancel(requestID) ``` 有关更多详细信息(包括分离式取消、恢复和服务器取消 路由),请参阅 `docs/mkdocs/en/runner.md` 和 `docs/mkdocs/en/agui.md`。 ## 示例 `examples` 目录包含了涵盖所有主要功能的可运行 demo。 不确定从哪里开始?根据你想要构建的内容选择一个路径: - 第一个多轮 agent:[examples/runner](examples/runner) - 可控的 graph 工作流:[examples/graph](examples/graph) - Agent 前端或流式 UI:[examples/agui](examples/agui) - A2A 互操作性:[examples/a2aagent](examples/a2aagent) - RAG 和知识检索:[examples/knowledge](examples/knowledge) - 评估和 prompt 迭代:[examples/evaluation](examples/evaluation) - Skills 和本地自动化:[examples/skillrun](examples/skillrun) ### 1. 工具使用 - [examples/agenttool](examples/agenttool) – 将 agent 封装为可调用的工具。 - [examples/multitools](examples/multitools) – 多工具编排。 - [examples/duckduckgo](examples/duckduckgo) – 网页搜索工具集成。 - [examples/filetoolset](examples/filetoolset) – 将文件操作作为工具。 - [examples/fileinput](examples/fileinput) – 提供文件作为输入。 - [examples/agenttool](examples/agenttool) 展示了流式和非流式 模式。 ### 2. 纯 LLM agent 示例:[examples/llmagent](examples/llmagent) - 将任何 chat-completion 模型封装为 `LLMAgent`。 - 配置系统指令、temperature、max token 等。 - 在模型流式输出时接收增量的 `event.Event` 更新。 ### 3. 多 agent runner 示例:[examples/multiagent](examples/multiagent) - **ChainAgent** – 子 agent 的线性 pipeline。 - **ParallelAgent** – 并发运行子 agent 并合并结果。 - **CycleAgent** – 迭代直到满足终止条件。 ### 4. Graph agent 示例:[examples/graph](examples/graph) - **GraphAgent** – 演示了如何使用 `graph` 和 `agent/graph` 包来构建和执行复杂的条件 工作流。它展示了 如何构建基于 graph 的 agent,安全地管理状态,实现 条件路由,以及使用 Runner 编排执行。 - 多条件扇出路由: ``` // 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 示例:[examples/memory](examples/memory) - 内存和 Redis memory 服务,支持 CRUD、搜索和工具集成。 - 如何配置、调用工具和自定义 prompt。 ### 6. 知识库 示例:[examples/knowledge](examples/knowledge) - 基础 RAG 示例:加载源、embed 到 vector store 并进行搜索。 - 如何使用对话上下文和调整加载/并发选项### 7. 遥测与 Tracing 示例:[examples/telemetry](examples/telemetry) - 跨模型、工具和 runner 层的 OpenTelemetry 钩子。 - 将 trace 导出到 OTLP endpoint 以进行实时分析。 ### 8. MCP 集成 示例:[examples/mcptool](examples/mcptool) - **trpc-mcp-go** 的封装实用工具,这是 **Model Context Protocol (MCP)** 的一种实现。 - 提供了遵循 MCP 规范的结构化 prompt、工具调用、resource 和 session 消息。 - 支持 agent 与 LLM 之间的动态工具执行和上下文丰富的交互。 ### 9. AG-UI Demo 示例:[examples/agui](examples/agui) - 通过 AG-UI (Agent-User Interaction) 协议暴露 Runner。 - 内置 Server-Sent Events (SSE) 服务器,以及客户端示例(例如, CopilotKit 和 TDesign Chat)。 ### 10. 评估 示例:[examples/evaluation](examples/evaluation) - 使用可重复的评估数据集和可插拔的指标来评估 agent。 - 包含本地文件支持和内存中的运行方式。 ### 11. Agent 技能 示例:[examples/skillrun](examples/skillrun), [examples/skillfind](examples/skillfind) - Skills 是带有 `SKILL.md` 规范 + 可选文档/脚本的文件夹。 - 内置工具:`skill_load`、`skill_list_docs`、`skill_select_docs`、 `skill_run`,以及(当执行器支持交互式 session 时) `skill_exec`、`skill_write_stdin`、`skill_poll_session`、 `skill_kill_session`。 - `skill_run` 是隔离工作区中默认的一次性命令 runner。 - `skill_exec` 和 session 工具涵盖了交互式 stdin/TTY 流程, 而无需将完整的脚本内联到 prompt 中。只有当代码执行器暴露了 `InteractiveProgramRunner` (或回退到支持该功能的本地引擎)时,它们才会被注册。 - `skill.NewFSRepository(...)` 可以扫描多个根目录,例如共享的 skills 目录加上用户私有的目录。在长期运行的进程中, 在安装或删除 skill 后使用 `(*skill.FSRepository).Refresh()`。 - 建议仅将 `skill_run` 用于选定 skill 文档所需的命令,而不是用于常规的 shell 探索。 - 当 `LLMAgent` 使用 `WithCodeExecutor(...)` 仅为了支持 `skill_run` 时, 请使用 `llmagent.WithEnableCodeExecutionResponseProcessor(false)` 禁用响应代码执行处理器。 专注于 skill 的示例(`examples/skill`、`examples/skillrun`、 `examples/skilldynamicschema` 和 `examples/structuredoutputskills`)遵循此模式,因此嵌入在助手文本中的代码块不会自动执行。 - `examples/skillfind` 演示了一个真实的端到端发现流程: 模型使用内置的 `skill-find` skill 搜索公共网络, 将公共 GitHub skill 安装到用户私有目录中,刷新 存储库,并在同一对话中使用新的 skill。 本地执行默认处于关闭状态,在你想要运行已安装的 skill 时可以显式启用。 ### 12. Artifacts 示例:[examples/artifact](examples/artifact) - 保存和检索由工具生成的版本化文件(图像、文本、报告)。 - 支持多种后端(内存、S3、COS)。 ### 13. A2A 互操作性 示例:[examples/a2aadk](examples/a2aadk) - 与 ADK Python A2A 服务器的 Agent-to-Agent (A2A) 互操作性。 - 演示了跨 runtime 的流式传输、工具调用和代码执行。 ### 14. 网关服务器 示例:[openclaw](openclaw) - 一个最简化的类 OpenClaw 网关服务器。 - 稳定的 session ID 和基于 session 的序列化。 - 基本的安全控制:白名单 + 提及门控。 - 类 OpenClaw 实现(Telegram + 网关):[openclaw](openclaw) 其他值得注意的示例: - [examples/humaninloop](examples/humaninloop) – 人工干预(Human in the loop)。 - [examples/codeexecution](examples/codeexecution) – 安全的代码执行。 有关用法的详细信息,请参阅每个示例文件夹中各自的 `README.md` 文件。 ## 架构概览 架构 ![architecture](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/24017fbc74000029.svg) ### **执行流程** 1. **Runner** 通过 session 管理来编排整个执行 pipeline 2. **Agent** 使用多个专门的组件处理请求 3. **Planner** 确定最佳策略和工具选择 4. **工具** 执行特定任务(API 调用、计算、网页搜索) 5. **Memory** 维护上下文并从交互中学习 6. **知识** 提供用于文档理解的 RAG 能力 关键 package: | Package | 职责 | | ----------- | ----------------------------------------------------------------------------------------------------------- | | `agent` | 核心执行单元,负责处理用户输入并生成响应。 | | `runner` | Agent 执行器,负责管理执行流程并连接 Session/Memory 服务能力。 | | `model` | 支持多种 LLM 模型(OpenAI、DeepSeek 等)。 | | `tool` | 提供各种工具能力(Function、MCP、DuckDuckGo 等)。 | | `session` | 管理用户 session 状态和事件。 | | `memory` | 记录用户长期 memory 和个性化信息。 | | `knowledge` | 实现 RAG 知识检索能力。 | | `planner` | 提供 agent 规划和推理能力。 | | `artifact` | 存储和检索由 agent 和工具生成的版本化文件(图像、报告等)。 | | `skill` | 加载并执行由 `SKILL.md` 定义的可重用 Agent Skills。 | | `event` | 定义 Runner 和服务器中使用的事件类型和流式 payload。 | | `evaluation` | 使用可插拔的指标在评估数据集上评估 agent 并存储结果。 | | `server` | 暴露 HTTP 服务器(Gateway、AG-UI、A2A)用于集成和 UI。 | | `telemetry` | OpenTelemetry tracing 和 metrics 插桩。 | ## 使用内置 agent 对于大多数应用,你**不需要**自己实现 `agent.Agent` 接口。该框架已经内置了几个现成可用的 agent,你可以像搭乐高积木一样组合它们: | Agent | 用途 | | --------------- | --------------------------------------------------- | | `LLMAgent` | 将 LLM chat-completion 模型封装为 agent。 | | `ChainAgent` | 按顺序执行子 agent。 | | `ParallelAgent` | 并发执行子 agent 并合并输出。 | | `CycleAgent` | 循环执行 planner + executor 直到收到停止信号。 | ### 多 agent 协作示例 ``` // 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 { /* ... */ } ``` 组合 API 允许你嵌套 chain、cycle 或 parallel 来构建复杂的 工作流,而无需进行底层管道搭建。 ## 贡献 我们欢迎你的贡献!加入我们不断壮大的开发者社区,共同构建 AI agent 的未来。 ### **贡献方式** - 通过 [Issues](https://github.com/trpc-group/trpc-agent-go/issues) **报告 bug** 或提出功能建议 - **改进文档** - 帮助他人更快地学习 - **提交 PR** - bug 修复、新功能或示例 - **分享你的用例** - 用你的 agent 应用启发他人 ### **快速贡献配置** ``` # Fork 和 clone 仓库 git clone https://github.com/YOUR_USERNAME/trpc-agent-go.git cd trpc-agent-go # 运行测试以确保一切正常 go test ./... go vet ./... # 进行修改并提交 PR! ``` **请阅读** [CONTRIBUTING.md](CONTRIBUTING.md) 了解详细的指南和编码规范。 ## 致谢 ### **企业级验证** 特别感谢腾讯的各业务部门,包括 **腾讯元宝**、**腾讯视频**、**腾讯新闻**、**IMA** 和 **QQ音乐**,感谢他们提供的宝贵支持和真实场景验证。生产环境的使用推动了框架的卓越! ### **开源灵感** 受到 **ADK**、**Agno**、**CrewAI**、**AutoGen** 等众多优秀框架的启发。站在巨人的肩膀上! ## Star 历史 [![Star History Chart](https://api.star-history.com/svg?repos=trpc-group/trpc-agent-go&type=Date)](https://star-history.com/#trpc-group/trpc-agent-go&Date) ## 许可证 基于 **Apache 2.0 许可证**授权 - 详见 [LICENSE](LICENSE) 文件。
### **GitHub 仓库** • **报告问题** • **参与讨论** 如果 tRPC-Agent-Go 对你的 Go agent 项目有帮助,欢迎点 Star。 _赋能开发者构建下一代智能应用_
标签:AI智能体框架, API集成, EVTX分析, Golang, LLM应用开发, MCP协议, 可观测性, 多智能体协作, 安全编程, 工作流引擎, 数据防泄漏, 日志审计, 用户代理