> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 运行

> Agent Server 中运行的概述，包括如何启动后台运行、无状态运行以及取消运行。

一次 *运行* 是对[助手](/langsmith/assistants)的调用。当您执行一次运行时，您需要指定使用哪个助手——可以通过图 ID 指定默认助手，或通过助手 ID 指定特定配置。

```mermaid actions={false} theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
flowchart TB
    subgraph deploy[部署]
        G[图代码<br/>━━━━━━━━━<br/>已部署的逻辑]
    end

    subgraph config[配置]
        A1[助手 1<br/>GPT-4, 正式]
        A2[助手 2<br/>Claude, 随意]
    end

    subgraph state[状态]
        T1[线程 1<br/>用户 A]
        T2[线程 2<br/>用户 B]
    end

    subgraph runs[运行]
        A1T1["运行: A1 + T1"]
        A1T2["运行: A1 + T2"]
        A2T1["运行: 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 的对话（配置切换）

执行运行时：

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

Agent Server API 提供了多个端点用于创建和管理运行。更多详情，请参阅 [API 参考](/langsmith/server-api-ref)。

## 本节内容

<CardGroup cols={2}>
  <Card title="启动后台运行" icon="player-play" href="/langsmith/background-run">
    异步运行您的智能体并轮询结果。
  </Card>

  <Card title="在同一运行多个智能体" icon="messages" href="/langsmith/same-thread">
    在共享线程上使用多个助手以组合智能体能力。
  </Card>

  <Card title="无状态运行" icon="player-skip-forward" href="/langsmith/stateless-runs">
    当不需要对话历史时，执行不持久化状态的运行。
  </Card>

  <Card title="取消运行" icon="player-stop" href="/langsmith/cancel-run">
    通过 API 取消单个或多个运行。
  </Card>
</CardGroup>

***

<div className="source-links">
  <Callout icon="terminal-2">
    [连接这些文档](/use-these-docs)到 Claude、VSCode 等，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/langsmith/runs.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
