Add the context assembly observation to the run-completed payload

Details (original message):
Add the context assembly observation to the run-completed payload (items, truncations, estimated size).
This commit is contained in:
weichen
2026-09-29 18:26:44 +00:00
parent aa53004376
commit 95294268d8
4 changed files with 40 additions and 1 deletions
+8
View File
@@ -177,3 +177,11 @@ func contains(s, sub string) bool {
return false
})()
}
func TestGoldenContextObservation(t *testing.T) {
golden(t, "context_observation", ContextObservation{
Items: []string{"system(画像)", "history(12)", "attachments(1)", "knowledge(3)"},
Truncations: []string{"历史 47 条超窗口 40,仅保留最近部分", "工具结果超长,转工件引用"},
EstChars: 18234,
})
}
+9
View File
@@ -110,6 +110,15 @@ type ArtifactPayload struct {
type RunCompletedPayload struct {
Usage Usage `json:"usage"`
// Context 为该次运行的上下文组装观测(4.10/4.17:构成 + 裁剪记录;可解释性)。
Context *ContextObservation `json:"context,omitempty"`
}
// ContextObservation 记录一次模型输入的实际构成与预算裁剪(ctxasm 产出)。
type ContextObservation struct {
Items []string `json:"items"` // 如 system(画像) / history(12) / attachments(1) / knowledge(3)
Truncations []string `json:"truncations,omitempty"` // 裁剪记录(历史超窗/工具结果超限/附件截断)
EstChars int `json:"estChars"` // 估算输入字符量
}
type RunFailedPayload struct {
+13
View File
@@ -0,0 +1,13 @@
{
"items": [
"system(画像)",
"history(12)",
"attachments(1)",
"knowledge(3)"
],
"truncations": [
"历史 47 条超窗口 40,仅保留最近部分",
"工具结果超长,转工件引用"
],
"estChars": 18234
}
+10 -1
View File
@@ -93,7 +93,16 @@ export interface AgentSpawnPayload { agentRun: ID; name: string; task: string }
export interface AgentProgressPayload { agentRun: ID; note?: string; phase?: RunPhase }
export interface AgentResultPayload { agentRun: ID; status: RunStatus; summary?: string }
export interface HITLResolvedPayload { cardId: ID; answer?: string; kind: 'choice' | 'free' | 'timeout' | 'cancelled' }
export interface RunCompletedPayload { usage: Usage }
export interface RunCompletedPayload {
usage: Usage
context?: ContextObservation
}
export interface ContextObservation {
items: string[]
truncations?: string[]
estChars: number
}
export interface RunFailedPayload { code: string; message: string }
// ---- HITL ----