ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

在 Conductor 中运行 Google ADK Agent:TypeScript 框架桥接实战指南

在 Conductor 中运行 Google ADK Agent:TypeScript 框架桥接实战指南 在 Conductor 中运行 Google ADK AgentTypeScript 框架桥接实战指南【免费下载链接】conductorConductor is an event driven agentic workflow engine providing durable and highly resilient execution engine for applications and AI Agents项目地址: https://gitcode.com/GitHub_Trending/co/conductor导读本文介绍如何把使用 Google Agent Development KitADK编写的 LLM Agent通过 Conductor 官方 TypeScript/JavaScript SDK 的框架桥接能力编译为持久的、可观测的 Conductor 执行并最终部署为可在工作流中复用的 Conductor Agent。读完本文你将掌握安装与环境变量配置、编写可运行的 ADK Agent 脚本、理解run/plan/deploy/serve生命周期以及通过AGENT任务在工作流中调用已部署 Agent 的完整路径。什么是框架桥接Framework BridgeConductor 是一个事件驱动的 Agentic 工作流引擎为应用与 AI Agent 提供持久、高弹性的执行环境。框架桥接的核心理念是你继续使用 Google ADK 编写 Agent 对象Conductor SDK 负责把它编译成普通的工作流定义并在 Conductor 上执行。由于编译结果是工作流每一次 LLM 调用、工具调用、等待、重试和分支都能在 Conductor UI 与 API 中完整可见参见 Bring Your Framework Agent。TypeScript 生态下io-orkes/conductor-javascript包内置了 Google ADK 的支持从io-orkes/conductor-javascript/agents导入AgentRuntime即可把google/adk的LlmAgent交给它运行。同类桥接还覆盖 OpenAI Agents、LangChain、LangGraph 与 Vercel AI SDK各语言入口可在 Agent Guides 清单 中查看。第一步安装与配置安装 Conductor JavaScript SDK 与 Google ADK 两个依赖包npm install io-orkes/conductor-javascript google/adk随后配置运行环境变量。CONDUCTOR_SERVER_URL指向你的 Conductor 服务器{{CONDUCTOR_SERVER_URL}}为占位符需替换为实际地址对于需要认证的服务器还需要提供访问密钥CONDUCTOR_AGENT_LLM_MODEL指定 Agent 编译后在服务器端使用的 LLM 模型export CONDUCTOR_SERVER_URL{{CONDUCTOR_SERVER_URL}} # For authenticated Conductor servers: # export CONDUCTOR_AUTH_KEYYOUR_AUTH_KEY # export CONDUCTOR_AUTH_SECRETYOUR_AUTH_SECRET export CONDUCTOR_AGENT_LLM_MODELgoogle_gemini/gemini-2.5-flash各环境变量的作用如下环境变量作用CONDUCTOR_SERVER_URLConductor 服务器 API 地址。使用 Orkes Developer Edition 时形如https://developer.orkescloud.com/api本地服务器为http://localhost:8080/api见 Connect to ConductorCONDUCTOR_AUTH_KEY/CONDUCTOR_AUTH_SECRET访问受保护服务器所需的密钥对仅对启用了认证的服务器必填CONDUCTOR_AGENT_LLM_MODELAgent 的默认 LLM 模型使用provider/model形式此处为 Google Gemini 提供方下的gemini-2.5-flash配置模型的另一条前提是服务器端能够调用你的模型提供商Developer Edition 需要在 Integrations 中添加 AI/LLM 集成自建本地服务器则需在启动前导出提供商的 API Key例如export OPENAI_API_KEY...服务器继承该环境变量后即可调用模型详见 framework-agents 前置要求。第二步编写并运行 ADK Agent将以下代码保存为adk-agent.tsimport { LlmAgent } from google/adk; import { AgentRuntime } from io-orkes/conductor-javascript/agents; const agent new LlmAgent({ name: adk_greeter, model: gemini-2.5-flash, instruction: You are friendly and concise., }); const runtime new AgentRuntime(); try { const result await runtime.run(agent, Share a machine learning fact.); result.printResult(); } finally { await runtime.shutdown(); }代码要点LlmAgent是 Google ADK 提供的 LLM Agent 构造器字段与原生 ADK 完全一致name为 Agent 名称model为模型名此处为 Geminiinstruction为系统提示词。你完全可以继续用它添加tools、memory等 ADK 能力。AgentRuntime来自 Conductor SDK是框架桥接的运行时入口。runtime.run(agent, prompt)会把 ADK Agent 编译为工作流图并在 Conductor 上执行一次返回的结果对象通过printResult()打印。runtime.shutdown()放在finally中确保进程退出前释放运行时资源。使用tsx直接运行 TypeScript 文件npx tsx adk-agent.ts运行后除了终端打印的结果你还可以在 Conductor UI 中找到这次对应的持久执行记录逐项查看 Agent 的每一步行为——这就是框架桥接相对直接调用模型的最大差异。生命周期从本地运行到生产部署本地run只是起点。一个 ADK Agent 在 Conductor 中遵循统一的四步生命周期详见 From framework object to workflow stepRun迭代开发期把 Agent 对象交给AgentRuntime.run()编译并执行一次执行过程从第一次运行起就在 UI 中可见。Plan检查查看 Agent 将要编译成的工作流图适合在 CI 中、任何部署动作之前做静态校验。Deploy发布把编译后的 Agent 注册到服务器成为带名称与版本号的 Conductor Agent。此后调用方无需引入 Google ADK 及其依赖即可调用它。Serve服务启动 worker 进程执行 Agent 的工具。当 SDK 以本地函数方式运行工具时必须保持该进程存活才能支撑已部署 Agent 的持续调用。部署后在 workflow 中调用agentType决定执行模式而非编写框架agentType: conductor表示运行一个按name选择的已部署 Conductor AgentagentType: a2a默认则调用远程 A2A 端点。Google ADK 只是 SDK 的编写路径并不是agentType取值。父工作流通过AGENT任务调用已部署 Agent与调用其他持久步骤完全一致{ name: run_agent, taskReferenceName: run_agent_ref, type: AGENT, inputParameters: { agentType: conductor, name: deployed-agent-name, prompt: ${workflow.input.prompt}, pollIntervalSeconds: 5 } }首次调用时name与prompt必填version可固定版本缺省使用最新版sessionId、runId、context、media、model、timeoutSeconds、idempotencyKey按需使用未提供幂等键时运行时自动创建重启稳定的幂等键。AGENT任务的输出包含executionId、agentName、state、text及完成后的结构化output其state采用标准化 A2A 生命周期取值working、input-required、completed、failed、canceled详细状态映射见 Output and durable execution contract。服务器还需开启conductor.integrations.ai.enabledtrue才能使用已部署 Agent 的控制面见 Server requirement。从示例到真实场景ADK 编排故障分诊仓库中的 Google ADK 分诊 Cookbook 展示了更完整的实战形态用 ADK 编写一个“订单异常分诊”Agent它通过 MCP 工具获取证据、输出处置建议但绝不执行处置再通过 Conductor SDK 部署与调用from conductor.ai.agents import AgentRuntime from google.adk.agents import Agent from google.adk.tools.mcp_tool import McpToolset, StreamableHTTPConnectionParams agent Agent( nameadk_order_exception_triage, modelopenai/gpt-4o, instructionUse MCP evidence to recommend a disposition; never execute it., tools[McpToolset(connection_paramsStreamableHTTPConnectionParams(urlhttp://127.0.0.1:3001/mcp))], ) with AgentRuntime() as runtime: runtime.run(agent, Order O-42 arrived damaged.)该示例同时给出了生产注意事项agentType应取conductor而非adk使用服务器实际配置的模型限制工具访问与迭代预算处置建议必须经过人工审批路由按“订单 ID 异常事件 ID”对账。这些原则同样适用于 TypeScript 场景。多语言对照与进一步阅读同样的桥接思路在各语言 SDK 中保持一致便于团队跨栈复用Pythonpip install conductor-python[adk]从conductor.ai.agents导入AgentRuntime见 Python Google ADK 指南Java依赖org.conductoross:conductor-ai与com.google.adk:google-adk通过AdkBridge.toAgentspan(adkAgent)转换见 Java Google ADK 指南TypeScript/JavaScript即本文所述io-orkes/conductor-javascript/agents的AgentRuntime。遇到运行失败时按 Verify and recover 的顺序排查先核对运行时服务器 URL、框架包与提供商凭据再在 UI 中定位失败任务后重试若 Agent 动作可能产生外部副作用需先明确幂等与恢复策略再重试。更完整的框架桥接参考、维护中的 SDK 示例矩阵与 AGENT 任务契约可继续阅读 Framework Agents 与 Conductor Agents。【免费下载链接】conductorConductor is an event driven agentic workflow engine providing durable and highly resilient execution engine for applications and AI Agents项目地址: https://gitcode.com/GitHub_Trending/co/conductor创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表