@monotykamary/pi-retry 0.3.7 → 0.3.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monotykamary/pi-retry",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Extension suite for pi coding agent that handles 400/413 errors and connection errors with automatic retry",
5
5
  "type": "module",
6
6
  "author": "Tom X Nguyen",
package/retry.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  hasConnectionError,
7
7
  hasRetryableError,
8
8
  isNonRetryableError,
9
+ isSilencedError,
9
10
  hasMaxTokensStop,
10
11
  isAssistantMessage,
11
12
  getLastAssistantMessage,
@@ -76,7 +77,8 @@ Agent.prototype.continue = function (this: Agent) {
76
77
  // Catch it — the while-loop will poll _handlePostAgentRun()
77
78
  // again, find no error, and exit cleanly.
78
79
  const msg = e?.message ?? '';
79
- if (msg.includes('Cannot continue from an assistant message') ||
80
+ if (msg.includes('Cannot continue from message role') ||
81
+ msg.includes('Cannot continue from an assistant message') ||
80
82
  msg.includes('Agent is already processing')) {
81
83
  return;
82
84
  }
@@ -191,7 +193,8 @@ export default function (pi: ExtensionAPI) {
191
193
  }
192
194
 
193
195
  // Log non-retryable errors so the user knows why we didn't retry
194
- if (isNonRetryableError(lastAssistant)) {
196
+ // (silenced errors are neither retried nor shown)
197
+ if (isNonRetryableError(lastAssistant) && !isSilencedError(lastAssistant)) {
195
198
  const errorMsg = lastAssistant.errorMessage || "Unknown error";
196
199
  ctx.ui.notify(`Non-retryable error (not retried): ${errorMsg.substring(0, 100)}`, "error");
197
200
  }
@@ -75,6 +75,12 @@ const NON_RETRYABLE_PATTERNS = [
75
75
  /no\s*such\s*model/i,
76
76
  /model\s*does\s*not\s*exist/i,
77
77
  /unsupported\s*model/i,
78
+ /cannot continue from message role/i,
79
+ ];
80
+
81
+ // Errors that are non-retryable AND should be silently ignored (no notification)
82
+ const SILENCED_PATTERNS = [
83
+ /cannot continue from message role/i,
78
84
  ];
79
85
 
80
86
  // ── Type guard ──
@@ -124,6 +130,17 @@ export function isNonRetryableError(message: AgentMessage): boolean {
124
130
  return NON_RETRYABLE_PATTERNS.some(p => p.test(message.errorMessage));
125
131
  }
126
132
 
133
+ /**
134
+ * Returns true for errors that are non-retryable and should be silently
135
+ * ignored (no UI notification). These are provider-level refusals that
136
+ * the user cannot act on and that would only add noise.
137
+ */
138
+ export function isSilencedError(message: AgentMessage): boolean {
139
+ if (!isAssistantMessage(message)) return false;
140
+ if (message.stopReason !== "error" || !message.errorMessage) return false;
141
+ return SILENCED_PATTERNS.some(p => p.test(message.errorMessage));
142
+ }
143
+
127
144
  // ── Categorisation (for UI messages) ──
128
145
 
129
146
  export function getErrorCategory(errorMessage: string): '400-413' | 'credit' | 'connection' | 'builtin' | 'other' {