Skip to main content
Skip to content

流式处理会话事件

Copilot 代理执行的每个操作——思考、编写代码、运行工具——都会以 session 事件 的形式发出,供你订阅。 本指南是每个事件类型的字段级参考,因此你确切地知道在未读取 SDK 源的情况下预期的数据。

概述

对会话设置 streaming: true 时,SDK 会实时发出临时事件(增量、进度更新)以及持久事件(完整的消息、工具结果)。 所有事件共享一个公用信封,并携带一个载荷,其形状取决于事件 data。

关系图:显示描述的过程的序列图。

概念Description
临时事件瞬时; 实时流传,但不持久保存到会话日志。 会话恢复时未重播。
持久化事件保存到磁盘上的会话事件日志。 恢复会话时重播。
Delta 事件临时流式处理块(文本或推理)。 累积增量以生成完整内容。
parentId 链每个事件的 parentId 都指向上一个事件,形成一个可以遍历的链接列表。

事件封装

无论类型如何,每个会话事件都包含以下字段:

领域类型Description
id
string (UUID v4)唯一事件标识符
timestamp
string (ISO 8601)创建事件时
parentIdstring | null链中上一个事件的 ID;对于第一个事件使用 null
agentIdstring?由子代理发起的事件的子代理实例 ID;在根/主代理和会话级事件中不存在
ephemeralboolean?
true(适用于临时事件);缺失或 false(适用于持久化事件)
typestring事件类型鉴别器(请参阅下表)
dataobject特定于事件的有效负载

订阅事件

代码语言 navigation

TypeScript
// All events
session.on((event) => {
    console.log(event.type, event.data);
});

// Specific event type — data is narrowed automatically
session.on("assistant.message_delta", (event) => {
    process.stdout.write(event.data.deltaContent);
});

提示

(Python/Go) 这些 SDK 使用单独的每个事件数据类型(例如AssistantMessageDeltaData),因此每个类型上仅存在相关字段。

(.NET) .NET SDK 为每个事件使用单独的强类型数据类(例如,AssistantMessageDeltaData),因此每个类型上仅存在相关字段。

(TypeScript) TypeScript SDK 使用可区分的联合 - 当你根据 event.type 匹配时,data 有效负载会自动缩小到正确的形状。

会话开始前订阅

会话可以在创建或恢复调用返回之前发出事件。 代理可能已经在运行——尤其是在使用 continuePendingWork 恢复时——而且诸如 session.idle 之类的瞬时事件绝不会写入会话日志,因此 getMessages 之后也无法恢复它们。 在会话句柄创建之后安装的订阅会错过该启动时机。

提示

(Rust)Client::prepare_session 和 Client::prepare_resume_session 会返回一个 PreparedSession,它在发生任何协议活动之前拥有该会话的事件通道。 首先订阅,然后调用 start()。

use github_copilot_sdk::{Client, SessionConfig};

async fn create_without_missing_startup_events(
    client: &Client,
) -> Result<(), github_copilot_sdk::Error> {
    let prepared = client.prepare_session(
        SessionConfig::default().with_event_buffer_capacity(2048),
    )?;

    // Installed before any wire activity: nothing is dropped for lack of a receiver.
    let mut events = prepared.subscribe();
    tokio::spawn(async move {
        while let Ok(event) = events.recv().await {
            println!("{}", event.event_type);
        }
    });

    let session = prepared.start().await?;
    let _ = session;
    Ok(())
}

prepare_* 是同步且惰性的:它会验证缓冲区容量、分配一个本地通道,而不会执行任何其他操作。 尚未注册任何会话,在首次轮询 start() 之前,CLI 不会收到任何内容。 丢弃一个已准备但从未启动的会话,不会留下任何状态,并会关闭其订阅;丢弃 start() Future 会取消正在进行的启动过程并注销该会话,因此,使用相同的会话 ID 重试会成功。 清理的范围限定为放弃的启动拥有的确切注册,因此无法逐出已接管同一会话 ID 的重试。

