agentgui 1.0.733 → 1.0.734
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/database.js +24 -15
- package/package.json +1 -1
- package/static/js/client.js +1 -1
package/database.js
CHANGED
|
@@ -1523,22 +1523,31 @@ export const queries = {
|
|
|
1523
1523
|
},
|
|
1524
1524
|
|
|
1525
1525
|
getRecentConversationChunks(conversationId, limit = 500) {
|
|
1526
|
-
|
|
1526
|
+
// Always include the complete latest session so tool_use/tool_result pairs are intact.
|
|
1527
|
+
// Then fill remaining capacity with older chunks.
|
|
1528
|
+
const latestSession = prep(
|
|
1529
|
+
`SELECT sessionId FROM chunks WHERE conversationId = ? ORDER BY created_at DESC LIMIT 1`
|
|
1530
|
+
).get(conversationId);
|
|
1531
|
+
if (!latestSession) return [];
|
|
1532
|
+
const latestSid = latestSession.sessionId;
|
|
1533
|
+
const latestRows = prep(
|
|
1527
1534
|
`SELECT id, sessionId, conversationId, sequence, type, data, created_at
|
|
1528
|
-
FROM chunks WHERE conversationId = ?
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1535
|
+
FROM chunks WHERE conversationId = ? AND sessionId = ? ORDER BY created_at ASC`
|
|
1536
|
+
).all(conversationId, latestSid);
|
|
1537
|
+
const remaining = limit - latestRows.length;
|
|
1538
|
+
let olderRows = [];
|
|
1539
|
+
if (remaining > 0) {
|
|
1540
|
+
const oldestLatest = latestRows.length ? latestRows[0].created_at : Date.now();
|
|
1541
|
+
olderRows = prep(
|
|
1542
|
+
`SELECT id, sessionId, conversationId, sequence, type, data, created_at
|
|
1543
|
+
FROM chunks WHERE conversationId = ? AND sessionId != ? AND created_at < ?
|
|
1544
|
+
ORDER BY created_at DESC LIMIT ?`
|
|
1545
|
+
).all(conversationId, latestSid, oldestLatest, remaining);
|
|
1546
|
+
olderRows.reverse();
|
|
1547
|
+
}
|
|
1548
|
+
return [...olderRows, ...latestRows].map(row => {
|
|
1549
|
+
try { return { ...row, data: typeof row.data === 'string' ? JSON.parse(row.data) : row.data }; }
|
|
1550
|
+
catch (e) { return row; }
|
|
1542
1551
|
});
|
|
1543
1552
|
},
|
|
1544
1553
|
|
package/package.json
CHANGED
package/static/js/client.js
CHANGED
|
@@ -2706,7 +2706,7 @@ class AgentGUIClient {
|
|
|
2706
2706
|
|
|
2707
2707
|
let fullData;
|
|
2708
2708
|
try {
|
|
2709
|
-
fullData = await window.wsClient.rpc('conv.full', { id: conversationId
|
|
2709
|
+
fullData = await window.wsClient.rpc('conv.full', { id: conversationId });
|
|
2710
2710
|
if (convSignal.aborted) return;
|
|
2711
2711
|
} catch (wsErr) {
|
|
2712
2712
|
if (wsErr.code === 404) {
|