Add thinking duration to message parts
Why: The chat timeline needs a persisted thinking duration, and tool duration already lives on the tool call, so the thinking part had nowhere to put it. Evidence: go test ./... passes; the message golden now includes durationMs on the thinking part. Impact: Additive JSON field with omitempty. Existing clients ignore unknown fields. Refs: feature/chat-timeline-preview Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+1
-1
@@ -42,7 +42,7 @@ func sampleMessage() Message {
|
|||||||
ID: "msg_abc123def456", ConversationID: "cnv_abc123def456", RunID: "run_abc123def456",
|
ID: "msg_abc123def456", ConversationID: "cnv_abc123def456", RunID: "run_abc123def456",
|
||||||
Role: RoleAssistant,
|
Role: RoleAssistant,
|
||||||
Parts: []Part{
|
Parts: []Part{
|
||||||
{Type: PartThinking, Text: "考虑先检索…", Process: true},
|
{Type: PartThinking, Text: "考虑先检索…", Process: true, DurationMs: 1500},
|
||||||
{Type: PartToolCall, Process: true, ToolCall: &ToolCallPart{ID: "call_1", Name: "history_search", Arguments: `{"q":"部署"}`, Duration: 12.5}},
|
{Type: PartToolCall, Process: true, ToolCall: &ToolCallPart{ID: "call_1", Name: "history_search", Arguments: `{"q":"部署"}`, Duration: 12.5}},
|
||||||
{Type: PartToolResult, Process: true, ToolResult: &ToolResultPart{CallID: "call_1", Status: "ok", Summary: "3 条命中"}},
|
{Type: PartToolResult, Process: true, ToolResult: &ToolResultPart{CallID: "call_1", Status: "ok", Summary: "3 条命中"}},
|
||||||
{Type: PartText, Text: "根据历史记录……"},
|
{Type: PartText, Text: "根据历史记录……"},
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ type Part struct {
|
|||||||
|
|
||||||
// 过程标记:true 的部件在 run 终态后由前端折叠为摘要行(4.2)。
|
// 过程标记:true 的部件在 run 终态后由前端折叠为摘要行(4.2)。
|
||||||
Process bool `json:"process,omitempty"`
|
Process bool `json:"process,omitempty"`
|
||||||
|
|
||||||
|
// DurationMs 是 thinking 部件的思考时长(毫秒,从首个推理增量到最后一个)。
|
||||||
|
// 工具耗时在 ToolCallPart.Duration,不复用本字段。
|
||||||
|
DurationMs float64 `json:"durationMs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToolCallPart struct {
|
type ToolCallPart struct {
|
||||||
|
|||||||
Vendored
+2
-1
@@ -7,7 +7,8 @@
|
|||||||
{
|
{
|
||||||
"type": "thinking",
|
"type": "thinking",
|
||||||
"text": "考虑先检索…",
|
"text": "考虑先检索…",
|
||||||
"process": true
|
"process": true,
|
||||||
|
"durationMs": 1500
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "tool_call",
|
"type": "tool_call",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export interface Part {
|
|||||||
card?: { kind: string; data: UINode[]; cardId?: ID }; // cardId 非空 = 收件箱卡片引用部件(submit_card)
|
card?: { kind: string; data: UINode[]; cardId?: ID }; // cardId 非空 = 收件箱卡片引用部件(submit_card)
|
||||||
error?: { code: string; message: string };
|
error?: { code: string; message: string };
|
||||||
process?: boolean; // run 终态后折叠为摘要行
|
process?: boolean; // run 终态后折叠为摘要行
|
||||||
|
durationMs?: number; // thinking 部件的思考时长(毫秒);工具耗时在 toolCall.durationMs
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Message {
|
export interface Message {
|
||||||
|
|||||||
Reference in New Issue
Block a user