启动缓冲值得提前规划:

  • 事件缓冲区是有限的— 512 个事件,除非 event_buffer_capacity 重写它。 容量 0 被拒绝,并出现无效配置错误,而不是固定。
  • 处理速度较慢的订阅者会看到一个 Lagged 错误,其中会报告跳过了多少个事件。 它们永远不会对会话的事件循环应用反压。
  • 需要无损地查看启动时的大量突发数据的使用方,必须配置足以覆盖该突发的容量,或者与 start() 同时并行排空订阅中的数据。

注意

对于服务器分配会话 ID 的云会话,在创建响应到达且 ID 已知之前,SDK 无法路由通知。 在该点之前发出的事件无法路由到任何会话。 这一保证的范围更窄:路由事件绝不会因为未安装接收器而被丢弃。 在配置中固定 session_id,即可从第一个字节开始获得路由,以及响应前的完整覆盖。

仅显示父代理响应

子代理事件共享父会话流,并包括信封级别的 agentId。 根代理/主代理事件和会话级事件会省略 agentId,因此主聊天渲染器可以忽略已设置 agentId 的助手事件,并将这些事件转而路由到跟踪界面或进度界面。

代码语言 navigation

TypeScript
import type { CopilotSession } from "@github/copilot-sdk";

export function subscribeParentResponse(session: CopilotSession): void {
    session.on("assistant.message_delta", (event) => {
        if (!event.agentId) {
            process.stdout.write(event.data.deltaContent);
        }
    });
}

助理活动

这些事件会跟踪代理的响应生命周期 - 从轮次开始,经过流式处理块,直到最终消息。

assistant.turn_start

代理开始处理轮次时已发出。

数据字段类型必需Description
turnIdstring✅轮次标识符(通常是字符串化的轮次编号)
interactionIdstring
用于遥测关联的 CAPI 交互 ID

assistant.intent

短暂。 代理当前正在执行的操作的简短描述,随着其工作的进行而更新。

数据字段类型必需Description
intentstring✅人类可读的意图(例如“浏览代码库”)

assistant.reasoning

从模型中得出完整的扩展思维定式。 推理完成后发出。

数据字段类型必需Description
reasoningIdstring✅此推理块的唯一标识符
contentstring✅完整的扩展思维文本

assistant.reasoning_delta

短暂。 实时流式处理的模型扩展思维增量区块。

数据字段类型必需Description
reasoningIdstring✅匹配相应的 assistant.reasoning 事件
deltaContentstring✅要附加到推理内容的文本区块

assistant.message

此 LLM 调用的助手完整响应。 可能包括工具调用请求。

数据字段类型必需Description
messageIdstring✅此消息的唯一标识符
contentstring✅助手的文本响应
toolRequestsToolRequest[]
助理拟进行的工具调用(请参阅下文)
reasoningOpaquestring
加密扩展思维(人类模型):会话绑定
reasoningTextstring
扩展思维中的可读推理文本
encryptedContentstring
加密推理内容(OpenAI 模型):会话绑定
phasestring
生成阶段(例如, "thinking" vs "response")
outputTokensnumber
来自 API 响应的实际输出令牌计数
interactionIdstring
用于遥测的 CAPI 交互 ID
parentToolCallIdstring
Deprecated. 使用信封层级 agentId 进行子代理归因

** ToolRequest 领域:**

领域类型必需Description
toolCallIdstring✅此工具调用的唯一 ID
namestring✅工具名称(例如, "bash"、 "edit"、 "grep")
argumentsobject
用于工具的解析参数
type"function" | "custom"
调用类型;如果缺失,默认为"function"

assistant.message_delta

短暂。 实时流式处理的助理文本响应的增量区块。

数据字段类型必需Description
messageIdstring✅匹配相应的 assistant.message 事件
deltaContentstring✅要追加到消息的文本片段
parentToolCallIdstring
Deprecated. 使用信封层级 agentId 进行子代理归因

assistant.turn_end

代理完成轮次时发出(所有工具执行完成,最终响应已传递)。

