@eduardo191labs/opencode-free-pi 0.7.5 → 0.7.6

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/README.md CHANGED
@@ -208,7 +208,10 @@ Después de iniciar sesión, ejecuta `/reload` en OpenCode o reinícialo.
208
208
  petición se reintenta una vez de inmediato y, si aun así falla, el plugin
209
209
  vuelve a pedir el catálogo en segundo plano (2 s, 5 s, 10 s, 20 s, 30 s y 60 s)
210
210
  y, en cuanto lo obtiene, registra los modelos y recarga proveedor y modelo en
211
- caliente. No hace falta reiniciar OpenCode ni elegir otra carpeta.
211
+ caliente. Si la caída dura más que esa ráfaga, sigue reintentando cada 60 s
212
+ mientras no haya ningún modelo registrado, así que un arranque sin red (VPN
213
+ caída, DPI bloqueando el gateway) se recupera solo cuando vuelve la conexión.
214
+ No hace falta reiniciar OpenCode ni elegir otra carpeta.
212
215
  - **Aislamiento por proveedor**: todo lo que añade el plugin —herramientas,
213
216
  cabeceras, anuncios, reglas de prompt, compactación, reintentos, topes de
214
217
  tokens y ajustes— se aplica solo a `free-pi` y `free-pi-defense`. Los demás
@@ -424,6 +427,9 @@ puede completarse el hook de reintento rota el id para los siguientes pasos. Un
424
427
  turno que se aborta o falla a mitad de stream marca su `x-session-id` como sucio:
425
428
  la siguiente petición arranca directamente con un id nuevo y libera el anterior,
426
429
  de modo que la sesión continúa sin interrupciones y sin pasar por un reintento.
430
+ Una compactación también deja el id marcado: el resumen y el turno siguiente se
431
+ solapan en el gateway y ese solape producía un 429 `concurrent` y un replay en
432
+ cada compactación, así que el turno posterior ya sale con un id nuevo.
427
433
 
428
434
  Los fallos de transporte (`ECONNREFUSED`, `ECONNRESET`, `ETIMEDOUT`, DNS
429
435
  temporal, `socket hang up`) no son límites de cuenta: el plugin los reintenta con
