Skip to content

This content is not available in your language yet.

客户端通过 GET /sessions/{id}/events 监听 session 实时输出,单向流式推送。

事件触发时机关键字段
run.queuedrun 入队runId
run.startedrun 开始执行runId, agentName
run.progress进度更新runId, step
message.delta流式文本增量runId, content
agent.switch.requested请求切换 agentrunId, fromAgent, toAgent
agent.switched切换完成runId, agentName
agent.delegate.startedsubagent 开始runId, childRunId, agentName
agent.delegate.completedsubagent 完成runId, childRunId
agent.delegate.failedsubagent 失败runId, childRunId, error
tool.startedtool 开始runId, toolName, toolCallId
tool.completedtool 成功runId, toolName, toolCallId
tool.failedtool 失败runId, toolName, error
run.completed正常完成runId
run.failed执行失败runId, errorCode
run.cancelled被取消runId
{ "event": "message.delta",
"data": { "sessionId": "ses_abc", "runId": "run_123", "content": "让我先看看这个文件" } }
{ "event": "tool.completed",
"data": { "sessionId": "ses_abc", "runId": "run_123", "toolName": "Read", "toolCallId": "tc_456", "durationMs": 42 } }
{ "event": "run.completed",
"data": { "sessionId": "ses_abc", "runId": "run_123", "agentName": "builder", "switchCount": 1, "durationMs": 15420 } }
  • cursor 支持断线重连
  • message.delta 需客户端拼接完整文本
  • 监听 run.completed / run.failed / run.cancelled 判断结束
  • 不依赖事件顺序推断状态,以 GET /runs/{id} 为准
节点内容
API 请求入口方法、路径、caller context
run 状态变更queued → running → completed 等
model callmodel_ref、token 用量、延迟
tool calltool_name、执行状态、耗时
action runaction 名、输入、结果
hook runhook 名、事件、决策
backend shell命令、exit code、耗时
workspace local state当前 worker 上的本地状态与诊断信息
字段说明
subject_ref调用方标识
workspace_id / session_id / run_id关联标识
agent_name / effective_agent_nameagent 标识
tool_nametool 名称
duration_ms耗时
status结果状态
  • 审计记录持久化在 PostgreSQL(tool_calls、hook_runs 等表)
  • 结构化日志输出到 stdout,可对接外部系统
  • SSE 事件写入 session_events 表,支持回放和断线重连