数据字段类型必需Description
turnIdstring✅匹配相应的 assistant.turn_start 事件

assistant.usage

短暂。 单个 API 调用的令牌使用情况和成本信息。

数据字段类型必需Description
modelstring✅模型标识符(例如 "gpt-5.4")
inputTokensnumber
消耗的输入令牌
outputTokensnumber
生成的输出令牌
reasoningTokensnumber
用于推理/思维链的输出令牌(属于 outputTokens 的子集)
cacheReadTokensnumber
从提示缓存中读取的令牌
cacheWriteTokensnumber
写入提示缓存的令牌
cacheExpiresAtstring
此模型调用的提示缓存过期时的 ISO 8601 时间戳
contentFilterTriggeredboolean
响应是被内容筛选阻止还是被截断(finish_reason === 'content_filter')
finishReasonstring
模型结束原因(例如:"stop"、"length"、"tool_calls"、"content_filter")
costnumber
计费的模型乘数成本
durationnumber
API 调用持续时间(以毫秒为单位)
timeToFirstTokenMsnumber
从请求发出到收到首个令牌的时间(流式延迟)
interTokenLatencyMsnumber
连续令牌之间的平均延迟(流式处理吞吐量)
reasoningEffortstring
此次调用使用的推理工作量级别(例如:"low"、"medium"、"high")
initiatorstring
触发此次调用的原因(例如 "sub-agent");如果是用户发起的,则为空
apiCallIdstring
提供程序的完成 ID(例如 chatcmpl-abc123)
serviceRequestIdstring
用于关联 CAPI 日志的 Copilot 服务请求 ID(x-copilot-service-request-id)
apiEndpoint"/chat/completions" | "/v1/messages" | "/responses" | "ws:/responses"
用于模型调用的 API 终结点;对于可观测性和成本归因非常有用。
ws:/responses 是响应 API 的 Websocket 变体
providerCallIdstring
GitHub请求跟踪 ID (x-github-request-id)
parentToolCallIdstring
Deprecated. 使用信封层级 agentId 进行子代理归因
quotaSnapshotsRecord<string, QuotaSnapshot>
按配额标识符记录的每个配额的资源使用情况
copilotUsageCopilotUsage
API 中的分项令牌成本明细

assistant.streaming_delta

短暂。 低级别网络进度指示器 - 从流式处理 API 响应接收的总字节数。

数据字段类型必需Description
totalResponseSizeBytesnumber✅到目前为止收到的累积字节数

工具执行事件

这些事件跟踪每个工具调用的完整生命周期,从模型请求工具调用到执行和结束。

tool.execution_start

当工具开始执行时发出。

数据字段类型必需Description
toolCallIdstring✅此工具调用的唯一标识符
toolNamestring✅工具的名称(例如,"bash", "edit"``"grep")
argumentsobject
传递给工具的已分析参数
mcpServerNamestring
MCP 服务器名称,当 MCP 服务器提供该工具时
mcpToolNamestring
MCP 服务器上的原始工具名称
parentToolCallIdstring
Deprecated. 使用信封层级 agentId 进行子代理归因

tool.execution_partial_result

短暂。 运行中工具的增量输出(例如 bash 的流式输出)。

数据字段类型必需Description
toolCallIdstring✅匹配相应的 tool.execution_start
partialOutputstring✅增量输出区块

tool.execution_progress

短暂。 由运行中的工具提供的人类可读的进度状态(例如 MCP 服务器进度通知)。

数据字段类型必需Description
toolCallIdstring✅匹配相应的 tool.execution_start
progressMessagestring✅进度状态消息

tool.execution_complete

当工具完成执行时发出 — 成功或出错。

数据字段类型必需Description
toolCallIdstring✅匹配相应的 tool.execution_start
successboolean✅执行是否成功
modelstring
生成此工具调用的模型
interactionIdstring
CAPI 交互标识
isUserRequestedboolean
true 当用户显式请求此工具调用时
resultResult
成功时显示(请参阅下文)
error{ message, code? }
失败时显示
toolTelemetryobject
工具特定的遥测数据(例如,CodeQL 检查次数)
parentToolCallIdstring
Deprecated. 使用信封层级 agentId 进行子代理归因

