@holoscript/holoscript-agent 2.1.0 → 2.1.2

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/dist/index.js CHANGED
@@ -1733,6 +1733,43 @@ var AgentRunner = class {
1733
1733
  finalText = resp.content;
1734
1734
  break;
1735
1735
  }
1736
+ if (productiveCallCount === 0 && toolsCalled.size > 0 && iters < MAX_TOOL_ITERS) {
1737
+ iters++;
1738
+ if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
1739
+ messages.pop();
1740
+ }
1741
+ messages.push({
1742
+ role: "user",
1743
+ content: `You read data but did NOT call write_file. This is a TASK FAILURE unless you act now.
1744
+ Task: ${target.title}
1745
+ Required output path (from task description): ${target.description.match(/path[:\s]+([^\s\n,]+\.json)/i)?.[1] ?? "see task description"}
1746
+ Call write_file NOW. Embed ALL data from the tool result above into the content. Do NOT output any text \u2014 your ONLY valid response is a write_file tool call.`
1747
+ });
1748
+ const reResp = await provider.complete(
1749
+ { messages, maxTokens: 8192, temperature: 0, tools: activeTools },
1750
+ identity.llmModel
1751
+ );
1752
+ aggUsage = {
1753
+ promptTokens: aggUsage.promptTokens + reResp.usage.promptTokens,
1754
+ completionTokens: aggUsage.completionTokens + reResp.usage.completionTokens,
1755
+ totalTokens: aggUsage.totalTokens + reResp.usage.totalTokens
1756
+ };
1757
+ if (reResp.finishReason === "tool_use" && reResp.toolUses && reResp.toolUses.length > 0) {
1758
+ log({ ev: "reprompt-tool-call", taskId: target.id, iter: iters, tools: reResp.toolUses.map((t) => t.name) });
1759
+ const reProd = summarizeToolProductivity(reResp.toolUses);
1760
+ for (const n of reProd.names) toolsCalled.add(n);
1761
+ productiveCallCount += reProd.productiveCount;
1762
+ messages.push({ role: "assistant", content: reResp.assistantBlocks ?? [] });
1763
+ const reResults = await Promise.all(
1764
+ reResp.toolUses.map(
1765
+ (u) => runTool(u, { signReceipt: this.opts.signReceipt, addTask: (tasks2) => mesh.addTasks(tasks2) })
1766
+ )
1767
+ );
1768
+ messages.push({ role: "user", content: reResults });
1769
+ }
1770
+ finalText = reResp.content;
1771
+ lastResponse = reResp;
1772
+ }
1736
1773
  const durationMs = Date.now() - start;
1737
1774
  if (productiveCallCount === 0) {
1738
1775
  log({