ag-ui

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AG-UI

AG-UI

Use this skill to implement AG-UI compliant integrations with correct event ordering, tool lifecycle behavior, and state synchronization semantics.
使用本Skill实现符合AG-UI规范的集成,确保正确的事件顺序、工具生命周期行为和状态同步语义。

Quick Triage

快速分类

  • Use this skill when the task is protocol-level integration between agent backend and UI client.
  • Switch to
    $langgraph
    when graph orchestration/checkpoint logic is the primary issue.
  • Switch to
    $langchain
    when chain or tool orchestration internals are the primary issue.
  • Switch to
    $copilotkit
    when CopilotKit hooks/provider behavior is primary.
  • 当任务涉及Agent后端与UI客户端之间的协议级集成时,使用本Skill。
  • 若主要问题是图编排/检查点逻辑,请切换至
    $langgraph
  • 若主要问题是链或工具编排内部逻辑,请切换至
    $langchain
  • 若主要问题是CopilotKit钩子/提供者行为,请切换至
    $copilotkit

Workflow

工作流程

  1. Define integration mode. Choose client-side
    HttpAgent
    , custom
    AbstractAgent
    , or middleware bridge.
  2. Lock event subset and ordering. Map required lifecycle, text, tool, and state events before implementation.
  3. Implement lifecycle first. Guarantee
    RUN_STARTED
    and
    RUN_FINISHED/RUN_ERROR
    framing around all runs.
  4. Implement message and tool streams. Ensure tool call start/args/end/result sequence is valid and complete.
  5. Implement state synchronization. Choose snapshot-only, delta-only, or hybrid strategy intentionally.
  6. Add middleware with explicit order. Enforce auth, filtering, and logging without mutating protocol invariants.
  7. Validate against event traces. Use deterministic replay to confirm ordering and payload shape.
  1. 定义集成模式。 选择客户端侧
    HttpAgent
    、自定义
    AbstractAgent
    或中间件桥接方式。
  2. 锁定事件子集与顺序。 在实现前映射所需的生命周期、文本、工具和状态事件。
  3. 优先实现生命周期逻辑。 确保所有运行都被
    RUN_STARTED
    RUN_FINISHED/RUN_ERROR
    事件包裹。
  4. 实现消息与工具流。 确保工具调用的启动/参数/结束/结果序列有效且完整。
  5. 实现状态同步。 有意选择仅快照、仅增量或混合策略。
  6. 添加具有明确顺序的中间件。 在不修改协议不变量的前提下,实施认证、过滤和日志记录。
  7. 基于事件轨迹进行验证。 使用确定性重放来确认事件顺序和负载格式。

Default Patterns

默认模式

  • Emit minimal valid event streams rather than custom ad-hoc payloads.
  • Keep tool result payloads parseable and bounded.
  • Prefer explicit event schemas over inferred client parsing.
  • Keep protocol payloads transport-agnostic.
  • 生成最小的有效事件流,而非自定义的临时负载。
  • 保持工具结果负载可解析且大小受限。
  • 优先使用明确的事件模式,而非让客户端自行推断解析。
  • 保持协议负载与传输方式无关。

Failure Modes

故障模式

  • Out-of-order lifecycle or tool events.
  • Partial tool-call streams without terminal result events.
  • State delta application mismatch on client.
  • Middleware mutating payloads into non-compliant shapes.
  • 生命周期或工具事件顺序混乱。
  • 工具调用流不完整,缺少终端结果事件。
  • 客户端侧状态增量应用不匹配。
  • 中间件将负载修改为不符合规范的格式。

Reference Map

参考映射

Load only what is needed for the current subtask.
  • Event contracts:
    references/event-contracts.md
  • State sync strategy:
    references/state-sync.md
  • Middleware usage:
    references/middleware-patterns.md
  • Integration checklist:
    references/integration-checklist.md
仅加载当前子任务所需的内容。
  • 事件契约:
    references/event-contracts.md
  • 状态同步策略:
    references/state-sync.md
  • 中间件使用:
    references/middleware-patterns.md
  • 集成检查清单:
    references/integration-checklist.md