@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.
@@ -1290,6 +1290,44 @@ Call write_file NOW. Embed ALL data from the tool result above into the content.
1290
1290
  finalText = reResp.content;
1291
1291
  lastResponse = reResp;
1292
1292
  }
1293
+ const WRITE_NAMES = /* @__PURE__ */ new Set(["write_file", "str_replace"]);
1294
+ if (toolsCalled.has("vision_analyze") && ![...toolsCalled].some((n) => WRITE_NAMES.has(n)) && iters < MAX_TOOL_ITERS) {
1295
+ iters++;
1296
+ if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
1297
+ messages.pop();
1298
+ }
1299
+ messages.push({
1300
+ role: "user",
1301
+ content: `vision_analyze returned a caption but you did NOT call write_file.
1302
+ Task: ${target.title}
1303
+ Output path: ${target.description.match(/path[:\s]+([^\s\n,]+\.json)/i)?.[1] ?? "see task description"}
1304
+ 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.`
1305
+ });
1306
+ const vwResp = await provider.complete(
1307
+ { messages, maxTokens: 8192, temperature: 0, tools: activeTools },
1308
+ identity.llmModel
1309
+ );
1310
+ aggUsage = {
1311
+ promptTokens: aggUsage.promptTokens + vwResp.usage.promptTokens,
1312
+ completionTokens: aggUsage.completionTokens + vwResp.usage.completionTokens,
1313
+ totalTokens: aggUsage.totalTokens + vwResp.usage.totalTokens
1314
+ };
1315
+ if (vwResp.finishReason === "tool_use" && vwResp.toolUses && vwResp.toolUses.length > 0) {
1316
+ log({ ev: "vision-write-call", taskId: target.id, iter: iters, tools: vwResp.toolUses.map((t) => t.name) });
1317
+ const vwProd = summarizeToolProductivity(vwResp.toolUses);
1318
+ for (const n of vwProd.names) toolsCalled.add(n);
1319
+ productiveCallCount += vwProd.productiveCount;
1320
+ messages.push({ role: "assistant", content: vwResp.assistantBlocks ?? [] });
1321
+ const vwResults = await Promise.all(
1322
+ vwResp.toolUses.map(
1323
+ (u) => runTool(u, { signReceipt: this.opts.signReceipt, addTask: (tasks2) => mesh.addTasks(tasks2) })
1324
+ )
1325
+ );
1326
+ messages.push({ role: "user", content: vwResults });
1327
+ }
1328
+ finalText = vwResp.content;
1329
+ lastResponse = vwResp;
1330
+ }
1293
1331
  const durationMs = Date.now() - start;
1294
1332
  if (productiveCallCount === 0) {
1295
1333
  log({