Skip to main content
如果你已了解 Agent SDK 工作流,并且需要查找准确的公开入口点或选项,请查看此页面。

入口点

智能体方法

流消费者

定义选项

AgentDefinition 包含:
  • id
  • model 或 models
  • preset
  • instructions
  • tools
  • maxSteps 和 stopWhen
  • modelRetry 和 toolExecution
  • temperature、maxOutputTokens 和 topP
  • parseOutput 和 outputSchema
  • requireApproval 和 humanReview
模型、指令和采样字段可以使用固定值或动态值。

运行和继续选项

AgentRunOptions 提供输入、模型客户端、应用上下文、可选覆盖项、取消操作、生命周期钩子、DevTools,以及由应用管理的状态访问器。 AgentContinueOptions 还接受:
  • 之前的 run 或 runId
  • humanInput
  • 按确切的工具调用 ID 批准或拒绝
  • 外部生成的 toolOutputs

结果记录

AgentRunResult 包含:
  • run: 持久运行状态、上下文、暂停详情和停止原因
  • steps: 已保存的模型/工具步骤记录
  • stepResults: 可用时的标准化步骤结果
  • usage: 累计 Token 数和报告的费用
  • output: 解析后的最终输出
  • messages: 循环使用的完整对话
  • items: 按顺序排列的类型化消息、推理、工具活动、错误和最终输出

错误类型

  • AgentGatewayError 描述 Gateway 或上游请求故障。
  • AgentSchemaValidationError 描述无效的工具、进度或最终输出数据。

相关指南

最后修改于 2026年10月2日