Skip to content
LangSmith 文档版本 跟随上游 源快照 e98ff0a8 更新于 2026-10-18

Run

Agent Server 中 run 的概述,包括如何启动后台 run、无状态 run 以及取消 run。

一个 run 是对 assistant 的一次调用。执行 run 时,你需要指定使用哪个 assistant——对于默认 assistant,可以按 graph ID 指定;对于特定配置,可以按 assistant 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

下图展示了 run 如何将 assistant 与 thread 结合以执行 graph:

  • Graph(浅蓝色):包含 agent 逻辑的已部署代码
  • Assistants(蓝色):配置选项(模型、prompt、工具)
  • Threads(橙色):对话历史的状态容器
  • Runs(绿色):将 assistant + thread 配对的执行

组合示例:

  • Run: A1 + T1:将 Assistant 1 配置应用于用户 A 的对话
  • Run: A1 + T2:同一个 assistant 服务于用户 B(不同对话)
  • Run: A2 + T1:将不同的 assistant 应用于用户 A 的对话(切换配置)

执行 run 时:

  • 每个 run 可以有自己的输入、配置覆盖和元数据。
  • Run 可以是无状态的(没有 thread),也可以是有状态的(在 thread 上执行以持久化对话)。
  • 多个 run 可以使用相同的 assistant 配置。
  • Assistant 的配置会影响底层 graph 的执行方式。

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

本节内容


BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。