@kenkaiiii/gg-agent 5.22.3 → 5.22.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.cjs CHANGED
@@ -255,9 +255,9 @@ async function* agentLoop(messages, options) {
255
255
  const STREAM_THINKING_IDLE_TIMEOUT_MS = 3e5;
256
256
  const STREAM_THINKING_HARD_TIMEOUT_MS = 6e5;
257
257
  const NON_STREAMING_HARD_TIMEOUT_MS = 3e5;
258
- const isSakana = options.provider === "sakana";
259
- const firstEventTimeoutMs = isSakana ? STREAM_THINKING_IDLE_TIMEOUT_MS : STREAM_FIRST_EVENT_TIMEOUT_MS;
260
- const initialHardTimeoutMs = isSakana ? STREAM_THINKING_HARD_TIMEOUT_MS : STREAM_HARD_TIMEOUT_MS;
258
+ const usesSilentReasoningBudget = options.provider === "sakana" || options.provider === "openai" && options.thinking != null;
259
+ const firstEventTimeoutMs = usesSilentReasoningBudget ? STREAM_THINKING_IDLE_TIMEOUT_MS : STREAM_FIRST_EVENT_TIMEOUT_MS;
260
+ const initialHardTimeoutMs = usesSilentReasoningBudget ? STREAM_THINKING_HARD_TIMEOUT_MS : STREAM_HARD_TIMEOUT_MS;
261
261
  const MAX_TOOLCALL_DELTA_CHARS = 1e6;
262
262
  const MAX_TOOLCALL_DELTA_EVENTS = 2e4;
263
263
  let logicalTurnStartedAt = 0;
@@ -285,7 +285,10 @@ async function* agentLoop(messages, options) {
285
285
  messages: messages.length,
286
286
  chars: msgChars,
287
287
  provider: options.provider,
288
- model: options.model
288
+ model: options.model,
289
+ thinking: options.thinking ?? "off",
290
+ firstEventTimeoutMs,
291
+ initialHardTimeoutMs
289
292
  });
290
293
  }
291
294
  if (firstTurn && options.getSteeringMessages) {
@@ -721,15 +724,29 @@ async function* agentLoop(messages, options) {
721
724
  continue;
722
725
  }
723
726
  if (transportFailure) {
727
+ const cause = malformed ? "malformed_stream" : socketDrop ? "socket_drop" : "stream_stall";
724
728
  diag("stall_exhausted", {
725
729
  stallRetries: MAX_STALL_RETRIES,
726
730
  provider: options.provider,
727
- model: options.model
731
+ model: options.model,
732
+ cause,
733
+ nonStreaming: useNonStreamingFallback,
734
+ events: streamEventCount,
735
+ eventTypes: eventTypeCounts,
736
+ lastEventType,
737
+ sinceLastEventMs: Date.now() - lastEventTime,
738
+ attemptDurationMs: Date.now() - streamCallStart,
739
+ maxConsumerLagMs
728
740
  });
729
741
  yield {
730
742
  type: "error",
731
- error: new Error(
732
- `The API provider's stream stalled ${MAX_STALL_RETRIES} times \u2014 the provider may be experiencing capacity issues. Your conversation is preserved. Send another message to retry.`
743
+ error: new import_gg_ai.GGAIError(
744
+ `The connection to the API provider stopped responding after ${MAX_STALL_RETRIES} automatic retries. Your conversation is preserved.`,
745
+ {
746
+ source: "network",
747
+ hint: "Retry once. If it keeps happening on this device, disable any VPN or proxy and allow GG Coder through firewall or antivirus web protection.",
748
+ cause: err
749
+ }
733
750
  )
734
751
  };
735
752
  break;