pi-mega-compact 0.20.65 → 0.20.67

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.
Files changed (82) hide show
  1. package/dist/extensions/mega-compact-s38.test/_helpers.js +2 -1
  2. package/dist/extensions/mega-compact.test/_helpers.js +4 -1
  3. package/dist/extensions/mega-events/agent-handlers/agentEndHandler.js +2 -2
  4. package/dist/extensions/mega-events/agent-handlers/turnEndHandler/errorRetry-transient.js +131 -0
  5. package/dist/extensions/mega-events/agent-handlers/turnEndHandler/errorRetry.js +13 -137
  6. package/dist/extensions/mega-events/compact-handlers.js +3 -3
  7. package/dist/extensions/mega-events/outage-advisor.js +5 -5
  8. package/dist/extensions/mega-events/send-safe.js +16 -0
  9. package/extensions/dashboard-client/dist/assets/{AdminTab-B31efZ_R.js → AdminTab-t4kzAKba.js} +2 -2
  10. package/extensions/dashboard-client/dist/assets/{AdminTab-B31efZ_R.js.map → AdminTab-t4kzAKba.js.map} +1 -1
  11. package/extensions/dashboard-client/dist/assets/{AreaChart-BpjHNUZm.js → AreaChart-B_2FnM5A.js} +2 -2
  12. package/extensions/dashboard-client/dist/assets/{AreaChart-BpjHNUZm.js.map → AreaChart-B_2FnM5A.js.map} +1 -1
  13. package/extensions/dashboard-client/dist/assets/{BarChart-CY2FndXC.js → BarChart-D0-fTEoK.js} +2 -2
  14. package/extensions/dashboard-client/dist/assets/{BarChart-CY2FndXC.js.map → BarChart-D0-fTEoK.js.map} +1 -1
  15. package/extensions/dashboard-client/dist/assets/{CacheTab-kMSrMD3e.js → CacheTab-CUQPLCcM.js} +2 -2
  16. package/extensions/dashboard-client/dist/assets/{CacheTab-kMSrMD3e.js.map → CacheTab-CUQPLCcM.js.map} +1 -1
  17. package/extensions/dashboard-client/dist/assets/{ConfigTab-BrKpv2YG.js → ConfigTab-xtAz7do-.js} +2 -2
  18. package/extensions/dashboard-client/dist/assets/{ConfigTab-BrKpv2YG.js.map → ConfigTab-xtAz7do-.js.map} +1 -1
  19. package/extensions/dashboard-client/dist/assets/{EventsTab-DaClreCm.js → EventsTab-DLie9_So.js} +2 -2
  20. package/extensions/dashboard-client/dist/assets/{EventsTab-DaClreCm.js.map → EventsTab-DLie9_So.js.map} +1 -1
  21. package/extensions/dashboard-client/dist/assets/{HealthTab-CxKQDqF3.js → HealthTab-DC-K1UGr.js} +2 -2
  22. package/extensions/dashboard-client/dist/assets/{HealthTab-CxKQDqF3.js.map → HealthTab-DC-K1UGr.js.map} +1 -1
  23. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BKSlSjv0.js → MaintenanceTab-BRiZnnzk.js} +2 -2
  24. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BKSlSjv0.js.map → MaintenanceTab-BRiZnnzk.js.map} +1 -1
  25. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-C2goWDt8.js → MemoryMapTab-DUHG7tll.js} +2 -2
  26. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-C2goWDt8.js.map → MemoryMapTab-DUHG7tll.js.map} +1 -1
  27. package/extensions/dashboard-client/dist/assets/{MetricsCards-DCPuCnrw.js → MetricsCards-Bm19vWjr.js} +2 -2
  28. package/extensions/dashboard-client/dist/assets/{MetricsCards-DCPuCnrw.js.map → MetricsCards-Bm19vWjr.js.map} +1 -1
  29. package/extensions/dashboard-client/dist/assets/MetricsTab-Bp-FbUfh.js +2 -0
  30. package/extensions/dashboard-client/dist/assets/{MetricsTab-Bz0Mdyb_.js.map → MetricsTab-Bp-FbUfh.js.map} +1 -1
  31. package/extensions/dashboard-client/dist/assets/OverviewTab-C7kYy6VF.js +16 -0
  32. package/extensions/dashboard-client/dist/assets/OverviewTab-C7kYy6VF.js.map +1 -0
  33. package/extensions/dashboard-client/dist/assets/{ReposTab-W_NKRWpk.js → ReposTab-6kRj8MNh.js} +2 -2
  34. package/extensions/dashboard-client/dist/assets/{ReposTab-W_NKRWpk.js.map → ReposTab-6kRj8MNh.js.map} +1 -1
  35. package/extensions/dashboard-client/dist/assets/{SessionsTab-GYrtNt4_.js → SessionsTab-duEyKw7t.js} +2 -2
  36. package/extensions/dashboard-client/dist/assets/{SessionsTab-GYrtNt4_.js.map → SessionsTab-duEyKw7t.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/{SetupTab-_1xa6eTJ.js → SetupTab-Dooq2vR4.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{SetupTab-_1xa6eTJ.js.map → SetupTab-Dooq2vR4.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Ciu8anVG.js → TimeSavedCard-CBIPgwK6.js} +2 -2
  40. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Ciu8anVG.js.map → TimeSavedCard-CBIPgwK6.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-BhXLIjWr.js → TurnMemoryView-BBnlvBRc.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-BhXLIjWr.js.map → TurnMemoryView-BBnlvBRc.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/TurnsTab-DuJmr4S6.js +2 -0
  44. package/extensions/dashboard-client/dist/assets/{TurnsTab-C-f3DggL.js.map → TurnsTab-DuJmr4S6.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-D97V04WE.js → VcStatusBadge-fU5-lO5O.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-D97V04WE.js.map → VcStatusBadge-fU5-lO5O.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-cyDJPAPB.js → VectorCortexTab-D5ef9CPz.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-cyDJPAPB.js.map → VectorCortexTab-D5ef9CPz.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{WikiTab-dQ96DyjP.js → WikiTab-D5f8LD_4.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{WikiTab-dQ96DyjP.js.map → WikiTab-D5f8LD_4.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{button-B1beLEiV.js → button-DzfeNezP.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{button-B1beLEiV.js.map → button-DzfeNezP.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/{card-CK9KH_ob.js → card-OZB1m8yv.js} +2 -2
  54. package/extensions/dashboard-client/dist/assets/{card-CK9KH_ob.js.map → card-OZB1m8yv.js.map} +1 -1
  55. package/extensions/dashboard-client/dist/assets/{client-extra-gN7xjggX.js → client-extra-DmQSTHzm.js} +2 -2
  56. package/extensions/dashboard-client/dist/assets/{client-extra-gN7xjggX.js.map → client-extra-DmQSTHzm.js.map} +1 -1
  57. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-MB2_0u55.js → generateCategoricalChart-o4NdniRd.js} +2 -2
  58. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-MB2_0u55.js.map → generateCategoricalChart-o4NdniRd.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/{index-CKVd_Ym_.js → index-BBhaR8pI.js} +3 -3
  60. package/extensions/dashboard-client/dist/assets/{index-CKVd_Ym_.js.map → index-BBhaR8pI.js.map} +1 -1
  61. package/extensions/dashboard-client/dist/assets/{switch-CswmYrO_.js → switch-WUfyEw15.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{switch-CswmYrO_.js.map → switch-WUfyEw15.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/{toggle-CMepFsf0.js → toggle-CoNdXeaQ.js} +2 -2
  64. package/extensions/dashboard-client/dist/assets/{toggle-CMepFsf0.js.map → toggle-CoNdXeaQ.js.map} +1 -1
  65. package/extensions/dashboard-client/dist/assets/{useSSE-Bl55LQFZ.js → useSSE-5AzRO3h7.js} +2 -2
  66. package/extensions/dashboard-client/dist/assets/{useSSE-Bl55LQFZ.js.map → useSSE-5AzRO3h7.js.map} +1 -1
  67. package/extensions/dashboard-client/dist/index.html +1 -1
  68. package/extensions/dashboard-client/src/components/RepoContextStack.tsx +37 -11
  69. package/extensions/dashboard-client/src/components/SessionContextGauges.tsx +10 -3
  70. package/extensions/mega-compact-s38.test/_helpers.ts +1 -1
  71. package/extensions/mega-compact.test/_helpers.ts +3 -1
  72. package/extensions/mega-events/agent-handlers/agentEndHandler.ts +2 -2
  73. package/extensions/mega-events/agent-handlers/turnEndHandler/errorRetry-transient.ts +170 -0
  74. package/extensions/mega-events/agent-handlers/turnEndHandler/errorRetry.ts +12 -147
  75. package/extensions/mega-events/compact-handlers.ts +3 -3
  76. package/extensions/mega-events/outage-advisor.ts +5 -5
  77. package/extensions/mega-events/send-safe.ts +35 -4
  78. package/package.json +1 -1
  79. package/extensions/dashboard-client/dist/assets/MetricsTab-Bz0Mdyb_.js +0 -2
  80. package/extensions/dashboard-client/dist/assets/OverviewTab-B-eZ-eDR.js +0 -16
  81. package/extensions/dashboard-client/dist/assets/OverviewTab-B-eZ-eDR.js.map +0 -1
  82. package/extensions/dashboard-client/dist/assets/TurnsTab-C-f3DggL.js +0 -2
@@ -0,0 +1,170 @@
1
+ /**
2
+ * turnEndHandler/errorRetry-transient.ts — transient/permanent retry branch.
3
+ *
4
+ * Extracted from errorRetry.ts (delegate-shell split) to keep every source
5
+ * file under the extensions soft limit. Contains the S38.6 circuit breaker,
6
+ * R10 provider-outage advisory, per-burst max, R2 session cap, R1 in-flight
7
+ * dedup + gating backoff, and the actual retry nudge send.
8
+ */
9
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
10
+ import type { MegaRuntime } from "../../../mega-runtime.js";
11
+ import type { MegaConfig } from "../../../mega-config.js";
12
+ import { errorRetryBackoffMs } from "../../error-classifier.js";
13
+ import { safeSendInvisibleMessage } from "../../send-safe.js";
14
+ import { maybeSendProviderOutageAdvisory } from "../../outage-advisor.js";
15
+ import type { TurnEndEvent } from "./event.js";
16
+
17
+ /** Context needed from the caller's scope for the transient/permanent branch. */
18
+ export interface TransientRetryContext {
19
+ readonly effectiveCategory: string;
20
+ readonly detail: { signal?: string };
21
+ readonly errSig: string | undefined;
22
+ }
23
+
24
+ /** Handle the transient or permanent error-retry path. Non-fatal. */
25
+ export async function transientRetry(
26
+ event: TurnEndEvent,
27
+ _ctx: ExtensionContext,
28
+ pi: ExtensionAPI,
29
+ runtime: MegaRuntime,
30
+ config: MegaConfig,
31
+ tc: TransientRetryContext,
32
+ ): Promise<void> {
33
+ const { effectiveCategory, detail, errSig } = tc;
34
+ // S38.7: hard-stop switch — bypass ALL retry logic when set.
35
+ if (config.errorRetryHardStop) {
36
+ runtime.rt.errorRetryCount = 0;
37
+ runtime.dashboard.event("error_retry_disabled", {
38
+ category: effectiveCategory,
39
+ turnIndex: event.turnIndex,
40
+ reason: "hard-stop",
41
+ });
42
+ return; // early exit — no retry
43
+ }
44
+ // S38.6: circuit-breaker — stop retrying after too many consecutive errors.
45
+ runtime.rt.consecutiveErrors++;
46
+ // R10: send calm "provider outage" advisory once per episode.
47
+ await maybeSendProviderOutageAdvisory(
48
+ effectiveCategory, runtime, pi, config,
49
+ { signal: detail.signal, rawText: (errSig || '').slice(0, 500) },
50
+ );
51
+ if (runtime.rt.consecutiveErrors > config.maxConsecutiveErrors) {
52
+ runtime.dashboard.event("error_retry_circuit_open", {
53
+ consecutive: runtime.rt.consecutiveErrors,
54
+ max: config.maxConsecutiveErrors,
55
+ turnIndex: event.turnIndex,
56
+ });
57
+ runtime.logger.warn("error-retry-circuit-open", {
58
+ sessionId: runtime.rt.sessionId,
59
+ consecutive: runtime.rt.consecutiveErrors,
60
+ max: config.maxConsecutiveErrors,
61
+ });
62
+ return; // early exit — circuit breaker tripped
63
+ }
64
+ const max =
65
+ effectiveCategory === "transient"
66
+ ? config.autoRetryTransientMax
67
+ : config.autoRetryPermanentMax;
68
+ // max === 0 disables the category entirely (revert to S28-only).
69
+ if (max <= 0) {
70
+ runtime.rt.errorRetryCount = 0;
71
+ return;
72
+ }
73
+ runtime.rt.errorRetryCount++;
74
+ if (runtime.rt.errorRetryCount > max) {
75
+ // Exhausted — surface the error, reset for the next burst.
76
+ runtime.dashboard.event("error_retry_exhausted", {
77
+ category: effectiveCategory,
78
+ count: runtime.rt.errorRetryCount,
79
+ max,
80
+ turnIndex: event.turnIndex,
81
+ });
82
+ runtime.logger.info("error-retry-exhausted", {
83
+ sessionId: runtime.rt.sessionId,
84
+ category: effectiveCategory,
85
+ count: runtime.rt.errorRetryCount,
86
+ max,
87
+ });
88
+ runtime.rt.errorRetryCount = 0;
89
+ return;
90
+ }
91
+ // R2: session-global cap — total S38 nudges per session across ALL bursts.
92
+ // Independent of the per-burst max and the circuit breaker. Hitting it is
93
+ // terminal for the session: log + dashboard event, stop nudging. `0` disables.
94
+ if (
95
+ config.errorRetrySessionMax > 0 &&
96
+ runtime.rt.errorRetrySessionCount >= config.errorRetrySessionMax
97
+ ) {
98
+ runtime.dashboard.event("error_retry_session_exhausted", {
99
+ count: runtime.rt.errorRetrySessionCount,
100
+ max: config.errorRetrySessionMax,
101
+ category: effectiveCategory,
102
+ turnIndex: event.turnIndex,
103
+ });
104
+ runtime.logger.warn("error-retry-session-exhausted", {
105
+ sessionId: runtime.rt.sessionId,
106
+ count: runtime.rt.errorRetrySessionCount,
107
+ max: config.errorRetrySessionMax,
108
+ category: effectiveCategory,
109
+ });
110
+ runtime.rt.errorRetryCount = 0;
111
+ return; // terminal for the session — no nudge
112
+ }
113
+ // R1: in-flight nudge dedup — a nudge queued via deliverAs:'followUp' must
114
+ // not be re-sent until consumed by an actual new agent turn (turn_start
115
+ // resets retryNudgePending). Without this, a fast-erroring provider + a
116
+ // per-turn nudge → N nudges queue up and pi dispatches N retry turns, each
117
+ // re-submitting the same failing prompt (the 2026-07-28 incident).
118
+ if (runtime.rt.retryNudgePending) {
119
+ runtime.dashboard.event("error_retry_dedup_skip", {
120
+ category: effectiveCategory,
121
+ count: runtime.rt.errorRetryCount,
122
+ max,
123
+ turnIndex: event.turnIndex,
124
+ });
125
+ return; // pending nudge not yet consumed — skip
126
+ }
127
+ // R1: gating backoff — errorRetryUntil is GATING. A nudge cannot fire before
128
+ // the previous backoff elapses. Paces retries (5s/10s/20s/30s default).
129
+ const now = Date.now();
130
+ if (now < runtime.rt.errorRetryUntil) {
131
+ runtime.dashboard.event("error_retry_backoff_skip", {
132
+ category: effectiveCategory,
133
+ count: runtime.rt.errorRetryCount,
134
+ max,
135
+ turnIndex: event.turnIndex,
136
+ });
137
+ return; // backoff not elapsed — skip
138
+ }
139
+ // Fire the retry nudge. Set pending (R1 dedup) + backoff (R1 pacing) +
140
+ // session count (R2 cap) BEFORE the await so a re-entrant turn_end during
141
+ // the send can't double-fire.
142
+ runtime.rt.retryNudgePending = true;
143
+ runtime.rt.lastErrorRetryAt = now;
144
+ runtime.rt.errorRetryUntil =
145
+ now +
146
+ errorRetryBackoffMs(
147
+ runtime.rt.errorRetryCount,
148
+ config.errorRetryBackoffMs,
149
+ );
150
+ runtime.rt.errorRetrySessionCount++;
151
+ runtime.dashboard.event("error_retry", {
152
+ category: effectiveCategory,
153
+ count: runtime.rt.errorRetryCount,
154
+ max,
155
+ turnIndex: event.turnIndex,
156
+ });
157
+ runtime.logger.info("error-retry", {
158
+ sessionId: runtime.rt.sessionId,
159
+ category: effectiveCategory,
160
+ count: runtime.rt.errorRetryCount,
161
+ max,
162
+ });
163
+ // PREVENT-PI-003: user-role only (queued + catch-guarded).
164
+ // Invisible: display:false so the retry trigger fires without
165
+ // rendering "Follow-up:" spam in the conversation UI.
166
+ await safeSendInvisibleMessage(
167
+ pi,
168
+ "[mega-compact] the last turn ended with an error; please retry.",
169
+ );
170
+ }
@@ -17,12 +17,11 @@ import type { MegaConfig } from "../../../mega-config.js";
17
17
  import {
18
18
  classifyError,
19
19
  classifyErrorDetailed,
20
- errorRetryBackoffMs,
21
20
  extractErrorSignature,
22
21
  isKnownRetryableTransient,
23
22
  } from "../../error-classifier.js";
24
- import { safeSendUserMessage } from "../../send-safe.js";
25
- import { maybeSendProviderOutageAdvisory } from "../../outage-advisor.js";
23
+ import { safeSendInvisibleMessage } from "../../send-safe.js";
24
+ import { transientRetry } from "./errorRetry-transient.js";
26
25
  import type { TurnEndEvent } from "./event.js";
27
26
 
28
27
  /** S38: broader error-retry safety net. Non-fatal end-to-end. */
@@ -232,7 +231,10 @@ export async function errorRetry(
232
231
  // Default ON (advisoryChannel=true): dashboard-only, no user message.
233
232
  if (!config.advisoryChannel) {
234
233
  // PREVENT-PI-003: user-role sendUserMessage only.
235
- await safeSendUserMessage(
234
+ // Invisible: display:false — the dashboard event + log already
235
+ // capture the poisoned-context signal; the user does not need a
236
+ // visible "Follow-up:" message.
237
+ await safeSendInvisibleMessage(
236
238
  pi,
237
239
  "[mega-compact] this session's context may be poisoned (the provider is rejecting every request). Run /clear or /new to start a fresh context.",
238
240
  );
@@ -270,149 +272,12 @@ export async function errorRetry(
270
272
  }
271
273
  } else {
272
274
  // (5) transient or permanent — retry with exponential backoff.
273
- // S38.7: hard-stop switch — bypass ALL retry logic when set.
274
- if (config.errorRetryHardStop) {
275
- runtime.rt.errorRetryCount = 0;
276
- runtime.dashboard.event("error_retry_disabled", {
277
- category: effectiveCategory,
278
- turnIndex: event.turnIndex,
279
- reason: "hard-stop",
280
- });
281
- return; // early exit — no retry
282
- }
283
- // S38.6: circuit-breaker — stop retrying after too many consecutive errors.
284
- runtime.rt.consecutiveErrors++;
285
- // R10: send calm "provider outage" advisory once per episode.
286
- await maybeSendProviderOutageAdvisory(
287
- effectiveCategory, runtime, pi, config,
288
- { signal: detail.signal, rawText: (errSig || '').slice(0, 500) },
289
- );
290
- if (runtime.rt.consecutiveErrors > config.maxConsecutiveErrors) {
291
- runtime.dashboard.event("error_retry_circuit_open", {
292
- consecutive: runtime.rt.consecutiveErrors,
293
- max: config.maxConsecutiveErrors,
294
- turnIndex: event.turnIndex,
295
- });
296
- runtime.logger.warn("error-retry-circuit-open", {
297
- sessionId: runtime.rt.sessionId,
298
- consecutive: runtime.rt.consecutiveErrors,
299
- max: config.maxConsecutiveErrors,
300
- });
301
- return; // early exit — circuit breaker tripped
302
- }
303
- const max =
304
- effectiveCategory === "transient"
305
- ? config.autoRetryTransientMax
306
- : config.autoRetryPermanentMax;
307
- // max === 0 disables the category entirely (revert to S28-only).
308
- if (max <= 0) {
309
- runtime.rt.errorRetryCount = 0;
310
- } else {
311
- runtime.rt.errorRetryCount++;
312
- if (runtime.rt.errorRetryCount > max) {
313
- // Exhausted — surface the error, reset for the next burst.
314
- runtime.dashboard.event("error_retry_exhausted", {
315
- category: effectiveCategory,
316
- count: runtime.rt.errorRetryCount,
317
- max,
318
- turnIndex: event.turnIndex,
319
- });
320
- runtime.logger.info("error-retry-exhausted", {
321
- sessionId: runtime.rt.sessionId,
322
- category: effectiveCategory,
323
- count: runtime.rt.errorRetryCount,
324
- max,
325
- });
326
- runtime.rt.errorRetryCount = 0;
327
- } else {
328
- // R2: session-global cap — total S38 nudges per session across
329
- // ALL bursts. Independent of the per-burst max and the circuit
330
- // breaker. Hitting it is terminal for the session: log +
331
- // dashboard event, stop nudging. `0` disables (reverts to
332
- // per-burst + circuit-breaker only).
333
- if (
334
- config.errorRetrySessionMax > 0 &&
335
- runtime.rt.errorRetrySessionCount >= config.errorRetrySessionMax
336
- ) {
337
- runtime.dashboard.event("error_retry_session_exhausted", {
338
- count: runtime.rt.errorRetrySessionCount,
339
- max: config.errorRetrySessionMax,
340
- category: effectiveCategory,
341
- turnIndex: event.turnIndex,
342
- });
343
- runtime.logger.warn("error-retry-session-exhausted", {
344
- sessionId: runtime.rt.sessionId,
345
- count: runtime.rt.errorRetrySessionCount,
346
- max: config.errorRetrySessionMax,
347
- category: effectiveCategory,
348
- });
349
- runtime.rt.errorRetryCount = 0;
350
- return; // terminal for the session — no nudge
351
- }
352
- // R1: in-flight nudge dedup — a nudge queued via
353
- // deliverAs:'followUp' must not be re-sent until it has been
354
- // consumed by an actual new agent turn (turn_start resets
355
- // retryNudgePending). Without this, a fast-erroring provider +
356
- // a per-turn nudge → N nudges queue up and pi dispatches N
357
- // retry turns, each re-submitting the same failing prompt
358
- // (the 2026-07-28 incident). errorRetryCount still advances
359
- // (this IS an error turn), so the per-burst max + circuit
360
- // breaker still bound the burst.
361
- if (runtime.rt.retryNudgePending) {
362
- runtime.dashboard.event("error_retry_dedup_skip", {
363
- category: effectiveCategory,
364
- count: runtime.rt.errorRetryCount,
365
- max,
366
- turnIndex: event.turnIndex,
367
- });
368
- return; // pending nudge not yet consumed — skip
369
- }
370
- // R1: gating backoff — errorRetryUntil is now GATING
371
- // (previously documented as non-gating). A nudge cannot fire
372
- // before the previous backoff elapses. This paces retries
373
- // (5s/10s/20s/30s by default) so a fast-erroring provider
374
- // doesn't slam N nudges in <1s.
375
- const now = Date.now();
376
- if (now < runtime.rt.errorRetryUntil) {
377
- runtime.dashboard.event("error_retry_backoff_skip", {
378
- category: effectiveCategory,
379
- count: runtime.rt.errorRetryCount,
380
- max,
381
- turnIndex: event.turnIndex,
382
- });
383
- return; // backoff not elapsed — skip
384
- }
385
- // Fire the retry nudge. Set pending (R1 dedup) + backoff
386
- // (R1 pacing) + session count (R2 cap) BEFORE the await so a
387
- // re-entrant turn_end during the send can't double-fire.
388
- runtime.rt.retryNudgePending = true;
389
- runtime.rt.lastErrorRetryAt = now;
390
- runtime.rt.errorRetryUntil =
391
- now +
392
- errorRetryBackoffMs(
393
- runtime.rt.errorRetryCount,
394
- config.errorRetryBackoffMs,
395
- );
396
- runtime.rt.errorRetrySessionCount++;
397
- runtime.dashboard.event("error_retry", {
398
- category: effectiveCategory,
399
- count: runtime.rt.errorRetryCount,
400
- max,
401
- turnIndex: event.turnIndex,
402
- });
403
- runtime.logger.info("error-retry", {
404
- sessionId: runtime.rt.sessionId,
405
- category: effectiveCategory,
406
- count: runtime.rt.errorRetryCount,
407
- max,
408
- });
409
- // PREVENT-PI-003: user-role sendUserMessage only (queued + catch-guarded).
410
- await safeSendUserMessage(
411
- pi,
412
- "[mega-compact] the last turn ended with an error; please retry.",
413
- );
414
- }
415
- }
275
+ // Delegated to errorRetry-transient.ts (delegate-shell split).
276
+ await transientRetry(event, ctx, pi, runtime, config, {
277
+ effectiveCategory,
278
+ detail,
279
+ errSig,
280
+ });
416
281
  }
417
282
  }
418
283
  } catch {
@@ -22,7 +22,7 @@ import type { MegaConfig } from "../mega-config.js";
22
22
  import { recordScore, getDedupStats } from "../../src/store/sqlite.js";
23
23
  import { evaluateAndUnlockAchievements } from "../../src/store/sqlite/game-achievements.js";
24
24
  import { resolveRepoRoot } from "../mega-config.js";
25
- import { safeSendUserMessage } from "./send-safe.js";
25
+ import { safeSendInvisibleMessage } from "./send-safe.js";
26
26
 
27
27
  /**
28
28
  * Build a minimal fallback compaction so pi never runs its throwing compact().
@@ -59,7 +59,7 @@ function fallbackCompaction(
59
59
  * Debounced resume-nudge: restart the agent loop after a compaction (which
60
60
  * may have stopped it). Idempotent — one nudge per 30s, never blocks.
61
61
  *
62
- * Uses safeSendUserMessage ({ deliverAs: 'followUp' } + catch-guard) so that a
62
+ * Uses safeSendInvisibleMessage ({ deliverAs: 'followUp' } + catch-guard) so that a
63
63
  * nudge fired during session_before_compact (which is mid-prompt-submission,
64
64
  * so the agent can be busy) QUEUES instead of throwing
65
65
  * "Agent is already processing. Specify streamingBehavior (steer or followUp)".
@@ -70,7 +70,7 @@ async function nudgeResume(pi: ExtensionAPI, runtime: MegaRuntime): Promise<void
70
70
  if (now >= runtime.resumeNudgeUntil) {
71
71
  runtime.resumeNudgeUntil = now + 30_000;
72
72
  runtime.rt.extensionInitiatedTurn = true; // R13: suppress self-classification
73
- await safeSendUserMessage(
73
+ await safeSendInvisibleMessage(
74
74
  pi,
75
75
  "[mega-compact] continue from the compacted context above.",
76
76
  );
@@ -9,12 +9,12 @@
9
9
  * Distinct from the poisoned-context /clear advise: the outage advisory is
10
10
  * for transient errors where the user's context is fine.
11
11
  *
12
- * PREVENT-PI-003: sends via safeSendUserMessage (user-role only).
12
+ * PREVENT-PI-003: sends via safeSendInvisibleMessage (user-role only).
13
13
  * PREVENT-PI-004: local ctx call, no network.
14
14
  */
15
15
 
16
16
  import type { MegaRuntime } from "../mega-runtime.js";
17
- import { safeSendUserMessage } from "./send-safe.js";
17
+ import { safeSendInvisibleMessage } from "./send-safe.js";
18
18
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
19
19
 
20
20
  /** R11: optional diagnostic detail passed from the classifier. */
@@ -31,7 +31,7 @@ export interface OutageDetail {
31
31
  *
32
32
  * @param effectiveCategory — must be "transient" for the advisory to fire.
33
33
  * @param runtime — the live MegaRuntime (mutated on advisory fire).
34
- * @param pi — pi ExtensionAPI for safeSendUserMessage.
34
+ * @param pi — pi ExtensionAPI for safeSendInvisibleMessage.
35
35
  * @param config — providerOutageAdviseThreshold config.
36
36
  * @param detail — R11: optional signal + rawText for forensics.
37
37
  */
@@ -70,8 +70,8 @@ export async function maybeSendProviderOutageAdvisory(
70
70
  // injecting into the conversation scares users and triggers false-positive
71
71
  // re-classification of the resulting turn (2026-07-31 incident).
72
72
  if (!config.advisoryChannel) {
73
- // Legacy path (flag OFF): user-role message injection.
74
- await safeSendUserMessage(
73
+ // Legacy path (flag OFF): invisible user-role message (display:false).
74
+ await safeSendInvisibleMessage(
75
75
  pi,
76
76
  `[mega-compact] the provider is having issues (${runtime.rt.consecutiveErrors} consecutive failures — timeouts/5xx/rate-limits). Retries are bounded and continue automatically; your context is fine — do NOT clear or reset it. Work resumes as soon as the provider recovers.`,
77
77
  );
@@ -1,16 +1,20 @@
1
1
  /**
2
- * send-safe.ts — queue-safe wrapper for pi.sendUserMessage.
2
+ * send-safe.ts — queue-safe wrappers for pi.sendUserMessage / pi.sendMessage.
3
3
  *
4
4
  * All extension-initiated user-role nudges (resume after compaction, length-stop
5
- * continue, error-retry) MUST go through this wrapper. It:
6
- * 1. Passes { deliverAs: 'followUp' } so that when the agent is busy (e.g. a
5
+ * continue, error-retry) MUST go through these wrappers. They:
6
+ * 1. Pass { deliverAs: 'followUp' } so that when the agent is busy (e.g. a
7
7
  * resume nudge fired during session_before_compact, which is mid-prompt
8
8
  * submission) pi QUEUES the message instead of throwing
9
9
  * "Agent is already processing. Specify streamingBehavior (steer or
10
10
  * followUp) to queue the message" (pi agent-session.js:830).
11
- * 2. Awaits the call and catch-guards it so a failed/queued nudge never throws
11
+ * 2. Await the call and catch-guard it so a failed/queued nudge never throws
12
12
  * or produces an unhandled rejection — it must never block the agent loop.
13
13
  *
14
+ * safeSendUserMessage renders the text in the conversation UI (visible).
15
+ * safeSendInvisibleMessage delivers via pi.sendMessage with display: false —
16
+ * the agent receives the retry trigger but the user never sees the text.
17
+ *
14
18
  * PREVENT-PI-003: user-role sendUserMessage only (no role:'system' injection).
15
19
  * PREVENT-PI-004: local pi ctx call, no network.
16
20
  */
@@ -19,6 +23,7 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
19
23
  /**
20
24
  * safeSendUserMessage — await + catch-guard + queue-safe wrapper for
21
25
  * pi.sendUserMessage. Never throws; never produces an unhandled rejection.
26
+ * The message IS visible in the conversation UI ("Follow-up:").
22
27
  */
23
28
  export async function safeSendUserMessage(
24
29
  pi: ExtensionAPI,
@@ -35,3 +40,29 @@ export async function safeSendUserMessage(
35
40
  /* non-fatal: a failed/queued nudge never blocks the agent loop */
36
41
  }
37
42
  }
43
+
44
+ /**
45
+ * safeSendInvisibleMessage — like safeSendUserMessage but uses pi.sendMessage
46
+ * with `display: false` so the retry trigger is delivered to the agent WITHOUT
47
+ * rendering in the conversation UI. Fixes the "Follow-up: [mega-compact] ..."
48
+ * pile-up when the API retries repeatedly — the retry mechanism still fires,
49
+ * the user just doesn't see the queued messages.
50
+ */
51
+ export async function safeSendInvisibleMessage(
52
+ pi: ExtensionAPI,
53
+ content: string,
54
+ ): Promise<void> {
55
+ try {
56
+ await (
57
+ pi.sendMessage as (
58
+ m: { customType: string; content: string; display: boolean },
59
+ o?: { deliverAs?: "steer" | "followUp" },
60
+ ) => Promise<void> | void
61
+ )(
62
+ { customType: "mega-compact-retry", content, display: false },
63
+ { deliverAs: "followUp" },
64
+ );
65
+ } catch {
66
+ /* non-fatal: a failed/queued nudge never blocks the agent loop */
67
+ }
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.20.65",
3
+ "version": "0.20.67",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -1,2 +0,0 @@
1
- import{j as r}from"./index-CKVd_Ym_.js";import{M as t}from"./MetricsCards-DCPuCnrw.js";import"./card-CK9KH_ob.js";import"./generateCategoricalChart-MB2_0u55.js";import"./BarChart-CY2FndXC.js";import"./AreaChart-BpjHNUZm.js";function e(){return r.jsx(t,{})}export{e as default};
2
- //# sourceMappingURL=MetricsTab-Bz0Mdyb_.js.map