** Result 领域:**

领域类型必需Description
contentstring✅发送给 LLM 的简明结果(可能为令牌效率截断)
detailedContentstring
显示的完整结果,保留差异等完整内容
contentsContentBlock[]
结构化内容块(文本、终端、图像、音频、资源)

tool.user_requested

当用户显式请求工具调用(而不是由模型选择调用时)发出。

数据字段类型必需Description
toolCallIdstring✅此工具调用的唯一标识符
toolNamestring✅用户要调用的工具的名称
argumentsobject
函数调用的参数

会话生命周期事件

session.idle

短暂。 代理已完成所有处理,并已准备好下一条消息。 这是转弯已完全完成的信号。

数据字段类型必需Description
abortedboolean
当前一轮通过中止信号取消时为真

session.error

会话处理期间出错。

数据字段类型必需Description
errorTypestring✅错误类别(例如,"authentication"、、 "quota"``"rate_limit")
messagestring✅用户可读的错误消息
stackstring
错误堆栈跟踪
statusCodenumber
来自上游请求的 HTTP 状态代码
providerCallIdstring
用于服务器端日志关联的 GitHub 请求跟踪 ID

session.compaction_start

上下文窗口压缩已经开始。 数据有效负载为空 ({}) 。

session.compaction_complete

上下文窗口压缩已完成。

数据字段类型必需Description
successboolean✅压缩是否成功
errorstring
压缩失败时出现错误消息
preCompactionTokensnumber
压缩前的令牌
postCompactionTokensnumber
压缩后的令牌
preCompactionMessagesLengthnumber
压缩前的消息计数
messagesRemovednumber
已删除邮件
tokensRemovednumber
已删除令牌
summaryContentstring
LLM 生成的压缩历史记录摘要
checkpointNumbernumber
为恢复创建的检查点快照编号
checkpointPathstring
存储检查点的文件路径
compactionTokensUsed{ input, output, cachedInput }
压缩LLM调用中的令牌使用情况
requestIdstring
GitHub 请求跟踪 ID(用于压缩调用)

session.title_changed

短暂。 会话自动生成的标题已更新。

数据字段类型必需Description
titlestring✅新会话标题

session.context_changed

会话的工作目录或存储库上下文已更改。

数据字段类型必需Description
cwdstring✅当前工作目录
gitRootstring
Git 存储库根目录
repositorystring
"owner/name" 格式的存储库
branchstring
当前 Git 分支

session.usage_info

短暂。 上下文窗口利用率快照。

数据字段类型必需Description
tokenLimitnumber✅模型上下文窗口的最大标记数
currentTokensnumber✅上下文窗口中的当前标记
messagesLengthnumber✅对话中的当前消息计数

session.session_limits_changed

当前会计窗口的会话限制已更改。 值 null``sessionLimits 表示没有活动限制。

数据字段类型必需Description
sessionLimitsSessionLimitsConfig | null✅当前会话限制;如果当前没有生效的限制,则为 null
sessionLimits.maxAiCreditsnumber
当前会话计费窗口内允许的最大 AI 积分

session.usage_checkpoint

用于在会话恢复时重建计费信息的持久累计使用量检查点。

数据字段类型必需Description
totalNanoAiunumber✅检查点时整个会话范围内累计的 nano-AI 单位成本
totalPremiumRequestsnumber
检查点时使用的高级 API 请求总数

session.task_complete

代理已完成其分配的任务。

数据字段类型必需Description
summarystring
已完成任务的摘要

session.shutdown

会话已结束。

