deepccc 0.2.9 → 0.2.10

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.
Files changed (2) hide show
  1. package/dist/context.js +14 -5
  2. package/package.json +1 -1
package/dist/context.js CHANGED
@@ -402,7 +402,10 @@ function replayStructuredAssistantMessage(message, messageIndex) {
402
402
  messages.push({ role: "assistant", content: assistantParts });
403
403
  assistantParts = [];
404
404
  };
405
- const flushTools = () => {
405
+ const completeToolStep = () => {
406
+ // OpenAI/LiteLLM requires every tool message to immediately follow the
407
+ // assistant message that declared all matching tool_calls for that step.
408
+ flushAssistant();
406
409
  for (const [toolCallId, toolName] of pendingCalls) {
407
410
  toolParts.push({
408
411
  type: "tool-result",
@@ -419,7 +422,8 @@ function replayStructuredAssistantMessage(message, messageIndex) {
419
422
  };
420
423
  for (const entry of timeline) {
421
424
  if (entry.type === "text") {
422
- flushTools();
425
+ if (pendingCalls.size > 0 || toolParts.length > 0)
426
+ completeToolStep();
423
427
  const previous = assistantParts[assistantParts.length - 1];
424
428
  if (previous?.type === "text")
425
429
  previous.text += entry.text;
@@ -427,7 +431,10 @@ function replayStructuredAssistantMessage(message, messageIndex) {
427
431
  assistantParts.push({ type: "text", text: entry.text });
428
432
  }
429
433
  else if (entry.type === "tool_use") {
430
- flushTools();
434
+ // Consecutive tool calls belong to one assistant step. Only close the
435
+ // previous step after at least one result has arrived.
436
+ if (toolParts.length > 0)
437
+ completeToolStep();
431
438
  knownNames.set(entry.id, entry.name);
432
439
  pendingCalls.set(entry.id, entry.name);
433
440
  emittedCallIds.add(entry.id);
@@ -454,8 +461,10 @@ function replayStructuredAssistantMessage(message, messageIndex) {
454
461
  });
455
462
  }
456
463
  }
457
- flushAssistant();
458
- flushTools();
464
+ if (pendingCalls.size > 0 || toolParts.length > 0)
465
+ completeToolStep();
466
+ else
467
+ flushAssistant();
459
468
  return messages;
460
469
  }
461
470
  function serializeMessagesForCompaction(messages) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepccc",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "A lightweight coding agent with OpenAI-compatible and Anthropic Messages API support.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [