Compare commits

..

5 Commits

Author SHA1 Message Date
devops a538025049 chore: bump version to v0.2.42 [skip ci] 2026-06-09 23:28:15 +00:00
devops 6d7454a7c1 chore: bump version to v0.2.41 [skip ci] 2026-06-09 23:27:51 +00:00
devops 3c72e807da chore: bump version to v0.2.40 [skip ci] 2026-06-09 23:27:24 +00:00
devops 702692cf0c chore: bump version to v0.2.39 [skip ci] 2026-06-09 23:14:57 +00:00
developer 51d1917a7b fix: GetSessionHistory parst content[] blocks korrekt
CI - Build & Test / Backend (.NET) (push) Successful in 24s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 15s
CI - Build & Test / Security Check (push) Successful in 3s
- Messages aus result.details.messages extrahieren
- Content = Array von {type, text} blocks → nur text extrahieren
- Thinking-Blocks + REPLY_SKIP + ANNOUNCE_SKIP herausfiltern
2026-06-10 01:14:08 +02:00
2 changed files with 35 additions and 10 deletions
+1 -1
View File
@@ -1 +1 @@
0.2.38 0.2.42
+34 -9
View File
@@ -145,24 +145,49 @@ public sealed class OpenClawGatewayClient(HttpClient httpClient, IConfiguration
{ {
try try
{ {
var result = await InvokeToolAsync("sessions_history", new { sessionKey, limit, offset }); var result = await InvokeToolAsync("sessions_history", new {
sessionKey, limit, offset,
includeTools = false
});
if (result is null) return new List<MessageEntry>(); if (result is null) return new List<MessageEntry>();
var messages = new List<MessageEntry>(); // sessions_history returns { details: { messages: [...] } }
var array = result as JsonArray ?? result.AsArray(); var messageArray = result["details"]?["messages"] as JsonArray;
if (array is null) return messages; if (messageArray is null) return new List<MessageEntry>();
foreach (var msg in array) var messages = new List<MessageEntry>();
foreach (var msg in messageArray.Cast<JsonNode?>())
{ {
if (msg is null) continue; if (msg is null) continue;
var role = msg["role"]?.GetValue<string>() ?? ""; var role = msg["role"]?.GetValue<string>() ?? "";
var content = msg["content"]?.GetValue<string>() ?? ""; // Skip non-user/assistant roles
if (role is not ("user" or "assistant")) continue;
// Content is an array of blocks: [{type: "text"/"thinking", text: "..."}]
// Extract only pure text blocks, skip thinking-only messages
var contentBlocks = msg["content"] as JsonArray;
if (contentBlocks is null) continue;
var visibleTexts = new List<string>();
foreach (var block in contentBlocks.Cast<JsonNode?>())
{
if (block is null) continue;
var type = block["type"]?.GetValue<string>() ?? "";
var text = block["text"]?.GetValue<string>() ?? "";
if (type == "text" && !string.IsNullOrWhiteSpace(text))
visibleTexts.Add(text);
}
var visibleContent = string.Join(" ", visibleTexts).Trim();
if (string.IsNullOrWhiteSpace(visibleContent)) continue;
// Skip system-only replies
if (visibleContent is "REPLY_SKIP" or "ANNOUNCE_SKIP") continue;
var timestamp = msg["timestamp"]?.GetValue<string>() var timestamp = msg["timestamp"]?.GetValue<string>()
?? msg["ts"]?.GetValue<string>()
?? msg["createdAt"]?.GetValue<string>()
?? DateTimeOffset.UtcNow.ToString("o"); ?? DateTimeOffset.UtcNow.ToString("o");
messages.Add(new MessageEntry(role, content, timestamp)); messages.Add(new MessageEntry(role, visibleContent, timestamp));
} }
return messages; return messages;