paperclipai/paperclip · warning

[opencode-local] Model availability probe could not run for

Error message

[opencode-local] Model availability probe could not run for "${model}" (${err instanceof Error ? err.message : String(err)}); proceeding with the configured model.

What it means

The local model-availability probe wraps `discoverOpenCodeModelsCached` (which spawns `opencode models`). If spawning throws — CLI missing, timeout, transient provider error — the adapter deliberately does NOT gate the run on the probe: it warns and returns a single-model fallback list so execution proceeds. Historically this threw and destroyed completed agent work mid-flight, so it is now strictly non-fatal.

Source

Thrown at packages/adapters/opencode-local/src/server/models.ts:235

  if (isTruthyEnvFlag(env.OPENCODE_ALLOW_ALL_MODELS ?? process.env.OPENCODE_ALLOW_ALL_MODELS)) {
    return [{ id: model, label: model }];
  }

  let models: AdapterModel[];
  try {
    models = await discoverOpenCodeModelsCached({
      command: input.command,
      cwd: input.cwd,
      env: input.env,
    });
  } catch (err) {
    // The availability probe is a best-effort pre-flight guard, not a gate. If
    // `opencode models` itself cannot run — a transient CLI error, a timeout, a
    // provider hiccup — do NOT abort the run. The real invocation is
    // authoritative, so a probe that can't execute must never be fatal.
    // (Previously this threw and crashed runs mid-flight, discarding the agent's
    // completed work and its terminal disposition, which then reopened the issue.)
    console.warn(
      `[opencode-local] Model availability probe could not run for "${model}" (${
        err instanceof Error ? err.message : String(err)
      }); proceeding with the configured model.`,
    );
    return [{ id: model, label: model }];
  }

  if (models.length === 0) {
    // The probe ran but returned nothing (e.g. a transient provider-auth blip).
    // Same reasoning as above: warn, don't block the run.
    console.warn(
      `[opencode-local] \`opencode models\` returned no models; proceeding with the configured model "${model}".`,
    );
    return [{ id: model, label: model }];
  }

  if (!models.some((entry) => entry.id === model)) {
    const sample = models.slice(0, 12).map((entry) => entry.id).join(", ");

View on GitHub (pinned to 120ae5428f)

Solutions

  1. Confirm `opencode` resolves for the server process: `which opencode` with the same env the adapter uses.
  2. Run `opencode models` locally with that env/cwd to reproduce the underlying error.
  3. Fix opencode installation/auth on that host; discovery is cached, so the next run re-probes.
  4. Treat a single occurrence as transient noise; only investigate if the warn repeats on every run.
Defensive patterns

Strategy: fallback

Validate before calling

// Before enabling the opencode-local adapter, verify the CLI is spawnable:
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const exec = promisify(execFile);

try {
  await exec('opencode', ['--version']);
} catch {
  throw new Error('opencode CLI not found on PATH for the server process');
}

Prevention

When it happens

Trigger: The `opencode` binary cannot be spawned in the adapter's cwd/env (not on PATH, ENOENT), the probe times out, or the provider listing call fails transiently — any exception from the cached discovery call lands in this branch.

Common situations: opencode CLI not installed on the machine/container running paperclip-server; PATH scrubbed for the agent process; slow provider causing a probe timeout; broken opencode auth/config on the host.

Related errors


AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18). Data as JSON: /api/errors/659c7f4b3e9f921f. Report an issue: GitHub.