数据字段类型必需Description
shutdownType"routine" | "error"✅正常关闭或崩溃
errorReasonstring
shutdownType 为 "error" 时的错误描述
totalPremiumRequestsnumber✅使用的高级 API 请求总数
totalApiDurationMsnumber✅累积 API 调用时间(以毫秒为单位)
sessionStartTimenumber✅会话启动时的 Unix 时间戳 (ms)
codeChanges{ linesAdded, linesRemoved, filesModified }✅代码更改的聚合指标
modelMetricsRecord<string, ModelMetric>✅按模型使用情况细分
currentModelstring
关闭时选择的模型

权限和用户输入事件

在继续操作之前,当代理需要用户批准或输入时,将发出这些事件。

permission.requested

代理需要权限才能执行操作(运行命令、写入文件等)。

数据字段类型必需Description
requestIdstring✅使用该功能通过 session.respondToPermission() 进行响应
permissionRequestPermissionRequest✅正在请求的权限的详细信息

permissionRequest 是 kind 上的可区分联合:

kind关键字段Description
"shell"
fullCommandText、intention、commands[]、possiblePaths[]执行 shell 命令
"write"
fileName、diff、intention、newFileContents?写入/修改文件
"read"
path、intention读取文件或目录
"mcp"
serverName、toolName、toolTitle、args?、readOnly调用 MCP 工具
"url"
url、intention获取 URL
"memory"
subject、fact、citations存储记忆
"custom-tool"
toolName、toolDescription、args?调用自定义工具

所有 kind 变体均包含一个可选的 toolCallId 链接,其指向触发请求的工具调用。

permission.completed

权限请求已解决。

数据字段类型必需Description
requestIdstring✅匹配相应的 permission.requested
result.kindstring✅其中之一:"approved"、、"denied-by-rules"``"denied-interactively-by-user"、"denied-no-approval-rule-and-could-not-request-from-user"、"denied-by-content-exclusion-policy"

user_input.requested

短暂。 代理正在向用户提问。

数据字段类型必需Description
requestIdstring✅使用该功能通过 session.respondToUserInput() 进行响应
questionstring✅向用户呈现的问题
choicesstring[]
用户的预定义选项
allowFreeformboolean
是否允许自由格式文本输入

user_input.completed

短暂。 解决了用户输入请求。

数据字段类型必需Description
requestIdstring✅匹配相应的 user_input.requested

elicitation.requested

短暂。 代理需要用户(MCP 引证协议)的结构化表单输入。

数据字段类型必需Description
requestIdstring✅使用该功能通过 session.respondToElicitation() 进行响应
messagestring✅所需信息的说明
mode"form"
启发模式(当前仅 "form")
requestedSchema{ type: "object", properties, required? }✅描述窗体字段的 JSON 架构

elicitation.completed

短暂。 启发请求已解决。

数据字段类型必需Description
requestIdstring✅匹配相应的 elicitation.requested

子代理和技能事件

subagent.started

自定义代理被调用为子代理。

数据字段类型必需Description
toolCallIdstring✅生成此子代理的父工具调用
agentNamestring✅子代理的内部名称
agentDisplayNamestring✅人工可读的显示名称
agentDescriptionstring✅子代理的作用说明
modelstring
如果在开始时已知,子智能体将使用的模型

subagent.completed

子代理成功完成。

数据字段类型必需Description
toolCallIdstring✅匹配相应的 subagent.started
agentNamestring✅内部名称
agentDisplayNamestring✅显示名称
modelstring
子代理使用的模型
durationMsnumber
时钟执行持续时间(以毫秒为单位)
totalTokensnumber
使用的输入和输出令牌总数
totalToolCallsnumber
工具调用总次数

subagent.failed

子代理遇到错误。

数据字段类型必需Description
toolCallIdstring✅匹配相应的 subagent.started
agentNamestring✅内部名称
agentDisplayNamestring✅显示名称
errorstring✅错误消息
modelstring
为子代理选择的模型(如果已知)
durationMsnumber
时钟执行持续时间(以毫秒为单位)
totalTokensnumber
失败前使用的输入和输出令牌总数
totalToolCallsnumber
失败前的工具调用总数

subagent.selected

已选择自定义代理(推断)来处理当前请求。

