@standardagents/builder 0.27.11 → 0.27.13

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/runtime.js CHANGED
@@ -1758,7 +1758,9 @@ var init_LLMRequest = __esm({
1758
1758
  console.error(`Error calling ${actualModelId} (attempt ${attempts}):`, error2);
1759
1759
  await this.logError(state, error2, "api_error", actualModelId, startTime, logId);
1760
1760
  if (attempts < MAX_RETRIES_PER_MODEL) {
1761
- const backoffMs = BACKOFF_BASE * Math.pow(2, attempts - 1);
1761
+ const base = BACKOFF_BASE * Math.pow(2, attempts - 1);
1762
+ const retryAfterMs = typeof error2?.retryAfter === "number" ? error2.retryAfter * 1e3 : 0;
1763
+ const backoffMs = Math.max(base, retryAfterMs);
1762
1764
  await this.sleep(backoffMs);
1763
1765
  previousLogId = logId;
1764
1766
  logId = void 0;
@@ -4327,8 +4329,17 @@ ${errorLines.join("\n")}`);
4327
4329
  responseParts.push(`Other tools run: ${successfulToolNames.join(", ")}`);
4328
4330
  }
4329
4331
  } else {
4330
- if (toolResponseOptions.include_text_response && textContent) {
4331
- responseParts.push(textContent);
4332
+ if (toolResponseOptions.include_text_response) {
4333
+ let responseText = textContent;
4334
+ if (!responseText) {
4335
+ const recovered = await state.storage.sql.exec(
4336
+ `SELECT content FROM messages WHERE parent_id = ? AND role = 'assistant' AND content IS NOT NULL AND content != '' AND (tool_calls IS NULL OR tool_calls = '') ORDER BY created_at DESC LIMIT 1`,
4337
+ toolMessageId
4338
+ );
4339
+ const recoveredRow = recovered.toArray()[0];
4340
+ if (recoveredRow?.content) responseText = recoveredRow.content;
4341
+ }
4342
+ if (responseText) responseParts.push(responseText);
4332
4343
  }
4333
4344
  if (toolResponseOptions.include_tool_calls || toolResponseOptions.include_errors) {
4334
4345
  const childAssistantMessagesResult = await state.storage.sql.exec(