@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.
@@ -1186,6 +1186,43 @@ var AgentRunner = class {
1186
1186
  finalText = resp.content;
1187
1187
  break;
1188
1188
  }
1189
+ if (productiveCallCount === 0 && toolsCalled.size > 0 && iters < MAX_TOOL_ITERS) {
1190
+ iters++;
1191
+ if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
1192
+ messages.pop();
1193
+ }
1194
+ messages.push({
1195
+ role: "user",
1196
+ content: `You read data but did NOT call write_file. This is a TASK FAILURE unless you act now.
1197
+ Task: ${target.title}
1198
+ Required output path (from task description): ${target.description.match(/path[:\s]+([^\s\n,]+\.json)/i)?.[1] ?? "see task description"}
1199
+ 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.`
1200
+ });
1201
+ const reResp = await provider.complete(
1202
+ { messages, maxTokens: 8192, temperature: 0, tools: activeTools },
1203
+ identity.llmModel
1204
+ );
1205
+ aggUsage = {
1206
+ promptTokens: aggUsage.promptTokens + reResp.usage.promptTokens,
1207
+ completionTokens: aggUsage.completionTokens + reResp.usage.completionTokens,
1208
+ totalTokens: aggUsage.totalTokens + reResp.usage.totalTokens
1209
+ };
1210
+ if (reResp.finishReason === "tool_use" && reResp.toolUses && reResp.toolUses.length > 0) {
1211
+ log({ ev: "reprompt-tool-call", taskId: target.id, iter: iters, tools: reResp.toolUses.map((t) => t.name) });
1212
+ const reProd = summarizeToolProductivity(reResp.toolUses);
1213
+ for (const n of reProd.names) toolsCalled.add(n);
1214
+ productiveCallCount += reProd.productiveCount;
1215
+ messages.push({ role: "assistant", content: reResp.assistantBlocks ?? [] });
1216
+ const reResults = await Promise.all(
1217
+ reResp.toolUses.map(
1218
+ (u) => runTool(u, { signReceipt: this.opts.signReceipt, addTask: (tasks2) => mesh.addTasks(tasks2) })
1219
+ )
1220
+ );
1221
+ messages.push({ role: "user", content: reResults });
1222
+ }
1223
+ finalText = reResp.content;
1224
+ lastResponse = reResp;
1225
+ }
1189
1226
  const durationMs = Date.now() - start;
1190
1227
  if (productiveCallCount === 0) {
1191
1228
  log({