数据字段类型必需Description
agentNamestring✅所选代理的内部名称
agentDisplayNamestring✅显示名称
toolsstring[] | null✅此代理可用的工具名称; null 适用于所有工具

subagent.deselected

取消了自定义代理的选择,返回到默认代理。 数据有效负载为空 ({}) 。

skill.invoked

为当前对话激活了技能。

数据字段类型必需Description
namestring✅技能名称
pathstring✅SKILL.md 定义的文件路径
contentstring✅将完整的技能内容注入到对话中
allowedToolsstring[]
此技能处于活动状态时自动批准的工具
pluginNamestring
技能的来源插件
pluginVersionstring
插件版本

其他事件

abort

当前轮次已中止。

数据字段类型必需Description
reasonstring✅为什么轮次被中止 (例如, "user initiated")

user.message

用户发送了一条消息。 已针对会话时间线进行记录。

数据字段类型必需Description
contentstring✅用户的消息内容
transformedContentstring
预处理后的转换版本
attachmentsAttachment[]
文件、目录、选定内容、Blob 或 GitHub 引用附件
sourcestring
消息源标识符
agentModestring
代理模式:"interactive"、、"plan"``"autopilot"或"shell"
interactionIdstring
CAPI 交互标识

system.message

系统或开发人员提示已注入对话。

数据字段类型必需Description
contentstring✅提示文本
role"system" | "developer"✅消息角色
namestring
源标识符
metadata{ promptVersion?, variables? }
提示模板元数据

external_tool.requested

代理想要调用外部工具(由 SDK 使用者提供)。

数据字段类型必需Description
requestIdstring✅使用该功能通过 session.respondToExternalTool() 进行响应
sessionIdstring✅此请求所属的会话
toolCallIdstring✅此调用的工具 ID
toolNamestring✅外部工具的名称
argumentsobject
工具参数

external_tool.completed

解决了外部工具请求。

数据字段类型必需Description
requestIdstring✅匹配相应的 external_tool.requested

exit_plan_mode.requested

短暂。 代理已创建计划并想要退出计划模式。

数据字段类型必需Description
requestIdstring✅使用该功能通过 session.respondToExitPlanMode() 进行响应
summarystring✅计划摘要
planContentstring✅完整计划文件内容
actionsstring[]✅可用的用户操作(例如批准、编辑、拒绝)
recommendedActionstring✅建议的操作

exit_plan_mode.completed

短暂。 已解决退出计划模式请求。

数据字段类型必需Description
requestIdstring✅匹配相应的 exit_plan_mode.requested

command.queued

短暂。 斜杠命令已排队执行。

数据字段类型必需Description
requestIdstring✅使用该功能通过 session.respondToQueuedCommand() 进行响应
commandstring✅斜杠命令文本(例如, /help``/clear)

command.completed

短暂。 排队的命令已解决。

数据字段类型必需Description
requestIdstring✅匹配相应的 command.queued

session_limits_exhausted.requested

短暂。 当前会话预算已用尽,运行时需要在继续之前做出用户决策。

数据字段类型必需Description
requestIdstring✅在响应待处理的限额耗尽请求时,请使用此 ID
maxAiCreditsnumber✅为当前会计窗口配置了最大 AI 信用额度
usedAiCreditsnumber✅当前计费周期内已消耗的 AI 点数

session_limits_exhausted.completed

短暂。 一个待处理的超限请求已解决。

数据字段类型必需Description
requestIdstring✅匹配相应的 session_limits_exhausted.requested 事件
response.action"add" | "set" | "unset" | "cancel"✅为已用尽限制请求选择的操作
response.additionalAiCreditsnumber
要添加到当前最大值的 AI 积分,如果 response.action 为 "add"
response.maxAiCreditsnumber
当 response.action 为 "set" 时,AI 积分的绝对最大上限

快速参考:智能回合流程

典型的代理行为轮次按以下顺序触发事件:

