@ouro.bot/cli 0.1.0-alpha.87 → 0.1.0-alpha.88
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/changelog.json +7 -0
- package/dist/mind/context.js +30 -0
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.88",
|
|
6
|
+
"changes": [
|
|
7
|
+
"CLI session repair now strips orphaned tool-result messages when a saved chat history lost the matching assistant tool call, so a broken prior turn no longer bricks every future `ouro chat` message with a tool-call replay error.",
|
|
8
|
+
"Recovered sessions keep valid tool call/result pairs intact while dropping only the stale outputs, which lets live operator chats resume from repaired history instead of forcing a brand-new thread."
|
|
9
|
+
]
|
|
10
|
+
},
|
|
4
11
|
{
|
|
5
12
|
"version": "0.1.0-alpha.87",
|
|
6
13
|
"changes": [
|
package/dist/mind/context.js
CHANGED
|
@@ -227,6 +227,34 @@ function repairSessionMessages(messages) {
|
|
|
227
227
|
});
|
|
228
228
|
return result;
|
|
229
229
|
}
|
|
230
|
+
function stripOrphanedToolResults(messages) {
|
|
231
|
+
const validCallIds = new Set();
|
|
232
|
+
for (const msg of messages) {
|
|
233
|
+
if (msg.role !== "assistant" || !Array.isArray(msg.tool_calls))
|
|
234
|
+
continue;
|
|
235
|
+
for (const toolCall of msg.tool_calls)
|
|
236
|
+
validCallIds.add(toolCall.id);
|
|
237
|
+
}
|
|
238
|
+
let removed = 0;
|
|
239
|
+
const repaired = messages.filter((msg) => {
|
|
240
|
+
if (msg.role !== "tool")
|
|
241
|
+
return true;
|
|
242
|
+
const keep = validCallIds.has(msg.tool_call_id);
|
|
243
|
+
if (!keep)
|
|
244
|
+
removed++;
|
|
245
|
+
return keep;
|
|
246
|
+
});
|
|
247
|
+
if (removed > 0) {
|
|
248
|
+
(0, runtime_1.emitNervesEvent)({
|
|
249
|
+
level: "warn",
|
|
250
|
+
event: "mind.session_orphan_tool_result_repair",
|
|
251
|
+
component: "mind",
|
|
252
|
+
message: "removed orphaned tool results from session history",
|
|
253
|
+
meta: { removed },
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
return repaired;
|
|
257
|
+
}
|
|
230
258
|
function saveSession(filePath, messages, lastUsage, state) {
|
|
231
259
|
const violations = validateSessionMessages(messages);
|
|
232
260
|
if (violations.length > 0) {
|
|
@@ -239,6 +267,7 @@ function saveSession(filePath, messages, lastUsage, state) {
|
|
|
239
267
|
});
|
|
240
268
|
messages = repairSessionMessages(messages);
|
|
241
269
|
}
|
|
270
|
+
messages = stripOrphanedToolResults(messages);
|
|
242
271
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
243
272
|
const envelope = { version: 1, messages };
|
|
244
273
|
if (lastUsage)
|
|
@@ -269,6 +298,7 @@ function loadSession(filePath) {
|
|
|
269
298
|
});
|
|
270
299
|
messages = repairSessionMessages(messages);
|
|
271
300
|
}
|
|
301
|
+
messages = stripOrphanedToolResults(messages);
|
|
272
302
|
const rawState = data?.state && typeof data.state === "object" && data.state !== null
|
|
273
303
|
? data.state
|
|
274
304
|
: undefined;
|