数据定义export interface AgentTracingContextV1 {
schemaVersion: "1.0"
trace: {
traceparent: string
tracestate?: string
}
source: {
framework:
| "deepagent"
| "claude-code"
| "openclaw"
| "opencode"
frameworkVersion?: string
adapterVersion?: string
captureMethod:
| "native"
| "plugin"
| "hook"
| "gateway"
| "source-patch"
| "inferred"
confidence:
| "authoritative"
| "correlated"
| "inferred"
}
invocation: {
/**
* 一次顶层应用调用。
* 例如父进程启动一次 claude -p 时生成。
*/
id: string
/**
* 如果当前 invocation 由另一个服务/进程启动。
*/
parentId?: string
}
session: {
/**
* 持久会话 ID。
* DeepAgent 对应 thread_id。
*/
id: string
/**
* Subagent 使用独立 child session 时填写。
*/
parentId?: string
}
turn: {
/**
* 一次用户输入/Prompt 的生命周期。
* Claude Code 对应 prompt_id。
*/
id: string
}
agent: {
/**
* 当前上下文实际属于主智能体还是子智能体。
*/
role: "main" | "subagent" | "system"
/**
* 一次具体 agent 实例/生命周期 ID。
*/
runId: string
/**
* 框架提供的 agent ID。
*/
id?: string
/**
* DeepAgent 的 lc_agent_name,
* Claude Code 的 agent_type。
*/
name?: string
/**
* 父 agent 的生命周期 ID。
*/
parentRunId?: string
/**
* 框架提供的父 agent ID。
*/
parentId?: string
/**
* main=0,直接 subagent=1。
*/
depth: number
/**
* 触发 subagent 的 tool call / delegation ID。
*/
delegationId?: string
/**
* 对于 system 内部调用,它服务于哪个 Agent。
*/
owner?: {
role: "main" | "subagent"
runId?: string
id?: string
name?: string
}
}
operation: {
/**
* 这次 LLM 调用的业务目的。
*/
kind:
| "agent-step"
| "compaction"
| "session-summary"
| "title-generation"
| "hook-model"
| "unknown"
/**
* 压缩触发来源。
*/
trigger?:
| "automatic"
| "manual"
| "context-overflow"
| "tool"
| "framework-internal"
/**
* 谁真正组织了这次模型调用。
*/
executor: {
kind:
| "agent-loop"
| "middleware"
| "framework-internal"
| "system-agent"
name?: string
}
}
context: {
/**
* 当前有效上下文的版本。
* 初始为 0,每次成功压缩后 +1。
*/
epoch: number
/**
* 当前压缩请求完成后将进入哪个 epoch。
*/
targetEpoch?: number
/**
* 当前 LangGraph checkpoint。
*/
checkpointId?: string
checkpointNamespace?: string
/**
* 本次压缩操作 ID。
*/
compactionId?: string
/**
* 链式压缩时指向上一轮压缩。
*/
previousCompactionId?: string
/**
* 压缩前估算 token。
*/
preCompactionTokens?: number
}
llm: {
/**
* 一次逻辑模型调用。
* retry 时保持不变。
*/
callId: string
/**
* HTTP retry 序号,从 1 开始。
*/
attempt: number
/**
* 每次 HTTP attempt 独立 ID。
*/
attemptId: string
provider?: string
model?: string
api?: string
streaming?: boolean
}
native?: Record<string, string | number | boolean | null>
}