assistant.turn_start          → Turn begins
├── assistant.intent          → What the agent plans to do (ephemeral)
├── assistant.reasoning_delta → Streaming thinking chunks (ephemeral, repeated)
├── assistant.reasoning       → Complete thinking block
├── assistant.message_delta   → Streaming response chunks (ephemeral, repeated)
├── assistant.message         → Complete response (may include toolRequests)
├── assistant.usage           → Token usage for this API call (ephemeral)
│
├── [If tools were requested:]
│   ├── permission.requested  → Needs user approval
│   ├── permission.completed  → Approval result
│   ├── tool.execution_start  → Tool begins
│   ├── tool.execution_partial_result  → Streaming tool output (ephemeral, repeated)
│   ├── tool.execution_progress        → Progress updates (ephemeral, repeated)
│   ├── tool.execution_complete        → Tool finished
│   │
│   └── [Agent loops: more reasoning → message → tool calls...]
│
assistant.turn_end            → Turn complete
session.idle                  → Ready for next message (ephemeral)

所有事件类型一目了然

此表列出了关键 data 有效负载字段。 上面记录了常见的信封字段。

事件类型临时类别关键数据字段
assistant.turn_start
助手
turnId、interactionId?
assistant.intent✅助手intent
assistant.reasoning
助手
reasoningId、content
assistant.reasoning_delta✅助手
reasoningId、deltaContent
assistant.streaming_delta✅助手totalResponseSizeBytes
assistant.message
助手
messageId、content、toolRequests?、outputTokens?、phase?
assistant.message_delta✅助手
messageId、deltaContent
assistant.turn_end
助手turnId
assistant.usage✅助手
model、apiEndpoint?、inputTokens?、outputTokens?、cost?、duration?
tool.user_requested
工具
toolCallId、toolName、arguments?
tool.execution_start
工具
toolCallId、toolName、arguments?、mcpServerName?
tool.execution_partial_result✅工具
toolCallId、partialOutput
tool.execution_progress✅工具
toolCallId、progressMessage
tool.execution_complete
工具
toolCallId、success、result?、error?
session.idle✅Sessionaborted?
session.error
Session
errorType、message、statusCode?
session.compaction_start
Session
(空)
session.compaction_complete
Session
success、preCompactionTokens?、summaryContent?
session.title_changed✅Sessiontitle
session.context_changed
Session
cwd、gitRoot?、repository?、branch?
session.usage_info✅Session
tokenLimit、currentTokens、messagesLength
session.session_limits_changed
SessionsessionLimits
session.usage_checkpoint
Session
totalNanoAiu、totalPremiumRequests?
session.task_complete
Sessionsummary?
session.shutdown
Session
shutdownType、codeChanges、modelMetrics
permission.requested
许可
requestId、permissionRequest
permission.completed
许可
requestId、result.kind
user_input.requested✅用户输入
requestId、question、choices?
user_input.completed✅用户输入requestId
elicitation.requested✅用户输入
requestId、message、requestedSchema
elicitation.completed✅用户输入requestId
subagent.started
子代理
toolCallId、agentName、agentDisplayName、model?
subagent.completed
子代理
toolCallId、agentName、agentDisplayName、model?、durationMs?、totalTokens?、totalToolCalls?
subagent.failed
子代理
toolCallId、agentName、error、model?、durationMs?、totalTokens?、totalToolCalls?
subagent.selected
子代理
agentName、agentDisplayName、tools
subagent.deselected
子代理
(空)
skill.invoked
技能
name、path、content、allowedTools?
abort
控件reason
user.message
User
content、attachments?、agentMode?
system.message
系统
content、role
external_tool.requested
外部工具
requestId、toolName、arguments?
external_tool.completed
外部工具requestId
command.queued✅命令
requestId、command
command.completed✅命令requestId
session_limits_exhausted.requested✅Session
requestId、maxAiCredits、usedAiCredits
session_limits_exhausted.completed✅Session
requestId、response.action
exit_plan_mode.requested✅计划模式
requestId、summary、planContent、actions
exit_plan_mode.completed✅计划模式requestId