@livx.cc/agentx 0.99.134 → 0.99.136

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/cli.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import { w as RouterState, H as Hooks, c as AgentOptions, x as RunResult, f as ChatUsage, R as ReasoningEffort, d as ChannelMode, b as Agent } from './secondChannel-D-8AGmAT.js';
2
+ import { w as RouterState, H as Hooks, c as AgentOptions, x as RunResult, f as ChatUsage, R as ReasoningEffort, d as ChannelMode, b as Agent } from './secondChannel-BqUiRI5w.js';
3
3
  import { IFilesystem } from '@livx.cc/wcli/core';
4
4
  import { M as Message, U as UserQuestion, H as HostBridge, c as ContentPart, o as MessageContent } from './tools-DwfeF8VQ.js';
5
5
 
package/dist/cli.js CHANGED
@@ -5716,7 +5716,7 @@ var Agent = class _Agent {
5716
5716
  }
5717
5717
  const sc = err2?.statusCode;
5718
5718
  const serverSide = sc >= 500 || sc === 408 || /Service Unavailable|overloaded|Internal server error|Bad gateway|Gateway time/i.test(String(err2?.message ?? ""));
5719
- const network = !sc && /ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|EPIPE|socket hang up|socket connection was closed|closed unexpectedly|stream failed mid-response|premature close|fetch failed|network|terminated|UND_ERR/i.test(String(err2?.message ?? err2?.code ?? err2));
5719
+ const network = !sc && /ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|EPIPE|socket hang up|socket connection was closed|closed unexpectedly|premature close|fetch failed|network|terminated|UND_ERR/i.test(String(err2?.message ?? err2?.code ?? err2));
5720
5720
  const stalled = err2?.code === "stall";
5721
5721
  const empty = err2?.code === "empty" || err2?.code === "cursor_silent";
5722
5722
  const maxAttempts = empty ? Math.max(o.emptyRetries, 0) : 2;
@@ -5872,9 +5872,10 @@ var Agent = class _Agent {
5872
5872
  if (o.maxRepeats && repeats >= o.maxRepeats) return kill("loop");
5873
5873
  toolCallsTotal += toolCalls.length;
5874
5874
  if (o.maxToolCalls && toolCallsTotal > o.maxToolCalls) return kill("max_tool_calls");
5875
+ const cutAtCap = res.finishReason === "max_tokens" || res.finishReason === "length";
5875
5876
  for (const tc of toolCalls) {
5876
5877
  if (o.signal?.aborted) return kill("aborted");
5877
- const raw = await this.dispatch(tc);
5878
+ const raw = cutAtCap && tc === toolCalls[toolCalls.length - 1] ? this.cutAtCapResult(tc) : await this.dispatch(tc);
5878
5879
  let content;
5879
5880
  if (typeof raw === "string") {
5880
5881
  content = nonEmptyResult(raw, tc.function.name);
@@ -6092,6 +6093,15 @@ var Agent = class _Agent {
6092
6093
  const invoked = new Set([...this.invokedTools].map(toolKey));
6093
6094
  return [...this.fabricatedClaims].filter((n) => !invoked.has(toolKey(n)));
6094
6095
  }
6096
+ /** A tool call the output cap cut mid-arguments: never run it (its args are incomplete), and say WHY —
6097
+ * a generic "missing argument" makes the model re-send the same oversized call. */
6098
+ cutAtCapResult(tc) {
6099
+ this.invokedTools.add(tc.function.name);
6100
+ const msg = `Error: your reply hit the output token limit while writing this ${tc.function.name} call, so its arguments were cut off and it did NOT run. Re-sending the same call will be cut again. Split it: write a smaller first part now, then add the rest in further calls (e.g. Edit to append), each well under the limit.`;
6101
+ log9.warn(`${tc.function.name} cut at the output cap \u2014 not run`);
6102
+ this.options.host?.notify?.({ kind: "tool_result", id: tc.id ?? "", output: msg, isError: true });
6103
+ return msg;
6104
+ }
6095
6105
  async dispatch(tc) {
6096
6106
  this.invokedTools.add(tc.function.name);
6097
6107
  const tool = this.activeTools.find((t) => t.name === tc.function.name);