opencode-immune 1.0.41 → 1.0.42

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 (2) hide show
  1. package/dist/plugin.js +11 -14
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -11,7 +11,7 @@ const child_process_1 = require("child_process");
11
11
  // ═══════════════════════════════════════════════════════════════════════════════
12
12
  // PLUGIN VERSION CHECK
13
13
  // ═══════════════════════════════════════════════════════════════════════════════
14
- const PLUGIN_VERSION = "1.0.41";
14
+ const PLUGIN_VERSION = "1.0.42";
15
15
  const PLUGIN_PACKAGE_NAME = "opencode-immune";
16
16
  /**
17
17
  * Read plugin version from package.json at runtime.
@@ -365,13 +365,13 @@ function isProviderRetryBanner(text) {
365
365
  return /(?:<none>\s*)?retrying in \d+s\s*-\s*attempt #\d+/i.test(text);
366
366
  }
367
367
  function scheduleProviderRetryWatchdog(state, sessionID, model) {
368
- if (!isManagedUltraworkSession(state, sessionID))
368
+ if (!isManagedRootUltraworkSession(state, sessionID))
369
369
  return;
370
370
  if (state.providerRetryWatchdogs.has(sessionID))
371
371
  return;
372
372
  const timer = setTimeout(async () => {
373
373
  state.providerRetryWatchdogs.delete(sessionID);
374
- if (!isManagedUltraworkSession(state, sessionID))
374
+ if (!isManagedRootUltraworkSession(state, sessionID))
375
375
  return;
376
376
  if (state.sessionRetryTimers.has(sessionID))
377
377
  return;
@@ -1251,7 +1251,6 @@ function createFallbackModels(state) {
1251
1251
  }
1252
1252
  else if (getManagedSession(state, input.sessionID)?.kind === "child") {
1253
1253
  await updateManagedSessionAgent(state, input.sessionID, input.agent);
1254
- scheduleProviderRetryWatchdog(state, input.sessionID, CHILD_SESSION_FALLBACK_MODEL);
1255
1254
  }
1256
1255
  // NOTE: Do NOT remove managed root sessions when agent changes in chat.params.
1257
1256
  // Subagent calls from 0-ultrawork (1-van, 7-backlog, etc.) use the same session.
@@ -1332,12 +1331,13 @@ function createEventHandler(state) {
1332
1331
  if (count < MAX_RETRIES) {
1333
1332
  const delay = Math.min(BASE_DELAY_MS * Math.pow(2, count), MAX_DELAY_MS);
1334
1333
  state.sessionErrorRetryCount.set(sessionID, count + 1);
1335
- // Pin fallback model: for child sessions always, for root provider-level failures.
1334
+ // Child/subagent failures are owned by the router. Auto-resuming a failed
1335
+ // child after the router advances can create two writers in one pipeline.
1336
1336
  if (isChild) {
1337
- await setSessionFallbackModel(state, sessionID, CHILD_SESSION_FALLBACK_MODEL);
1338
- const errorType = isModelAccessError(error) ? "model access error" : isRateLimitApiError(error) ? "rate limit" : isCertificateApiError(error) ? "certificate error" : "retryable error";
1339
- console.log(`[opencode-immune] Child session ${sessionID}: ${errorType} detected. ` +
1340
- `Retry will use fallback model ${CHILD_SESSION_FALLBACK_MODEL.providerID}/${CHILD_SESSION_FALLBACK_MODEL.modelID}.`);
1337
+ console.log(`[opencode-immune] Child session ${sessionID}: retryable error detected. ` +
1338
+ `Skipping plugin auto-retry; router owns sequential fallback decisions.`);
1339
+ state.sessionErrorRetryCount.set(sessionID, count);
1340
+ return;
1341
1341
  }
1342
1342
  else if (isRoot && (isRateLimitApiError(error) || isCertificateApiError(error))) {
1343
1343
  await setSessionFallbackModel(state, sessionID, RATE_LIMIT_FALLBACK_MODEL);
@@ -1515,11 +1515,8 @@ function createTextCompleteHandler(state) {
1515
1515
  cancelProviderRetryWatchdog(state, sessionID, "assistant text completed");
1516
1516
  // Some provider/SDK failures render as a retry banner instead of a
1517
1517
  // session.error event, leaving the UI waiting for long internal backoff.
1518
- if (isProviderRetryBanner(text) && isManagedUltraworkSession(state, sessionID)) {
1519
- const managedSession = getManagedSession(state, sessionID);
1520
- const fallbackModel = managedSession?.kind === "child"
1521
- ? CHILD_SESSION_FALLBACK_MODEL
1522
- : RATE_LIMIT_FALLBACK_MODEL;
1518
+ if (isProviderRetryBanner(text) && isManagedRootUltraworkSession(state, sessionID)) {
1519
+ const fallbackModel = RATE_LIMIT_FALLBACK_MODEL;
1523
1520
  await setSessionFallbackModel(state, sessionID, fallbackModel);
1524
1521
  scheduleManagedSessionRetry(state, sessionID, {
1525
1522
  delayMs: 1_000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
5
5
  "exports": {
6
6
  "./server": "./dist/plugin.js"