@ducci/jarvis 1.0.98 → 1.0.100

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ducci/jarvis",
3
- "version": "1.0.98",
3
+ "version": "1.0.100",
4
4
  "description": "A fully automated agent system that lives on a server.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -22,7 +22,8 @@ function stripCodeFence(text) {
22
22
  // JSON string values — models sometimes forget to escape \n as \\n
23
23
  // 3. Remove trailing commas before } and ] (JS-valid but JSON-invalid)
24
24
  function sanitizeJson(text) {
25
- let s = stripCodeFence(text);
25
+ // Strip <think>...</think> blocks (e.g. MiniMax reasoning traces) before JSON parsing
26
+ let s = stripCodeFence(text).replace(/<think>[\s\S]*?<\/think>/g, '').trim();
26
27
 
27
28
  // State machine: walk the string and fix unescaped control chars inside strings
28
29
  let result = '';
@@ -230,7 +231,11 @@ async function runSubagent(client, config, args, parentSessionId) {
230
231
  return msg;
231
232
  });
232
233
  if (resolved.length <= subConfig.messageWindow + 1) return resolved;
233
- return [resolved[0], ...resolved.slice(-(subConfig.messageWindow))];
234
+ // Walk back from the window boundary past any orphaned tool results to avoid
235
+ // starting mid-tool-call-sequence (MiniMax error 2013: tool_call_id not found)
236
+ let startIdx = resolved.length - subConfig.messageWindow;
237
+ while (startIdx > 1 && resolved[startIdx].role === 'tool') startIdx--;
238
+ return [resolved[0], ...resolved.slice(startIdx)];
234
239
  }
235
240
 
236
241
  const run = await runAgentLoop(client, subConfig, subSession, prepareMessages, usageAccum);
@@ -805,7 +810,11 @@ async function _runHandleChat(config, sessionId, userMessage, attachments = [],
805
810
  return msg;
806
811
  });
807
812
  if (resolved.length <= config.messageWindow + 1) return resolved;
808
- return [resolved[0], ...resolved.slice(-(config.messageWindow))];
813
+ // Walk back from the window boundary past any orphaned tool results to avoid
814
+ // starting mid-tool-call-sequence (MiniMax error 2013: tool_call_id not found)
815
+ let startIdx = resolved.length - config.messageWindow;
816
+ while (startIdx > 1 && resolved[startIdx].role === 'tool') startIdx--;
817
+ return [resolved[0], ...resolved.slice(startIdx)];
809
818
  }
810
819
 
811
820
  const allToolCalls = [];