persist and restore assistant tool calls in session jsonl events

This commit is contained in:
DBT
2026-02-24 10:14:46 +00:00
parent 8988002c5a
commit 8dd8eb23dc

View File

@@ -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 {