@holoscript/holoscript-agent 2.1.3 → 2.1.4

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
@@ -1837,6 +1837,44 @@ Call write_file NOW. Embed ALL data from the tool result above into the content.
1837
1837
  finalText = reResp.content;
1838
1838
  lastResponse = reResp;
1839
1839
  }
1840
+ const WRITE_NAMES = /* @__PURE__ */ new Set(["write_file", "str_replace"]);
1841
+ if (toolsCalled.has("vision_analyze") && ![...toolsCalled].some((n) => WRITE_NAMES.has(n)) && iters < MAX_TOOL_ITERS) {
1842
+ iters++;
1843
+ if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
1844
+ messages.pop();
1845
+ }
1846
+ messages.push({
1847
+ role: "user",
1848
+ content: `vision_analyze returned a caption but you did NOT call write_file.
1849
+ Task: ${target.title}
1850
+ Output path: ${target.description.match(/path[:\s]+([^\s\n,]+\.json)/i)?.[1] ?? "see task description"}
1851
+ Call write_file NOW. Put the caption from vision_analyze into the JSON content field. Do NOT output text \u2014 your ONLY valid response is a write_file tool call.`
1852
+ });
1853
+ const vwResp = await provider.complete(
1854
+ { messages, maxTokens: 8192, temperature: 0, tools: activeTools },
1855
+ identity.llmModel
1856
+ );
1857
+ aggUsage = {
1858
+ promptTokens: aggUsage.promptTokens + vwResp.usage.promptTokens,
1859
+ completionTokens: aggUsage.completionTokens + vwResp.usage.completionTokens,
1860
+ totalTokens: aggUsage.totalTokens + vwResp.usage.totalTokens
1861
+ };
1862
+ if (vwResp.finishReason === "tool_use" && vwResp.toolUses && vwResp.toolUses.length > 0) {
1863
+ log({ ev: "vision-write-call", taskId: target.id, iter: iters, tools: vwResp.toolUses.map((t) => t.name) });
1864
+ const vwProd = summarizeToolProductivity(vwResp.toolUses);
1865
+ for (const n of vwProd.names) toolsCalled.add(n);
1866
+ productiveCallCount += vwProd.productiveCount;
1867
+ messages.push({ role: "assistant", content: vwResp.assistantBlocks ?? [] });
1868
+ const vwResults = await Promise.all(
1869
+ vwResp.toolUses.map(
1870
+ (u) => runTool(u, { signReceipt: this.opts.signReceipt, addTask: (tasks2) => mesh.addTasks(tasks2) })
1871
+ )
1872
+ );
1873
+ messages.push({ role: "user", content: vwResults });
1874
+ }
1875
+ finalText = vwResp.content;
1876
+ lastResponse = vwResp;
1877
+ }
1840
1878
  const durationMs = Date.now() - start;
1841
1879
  if (productiveCallCount === 0) {
1842
1880
  log({