{"record":{"id":"8bc0d390c5b7cfbf","repo":"paperclipai/paperclip","slug":"opencode-models-failed-on-the-remote-execution-t","errorCode":null,"errorMessage":"`opencode models` failed on the remote execution target: ${detail}","messagePattern":"`opencode models` failed on the remote execution target: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapters/opencode-local/src/server/execute.ts","lineNumber":133,"sourceCode":"    input.executionTarget,\n    input.command,\n    [\"models\"],\n    {\n      cwd: input.cwd,\n      env: input.env,\n      timeoutSec: probeTimeoutSec,\n      graceSec: input.graceSec,\n      onLog: async () => {},\n    },\n  );\n\n  if (probe.timedOut) {\n    throw new Error(`\\`opencode models\\` timed out on the remote execution target after ${probeTimeoutSec}s.`);\n  }\n\n  if ((probe.exitCode ?? 1) !== 0) {\n    const detail = firstNonEmptyLine(probe.stderr) || firstNonEmptyLine(probe.stdout);\n    throw new Error(\n      detail\n        ? `\\`opencode models\\` failed on the remote execution target: ${detail}`\n        : \"`opencode models` failed on the remote execution target.\",\n    );\n  }\n\n  const models = parseOpenCodeModelsOutput(probe.stdout);\n  if (models.length === 0) {\n    throw new Error(\n      \"OpenCode returned no models on the remote execution target. Run `opencode models` there and verify provider auth.\",\n    );\n  }\n\n  if (!models.some((entry) => entry.id === model)) {\n    const sample = models.slice(0, 12).map((entry) => entry.id).join(\", \");\n    throw new Error(\n      `Configured OpenCode model is unavailable on the remote execution target: ${model}. Available models: ${sample}${models.length > 12 ? \", ...\" : \"\"}`,\n    );","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/adapters/opencode-local/src/server/execute.ts#L115-L151","documentation":"Thrown by the REMOTE OpenCode model probe when `opencode models` exits with a non-zero code on the remote/sandbox target. The detail is the first non-empty line of stderr, falling back to stdout, so the operator sees opencode's own error. This is a target-side failure, not a Paperclip adapter bug.","triggerScenarios":"runAdapterExecutionTargetProcess returns exitCode != 0 (and not timedOut) for `opencode models` on a remote target; detail = firstNonEmptyLine(stderr) || firstNonEmptyLine(stdout).","commonSituations":"opencode binary not installed or not on PATH in the sandbox image; provider auth missing/expired inside the target; opencode version mismatch producing a fatal startup error; shared-library/permission error launching the binary.","solutions":["Read the detail line — it is opencode's own error message and usually names the cause (auth, missing binary, config).","Ensure opencode is installed and on PATH in the remote/sandbox image; run `opencode models` there manually to reproduce.","Configure provider auth inside the target (API key env or opencode login) so the binary can enumerate models.","If auth is correct but the version is old, upgrade opencode in the image."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check the target has opencode and auth before the run.\nasync function remoteHasOpenCode(target: ExecutionTarget, cwd: string, env: NodeJS.ProcessEnv): Promise<boolean> {\n  const r = await runAdapterExecutionTargetProcess(runId, target, \"opencode\", [\"--version\"], { cwd, env, timeoutSec: 10, graceSec: 2, onLog: async () => {} });\n  return (r.exitCode ?? 1) === 0;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ensureOpenCodeModelAvailableOnTarget(input);\n} catch (e) {\n  if (e instanceof Error && /`opencode models` failed on the remote execution target/.test(e.message)) {\n    // parse the detail line; guide the operator to install opencode or auth the provider; non-retryable until fixed\n  }\n  throw e;\n}","preventionTips":["Bake opencode and provider auth into the sandbox image.","Verify PATH in the target includes the opencode binary.","Run `opencode models` in CI against the image to catch regressions."],"tags":["opencode","models","remote","sandbox","process-error"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}