mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-21 03:27:32 +08:00
persist and restore assistant tool calls in session jsonl events
This commit is contained in:
@@ -45,6 +45,7 @@ type openClawEvent struct {
|
|||||||
} `json:"content,omitempty"`
|
} `json:"content,omitempty"`
|
||||||
ToolCallID string `json:"toolCallId,omitempty"`
|
ToolCallID string `json:"toolCallId,omitempty"`
|
||||||
ToolName string `json:"toolName,omitempty"`
|
ToolName string `json:"toolName,omitempty"`
|
||||||
|
ToolCalls []providers.ToolCall `json:"toolCalls,omitempty"`
|
||||||
} `json:"message,omitempty"`
|
} `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +330,7 @@ func toOpenClawMessageEvent(msg providers.Message) openClawEvent {
|
|||||||
} `json:"content,omitempty"`
|
} `json:"content,omitempty"`
|
||||||
ToolCallID string `json:"toolCallId,omitempty"`
|
ToolCallID string `json:"toolCallId,omitempty"`
|
||||||
ToolName string `json:"toolName,omitempty"`
|
ToolName string `json:"toolName,omitempty"`
|
||||||
|
ToolCalls []providers.ToolCall `json:"toolCalls,omitempty"`
|
||||||
}{
|
}{
|
||||||
Role: mappedRole,
|
Role: mappedRole,
|
||||||
Content: []struct {
|
Content: []struct {
|
||||||
@@ -338,6 +340,7 @@ func toOpenClawMessageEvent(msg providers.Message) openClawEvent {
|
|||||||
{Type: "text", Text: msg.Content},
|
{Type: "text", Text: msg.Content},
|
||||||
},
|
},
|
||||||
ToolCallID: msg.ToolCallID,
|
ToolCallID: msg.ToolCallID,
|
||||||
|
ToolCalls: msg.ToolCalls,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return e
|
return e
|
||||||
@@ -368,7 +371,7 @@ func fromJSONLLine(line []byte) (providers.Message, bool) {
|
|||||||
content += part.Text
|
content += part.Text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return providers.Message{Role: role, Content: content, ToolCallID: event.Message.ToolCallID}, true
|
return providers.Message{Role: role, Content: content, ToolCallID: event.Message.ToolCallID, ToolCalls: event.Message.ToolCalls}, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func deriveSessionID(key string) string {
|
func deriveSessionID(key string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user