以编程方式使用文档

A _运行_ 是对 助手的调用。当您执行运行时,您需要指定使用哪个助手——可以是默认助手(通过图形 ID),也可以是特定配置(通过助手 ID)。

flowchart TB
    subgraph deploy[Deployment]
        G[Graph Code<br/>━━━━━━━━━<br/>Deployed logic]
    end

    subgraph config[Configuration]
        A1[Assistant 1<br/>GPT-4, Formal]
        A2[Assistant 2<br/>Claude, Casual]
    end

    subgraph state[State]
        T1[Thread 1<br/>User A]
        T2[Thread 2<br/>User B]
    end

    subgraph runs[Runs]
        A1T1["Run: A1 + T1"]
        A1T2["Run: A1 + T2"]
        A2T1["Run: A2 + T1"]
    end

    A1 -.-> T1
    A1 -.-> T2
    A2 -.-> T1

    A1T1 --> G
    A1T2 --> G
    A2T1 --> G

    style G fill:#E5F4FF,stroke:#006DDD,stroke-width:2px,color:#030710
    style A1 fill:#B3E0F2,stroke:#4A90E2,stroke-width:2px,color:#1E3A5F
    style A2 fill:#B3E0F2,stroke:#4A90E2,stroke-width:2px,color:#1E3A5F
    style T1 fill:#FFE0B3,stroke:#7E65AE,stroke-width:2px,color:#504B5F
    style T2 fill:#FFE0B3,stroke:#7E65AE,stroke-width:2px,color:#504B5F
    style A1T1 fill:#B3F2C9,stroke:#10B981,stroke-width:2px,color:#2E3900
    style A1T2 fill:#B3F2C9,stroke:#10B981,stroke-width:2px,color:#2E3900
    style A2T1 fill:#B3F2C9,stroke:#10B981,stroke-width:2px,color:#2E3900

此图展示了 **运行** 如何将助手与线程结合以执行图形:

  • 图形 (浅蓝色):包含代理逻辑的已部署代码
  • 助手 (蓝色):配置选项(模型、提示词、工具)
  • 线程 (橙色):用于对话历史的状态容器
  • 运行 (绿色):将助手 + 线程配对执行的执行

示例组合: - **运行: A1 + T1**: 已将助手1配置应用于用户A的对话 - **运行: A1 + T2**: 同一助手服务用户B(不同对话) - **运行: A2 + T1**: 已将不同助手应用于用户A的对话(配置切换)

执行运行时:

  • - 每个运行可以有自己的输入、配置覆盖和元数据。
  • - 运行可以是无状态的(无线程)或状态化的(在 线程 上执行以实现对话持久化)。
  • - 多个运行可以使用相同的助手配置。
  • - 助手的配置会影响底层图的执行方式。

Agent Server API 提供了多个用于创建和管理运行的端点。更多详情请参阅 API 参考文档.

本节内容

Kick off background runs

异步运行您的代理并轮询获取结果。

Run multiple agents on the same thread

在共享线程上使用多个助手以组合代理能力。

Stateless runs

当不需要对话历史时,执行不持久化状态的运行。

Cancel a run

通过 API 取消单个或多个运行。