@@ -59,7 +59,7 @@ export declare const DEFAULT_THINKING_LEVELS: readonly ["none", "minimal", "low"
59
59
  * models show: skipping analysis, inventing verification, and ignoring the
60
60
  * context the conversation already established.
61
61
  */
62
- export declare const FREE_PI_GUIDANCE = "# free-pi working rules\n- Answer the user's latest request and keep their constraints; do not switch to a different task.\n- Slow down on multi-step work (arithmetic, counting, logic, dates, units, planning, debugging): write out each step, recompute the result a second way, and only then answer. On those tasks a correct answer after a dozen explicit steps beats a fast guess; do not stop at the first plausible number.\n- Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass.\n- Treat the conversation above as memory: reuse earlier decisions, file paths, identifiers and results. If something is genuinely missing, say what is missing instead of guessing.\n- Use the available tools (`read`, `grep`, `glob`, `shell`, `edit`) for real work; do not describe hypothetical commands as if they ran. Prefer `read`, `grep` and `glob` over shell for inspecting files.\n- The `shell` tool runs a portable scanner, not a full bash. Heredocs (`<<EOF`), chained one-liners with nested or heavy-escaped quotes, and some shells' loops are rejected before they run. Put any complex script in a file with `write` and run that file; on Windows write PowerShell syntax.\n- Reply in the language of the user's latest message; keep code, paths and identifiers unchanged.\n- Delegate large or self-contained work with OpenCode's native `subagent` tool: `free-pi/scout` and `free-pi/planner` for read-only recon and planning, `free-pi/worker` for a full task, `free-pi/reviewer` for review. A subagent runs in its own context and reports back; never launch a subagent from inside one. The `subagent` tool returns a child `sessionID` and OpenCode injects the child's report when it goes idle; to inspect what that child actually did, call `free_pi_subagent_read` with its `sessionID` (omit it to list this session's children).\n- Load a skill with the native `skill` tool when its description matches the task.\n- `AGENTS.md` and the files listed under `instructions` are the project's memory. Follow them; do not restate or replace them.\n- Never claim to have compacted, summarized or cleared context unless that actually happened.\n- Never answer with a session summary or with `## Objective` / `## Work State` blocks; that format belongs to compaction. If the work is unfinished, take the next concrete action instead of describing the state.\n- Continue until the request is finished, then report concisely what changed and what you verified.";
62
+ export declare const FREE_PI_GUIDANCE = "# free-pi working rules\n- Answer the user's latest request and keep their constraints; do not switch to a different task.\n- Slow down on multi-step work (arithmetic, counting, logic, dates, units, planning, debugging): write out each step, recompute the result a second way, and only then answer. On those tasks a correct answer after a dozen explicit steps beats a fast guess; do not stop at the first plausible number.\n- Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass. In `edit`, `oldString` must differ from `newString` and match exactly once; add surrounding lines when it is ambiguous.\n- Treat the conversation above as memory: reuse earlier decisions, file paths, identifiers and results. If something is genuinely missing, say what is missing instead of guessing.\n- Use the available tools (`read`, `grep`, `glob`, `shell`, `edit`) for real work; do not describe hypothetical commands as if they ran. Prefer `read`, `grep` and `glob` over shell for inspecting files.\n- The `shell` tool runs a portable scanner, not a full bash. Heredocs (`<<EOF`), chained one-liners with nested or heavy-escaped quotes, and some shells' loops are rejected before they run. Put any complex script in a file with `write` and run that file. On Windows the shell is PowerShell: use `Get-ChildItem`/`Select-String`, not `dir /b`, `findstr` or `cmd /c`.\n- Reply in the language of the user's latest message; keep code, paths and identifiers unchanged.\n- Delegate large or self-contained work with OpenCode's native `subagent` tool: `free-pi/scout` and `free-pi/planner` for read-only recon and planning, `free-pi/worker` for a full task, `free-pi/reviewer` for review. A subagent runs in its own context and reports back; never launch a subagent from inside one. The `subagent` tool returns a child `sessionID` and OpenCode injects the child's report when it goes idle; to inspect what that child actually did, call `free_pi_subagent_read` with its `sessionID` (omit it to list this session's children).\n- Load a skill with the native `skill` tool when its description matches the task.\n- `AGENTS.md` and the files listed under `instructions` are the project's memory. Follow them; do not restate or replace them.\n- Never claim to have compacted, summarized or cleared context unless that actually happened.\n- Never answer with a session summary or with `## Objective` / `## Work State` blocks; that format belongs to compaction. If the work is unfinished, take the next concrete action instead of describing the state.\n- Continue until the request is finished, then report concisely what changed and what you verified.";
63
63
  export declare const FREE_PI_GUIDANCE_MARKER = "# free-pi working rules";
64
64
  /**
65
65
  * Appended to OpenCode's compaction request. Its default summary prompt asks
@@ -76,7 +76,7 @@ export declare const FREE_PI_COMPACTION_MARKER = "# free-pi compaction rules";
76
76
  * 100k-token system prompt are easy to ignore. It is not a user instruction and
77
77
  * never becomes part of the stored conversation.
78
78
  */
79
- export declare const TURN_REMINDER = "# free-pi turn check (not a user request)\nYou are in a normal working turn, not a compaction.\n- Never answer with `## Objective`, `## Requirements`, `## Work State` or a session summary; that format belongs only to a compaction. Earlier sections with those names are history, not an answer template.\n- If the user asked to search, find, analyze or verify something, call the matching tool first (grep/glob/shell for files, websearch/webfetch for the web) and report what it returned.\n- Keep each shell command simple: no heredocs and no nested-quote one-liners. Write a script file and run it when the command is complex.\n- If the task is unfinished, call the next tool now instead of describing the state.";
79
+ export declare const TURN_REMINDER = "# free-pi turn check (not a user request)\nYou are in a normal working turn, not a compaction.\n- Never answer with `## Objective`, `## Requirements`, `## Work State` or a session summary; that format belongs only to a compaction. Earlier sections with those names are history, not an answer template.\n- If the user asked to search, find, analyze or verify something, call the matching tool first (grep/glob/shell for files, websearch/webfetch for the web) and report what it returned.\n- Keep each shell command simple: no heredocs, no nested-quote one-liners, and PowerShell cmdlets on Windows. Write a script file and run it when the command is complex.\n- If the task is unfinished, call the next tool now instead of describing the state.";
80
80
  export declare const TURN_REMINDER_MARKER = "# free-pi turn check";
81
81
  /**
82
82
  * OpenCode keeps only the latest exchange beside a summary, so after a
@@ -149,6 +149,16 @@ export declare const CATALOG_RETRY_MS = 1000;
149
149
  * the models, so a transient timeout heals without restarting OpenCode.
150
150
  */
151
151
  export declare const CATALOG_RECOVERY_DELAYS_MS: readonly [2000, 5000, 10000, 20000, 30000, 60000];
152
+ /**
153
+ * Once the burst above is exhausted, keep trying at this interval for as long
154
+ * as no model is registered. A cold start during a long outage (VPN down, DPI
155
+ * blocking the gateway) otherwise leaves the provider with zero models, and
156
+ * OpenCode answers every free-pi prompt with "Model unavailable … not available
157
+ * in this session's location" until the app is restarted.
158
+ */
159
+ export declare const CATALOG_RECOVERY_INTERVAL_MS = 60000;
160
+ /** Log one warning every N background attempts instead of one per minute. */
161
+ export declare const CATALOG_RECOVERY_LOG_EVERY = 10;
152
162
  export declare const REGISTRY_TTL_MS: number;
153
163
  export declare const REGISTRY_RETRY_MS = 60000;
154
164
  export declare const REGISTRY_TIMEOUT_MS = 3500;
package/dist/constants.js CHANGED
@@ -76,10 +76,10 @@ export const DEFAULT_THINKING_LEVELS = [
76
76
  export const FREE_PI_GUIDANCE = `# free-pi working rules
77
77
  - Answer the user's latest request and keep their constraints; do not switch to a different task.
78
78
  - Slow down on multi-step work (arithmetic, counting, logic, dates, units, planning, debugging): write out each step, recompute the result a second way, and only then answer. On those tasks a correct answer after a dozen explicit steps beats a fast guess; do not stop at the first plausible number.
79
- - Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass.
79
+ - Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass. In \`edit\`, \`oldString\` must differ from \`newString\` and match exactly once; add surrounding lines when it is ambiguous.
80
80
  - Treat the conversation above as memory: reuse earlier decisions, file paths, identifiers and results. If something is genuinely missing, say what is missing instead of guessing.
81
81
  - Use the available tools (\`read\`, \`grep\`, \`glob\`, \`shell\`, \`edit\`) for real work; do not describe hypothetical commands as if they ran. Prefer \`read\`, \`grep\` and \`glob\` over shell for inspecting files.
82
- - The \`shell\` tool runs a portable scanner, not a full bash. Heredocs (\`<<EOF\`), chained one-liners with nested or heavy-escaped quotes, and some shells' loops are rejected before they run. Put any complex script in a file with \`write\` and run that file; on Windows write PowerShell syntax.
82
+ - The \`shell\` tool runs a portable scanner, not a full bash. Heredocs (\`<<EOF\`), chained one-liners with nested or heavy-escaped quotes, and some shells' loops are rejected before they run. Put any complex script in a file with \`write\` and run that file. On Windows the shell is PowerShell: use \`Get-ChildItem\`/\`Select-String\`, not \`dir /b\`, \`findstr\` or \`cmd /c\`.
83
83
  - Reply in the language of the user's latest message; keep code, paths and identifiers unchanged.
84
84
  - Delegate large or self-contained work with OpenCode's native \`subagent\` tool: \`free-pi/scout\` and \`free-pi/planner\` for read-only recon and planning, \`free-pi/worker\` for a full task, \`free-pi/reviewer\` for review. A subagent runs in its own context and reports back; never launch a subagent from inside one. The \`subagent\` tool returns a child \`sessionID\` and OpenCode injects the child's report when it goes idle; to inspect what that child actually did, call \`free_pi_subagent_read\` with its \`sessionID\` (omit it to list this session's children).
85
85
  - Load a skill with the native \`skill\` tool when its description matches the task.
@@ -112,7 +112,7 @@ export const TURN_REMINDER = `# free-pi turn check (not a user request)
112
112
  You are in a normal working turn, not a compaction.
113
113
  - Never answer with \`## Objective\`, \`## Requirements\`, \`## Work State\` or a session summary; that format belongs only to a compaction. Earlier sections with those names are history, not an answer template.
114
114
  - If the user asked to search, find, analyze or verify something, call the matching tool first (grep/glob/shell for files, websearch/webfetch for the web) and report what it returned.
115
- - Keep each shell command simple: no heredocs and no nested-quote one-liners. Write a script file and run it when the command is complex.
115
+ - Keep each shell command simple: no heredocs, no nested-quote one-liners, and PowerShell cmdlets on Windows. Write a script file and run it when the command is complex.
116
116
  - If the task is unfinished, call the next tool now instead of describing the state.`;
117
117
  export const TURN_REMINDER_MARKER = "# free-pi turn check";
118
118
  /**
@@ -188,6 +188,16 @@ export const CATALOG_RETRY_MS = 1_000;
188
188
  export const CATALOG_RECOVERY_DELAYS_MS = [
189
189
  2_000, 5_000, 10_000, 20_000, 30_000, 60_000,
190
190
  ];
191
+ /**
192
+ * Once the burst above is exhausted, keep trying at this interval for as long
193
+ * as no model is registered. A cold start during a long outage (VPN down, DPI
194
+ * blocking the gateway) otherwise leaves the provider with zero models, and
195
+ * OpenCode answers every free-pi prompt with "Model unavailable … not available
196
+ * in this session's location" until the app is restarted.
197
+ */
198
+ export const CATALOG_RECOVERY_INTERVAL_MS = 60_000;
199
+ /** Log one warning every N background attempts instead of one per minute. */
200
+ export const CATALOG_RECOVERY_LOG_EVERY = 10;
191
201
  export const REGISTRY_TTL_MS = 5 * 60_000;
192
202
  export const REGISTRY_RETRY_MS = 60_000;
193
203
  export const REGISTRY_TIMEOUT_MS = 3_500;
package/dist/plugin.js CHANGED
@@ -10,7 +10,7 @@ import { currentLiveLimits, loadLiveLimits, shouldVerifyWindow, verifyGatewayWin
10
10
  import { accountAccess, buildModels, filterAccessibleModels, isReasoningEffort, modelRegistryCandidates, partitionModels, } from "./catalog/models.js";
11
11
  import { fetchModelsRegistry } from "./catalog/registry.js";
12
12
  import { applyProvider } from "./catalog/v2.js";
13
- import { CATALOG_RECOVERY_DELAYS_MS, DEFENSE_PROVIDER_ID, PROVIDER_ID, } from "./constants.js";
13
+ import { CATALOG_RECOVERY_DELAYS_MS, CATALOG_RECOVERY_INTERVAL_MS, CATALOG_RECOVERY_LOG_EVERY, DEFENSE_PROVIDER_ID, PROVIDER_ID, } from "./constants.js";
14
14
  import { registerIntegration } from "./integration/setup.js";
15
15
  import { createLogger } from "./logging.js";
16
16
  import { subscribeEvents } from "./session/events.js";
@@ -275,19 +275,25 @@ async function setup(ctx) {
275
275
  abort.signal.addEventListener("abort", finish, { once: true });
276
276
  });
277
277
  const catalogRecovery = (async () => {
278
- // Only a missing catalog needs recovery; an empty model list after access
279
- // filtering means the account cannot use these models, not a timeout.
280
- if (currentCatalog)
281
- return;
282
- for (const delay of CATALOG_RECOVERY_DELAYS_MS) {
283
- if (abort.signal.aborted || currentMain.length > 0)
284
- return;
278
+ // Keep going while the provider has no models: a failed cold start must heal
279
+ // even if the outage outlasts the initial burst. An empty list because the
280
+ // account filter removed everything is also temporary (quota refreshes).
281
+ let attempt = 0;
282
+ while (!abort.signal.aborted && currentMain.length === 0) {
283
+ const delay = CATALOG_RECOVERY_DELAYS_MS[attempt] ?? CATALOG_RECOVERY_INTERVAL_MS;
284
+ attempt += 1;
285
285
  await waitForAbort(delay);
286
286
  if (abort.signal.aborted || currentMain.length > 0)
287
287
  return;
288
288
  const next = await fetchCatalog(deps).catch(() => undefined);
289
- if (!next)
289
+ if (!next) {
290
+ if (attempt % CATALOG_RECOVERY_LOG_EVERY === 0) {
291
+ log.warn("free-pi catalog is still unreachable; models stay unavailable", {
292
+ attempts: attempt,
293
+ });
294
+ }
290
295
  continue;
296
+ }
291
297
  const parts = partitionModels(next);
292
298
  const accessNow = accountAccess(state.quotaCache?.me);
293
299
  const nextMain = filterAccessibleModels(parts.main, accessNow);
@@ -306,7 +312,6 @@ async function setup(ctx) {
306
312
  });
307
313
  return;
308
314
  }
309
- log.warn("free-pi catalog stayed unreachable; free-pi models remain unavailable", { attempts: CATALOG_RECOVERY_DELAYS_MS.length });
310
315
  })();
311
316
  void catalogRecovery.catch(() => undefined);
312
317
  log.info(`Loaded ${currentMain.length} free-pi model(s) and ${includeDefense ? currentDefense.length : 0} defense model(s)`, {
@@ -244,6 +244,12 @@ async function applyGeneration(deps, event, kind) {
244
244
  // OpenCode sends the messages it is folding into the summary, which is the
245
245
  // same set pi reports through `session_before_compact`.
246
246
  recordCompaction(deps, event.sessionID, Array.isArray(event.messages) ? event.messages.length : 0);
247
+ // The compaction request and the next turn overlap: the runner starts the
248
+ // next step while the gateway still holds this wire session's request slot,
249
+ // which costs a `429 concurrent` and a full replay every time. Rotating the
250
+ // id for the next request avoids that round trip without changing what the
251
+ // model receives (the whole compacted history goes out every time).
252
+ markWireSessionDirty(deps, event.sessionID);
247
253
  }
248
254
  else if (kind === "primary") {
249
255
  // The free models tend to skip planning and claim work they did not do;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eduardo191labs/opencode-free-pi",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "Ad-supported free-pi provider plugin for OpenCode on Windows, Linux, macOS and Termux",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/constants.ts CHANGED
@@ -83,10 +83,10 @@ export const DEFAULT_THINKING_LEVELS = [
83
83
  export const FREE_PI_GUIDANCE = `# free-pi working rules
84
84
  - Answer the user's latest request and keep their constraints; do not switch to a different task.
85
85
  - Slow down on multi-step work (arithmetic, counting, logic, dates, units, planning, debugging): write out each step, recompute the result a second way, and only then answer. On those tasks a correct answer after a dozen explicit steps beats a fast guess; do not stop at the first plausible number.
86
- - Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass.
86
+ - Read the files involved before editing and run the project's checks afterwards. Never say a test, build or command passed unless you ran it and saw it pass. In \`edit\`, \`oldString\` must differ from \`newString\` and match exactly once; add surrounding lines when it is ambiguous.
87
87
  - Treat the conversation above as memory: reuse earlier decisions, file paths, identifiers and results. If something is genuinely missing, say what is missing instead of guessing.
88
88
  - Use the available tools (\`read\`, \`grep\`, \`glob\`, \`shell\`, \`edit\`) for real work; do not describe hypothetical commands as if they ran. Prefer \`read\`, \`grep\` and \`glob\` over shell for inspecting files.
89
- - The \`shell\` tool runs a portable scanner, not a full bash. Heredocs (\`<<EOF\`), chained one-liners with nested or heavy-escaped quotes, and some shells' loops are rejected before they run. Put any complex script in a file with \`write\` and run that file; on Windows write PowerShell syntax.
89
+ - The \`shell\` tool runs a portable scanner, not a full bash. Heredocs (\`<<EOF\`), chained one-liners with nested or heavy-escaped quotes, and some shells' loops are rejected before they run. Put any complex script in a file with \`write\` and run that file. On Windows the shell is PowerShell: use \`Get-ChildItem\`/\`Select-String\`, not \`dir /b\`, \`findstr\` or \`cmd /c\`.
90
90
  - Reply in the language of the user's latest message; keep code, paths and identifiers unchanged.
91
91
  - Delegate large or self-contained work with OpenCode's native \`subagent\` tool: \`free-pi/scout\` and \`free-pi/planner\` for read-only recon and planning, \`free-pi/worker\` for a full task, \`free-pi/reviewer\` for review. A subagent runs in its own context and reports back; never launch a subagent from inside one. The \`subagent\` tool returns a child \`sessionID\` and OpenCode injects the child's report when it goes idle; to inspect what that child actually did, call \`free_pi_subagent_read\` with its \`sessionID\` (omit it to list this session's children).
92
92
  - Load a skill with the native \`skill\` tool when its description matches the task.
@@ -121,7 +121,7 @@ export const TURN_REMINDER = `# free-pi turn check (not a user request)
121
121
  You are in a normal working turn, not a compaction.
122
122
  - Never answer with \`## Objective\`, \`## Requirements\`, \`## Work State\` or a session summary; that format belongs only to a compaction. Earlier sections with those names are history, not an answer template.
123
123
  - If the user asked to search, find, analyze or verify something, call the matching tool first (grep/glob/shell for files, websearch/webfetch for the web) and report what it returned.
124
- - Keep each shell command simple: no heredocs and no nested-quote one-liners. Write a script file and run it when the command is complex.
124
+ - Keep each shell command simple: no heredocs, no nested-quote one-liners, and PowerShell cmdlets on Windows. Write a script file and run it when the command is complex.
125
125
  - If the task is unfinished, call the next tool now instead of describing the state.`;
126
126
  export const TURN_REMINDER_MARKER = "# free-pi turn check";
127
127
 
@@ -207,6 +207,16 @@ export const CATALOG_RETRY_MS = 1_000;
207
207
  export const CATALOG_RECOVERY_DELAYS_MS = [
208
208
  2_000, 5_000, 10_000, 20_000, 30_000, 60_000,
209
209
  ] as const;
210
+ /**
211
+ * Once the burst above is exhausted, keep trying at this interval for as long
212
+ * as no model is registered. A cold start during a long outage (VPN down, DPI
213
+ * blocking the gateway) otherwise leaves the provider with zero models, and
214
+ * OpenCode answers every free-pi prompt with "Model unavailable … not available
215
+ * in this session's location" until the app is restarted.
216
+ */
217
+ export const CATALOG_RECOVERY_INTERVAL_MS = 60_000;
218
+ /** Log one warning every N background attempts instead of one per minute. */
219
+ export const CATALOG_RECOVERY_LOG_EVERY = 10;
210
220
  export const REGISTRY_TTL_MS = 5 * 60_000;
211
221
  export const REGISTRY_RETRY_MS = 60_000;
212
222
  export const REGISTRY_TIMEOUT_MS = 3_500;
package/src/plugin.ts CHANGED
@@ -34,6 +34,8 @@ import { fetchModelsRegistry } from "./catalog/registry.js";
34
34
  import { applyProvider } from "./catalog/v2.js";
35
35
  import {
36
36
  CATALOG_RECOVERY_DELAYS_MS,
37
+ CATALOG_RECOVERY_INTERVAL_MS,
38
+ CATALOG_RECOVERY_LOG_EVERY,
37
39
  DEFENSE_PROVIDER_ID,
38
40
  PROVIDER_ID,
39
41
  } from "./constants.js";
@@ -337,15 +339,25 @@ async function setup(ctx: Plugin.Context): Promise<() => Promise<void>> {
337
339
  abort.signal.addEventListener("abort", finish, { once: true });
338
340
  });
339
341
  const catalogRecovery = (async () => {
340
- // Only a missing catalog needs recovery; an empty model list after access
341
- // filtering means the account cannot use these models, not a timeout.
342
- if (currentCatalog) return;
343
- for (const delay of CATALOG_RECOVERY_DELAYS_MS) {
344
- if (abort.signal.aborted || currentMain.length > 0) return;
342
+ // Keep going while the provider has no models: a failed cold start must heal
343
+ // even if the outage outlasts the initial burst. An empty list because the
344
+ // account filter removed everything is also temporary (quota refreshes).
345
+ let attempt = 0;
346
+ while (!abort.signal.aborted && currentMain.length === 0) {
347
+ const delay =
348
+ CATALOG_RECOVERY_DELAYS_MS[attempt] ?? CATALOG_RECOVERY_INTERVAL_MS;
349
+ attempt += 1;
345
350
  await waitForAbort(delay);
346
351
  if (abort.signal.aborted || currentMain.length > 0) return;
347
352
  const next = await fetchCatalog(deps).catch(() => undefined);
348
- if (!next) continue;
353
+ if (!next) {
354
+ if (attempt % CATALOG_RECOVERY_LOG_EVERY === 0) {
355
+ log.warn("free-pi catalog is still unreachable; models stay unavailable", {
356
+ attempts: attempt,
357
+ });
358
+ }
359
+ continue;
360
+ }
349
361
  const parts = partitionModels(next);
350
362
  const accessNow = accountAccess(state.quotaCache?.me);
351
363
  const nextMain = filterAccessibleModels(parts.main, accessNow);
@@ -366,10 +378,6 @@ async function setup(ctx: Plugin.Context): Promise<() => Promise<void>> {
366
378
  );
367
379
  return;
368
380
  }
369
- log.warn(
370
- "free-pi catalog stayed unreachable; free-pi models remain unavailable",
371
- { attempts: CATALOG_RECOVERY_DELAYS_MS.length },
372
- );
373
381
  })();
374
382
  void catalogRecovery.catch(() => undefined);
375
383
 
@@ -390,6 +390,12 @@ async function applyGeneration(
390
390
  event.sessionID,
391
391
  Array.isArray(event.messages) ? event.messages.length : 0,
392
392
  );
393
+ // The compaction request and the next turn overlap: the runner starts the
394
+ // next step while the gateway still holds this wire session's request slot,
395
+ // which costs a `429 concurrent` and a full replay every time. Rotating the
396
+ // id for the next request avoids that round trip without changing what the
397
+ // model receives (the whole compacted history goes out every time).
398
+ markWireSessionDirty(deps, event.sessionID);
393
399
  } else if (kind === "primary") {
394
400
  // The free models tend to skip planning and claim work they did not do;
395
401
  // the CLI gets a much larger agent prompt. This is the compact equivalent.