{"record":{"id":"87689bb91360f846","repo":"Hmbown/CodeWhale","slug":"remote-error","errorCode":"remote_error","errorMessage":"${r.error?.message ?? \"remote agent failed\"}","messagePattern":"\\$\\{r\\.error\\?\\.message \\?\\? \"remote agent failed\"\\}","errorType":"error_code","errorClass":"ServerError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/mcp/server.mjs","lineNumber":964,"sourceCode":"      };\n      const resolve = async (req) => {\n        const rep = await remoteCall({ tool: \"resolve_element\", args: req }, { timeoutMs: 30_000 });\n        if (!rep?.ok) return { found: false, element: null, reason: rep?.error?.code ?? \"remote_error\" };\n        return rep.data;\n      };\n      const wireArgs = await prepareArgs(computer, name, args, resolve, sink);\n      throwIfAborted();\n      await assertCurrentRoute(computer, binding);\n      // Re-check the kill switch: a stop that arrived while the executor was\n      // being resolved still blocks this dispatch.\n      if (controlStopped && !READ_ONLY_TOOLS.has(name)) throw new ServerError(\"control_stopped\", \"stop_computer_control is active; no further actions are permitted this session\");\n      inFlight++;\n      try {\n        dispatched = true;\n        const timeoutMs = backendMethod.startsWith(\"recording\") || backendMethod === \"get_app_state\" ? 60_000 : 30_000;\n        const invoke = async (tool, a) => {\n          const r = await remoteCall({ tool, args: a }, { timeoutMs });\n          if (!r.ok) throw new ServerError(r.error?.code ?? \"remote_error\", r.error?.message ?? \"remote agent failed\");\n          return r.data;\n        };\n        data = name === \"type\" ? await invokeType(invoke, wireArgs) : await invoke(backendMethod, wireArgs);\n      } finally {\n        inFlight--;\n      }\n      await assertCurrentRoute(computer, binding, true);\n      if (Array.isArray(data)) data = { items: data };\n      if ((backendMethod === \"screenshot\" || backendMethod === \"zoom\") && data?.file) {\n        if (ex.filesLocal) bindRaster(computer, data);\n        else {\n          // Raster lives on the remote machine; bind geometry for coordinate mapping.\n          bindRaster(computer, { ...data, file: null });\n          data.note = \"file lives on the remote computer; pull it with scp if you need the bytes locally\";\n        }\n      }\n      if (backendMethod === \"zoom\") bindZoomRaster(computer, zoomParent, args.region, ex.filesLocal ? data?.file ?? data?.path : null);\n      if (name === \"get_app_state\") {","sourceCodeStart":946,"sourceCodeEnd":982,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/mcp/server.mjs#L946-L982","documentation":"When a tool is dispatched to a remote agent over the persistent channel (ssh --serve etc.), a reply with ok:false is converted into a ServerError. The code defaults to remote_error but the agent's own error code and message are forwarded verbatim, so this error is a passthrough of a failure that happened on the remote side.","triggerScenarios":"Any remote tool call where the remote agent returns { ok: false } — remote-side precondition failures, unknown tools on the agent, backend errors, or timeouts surfaced by the agent as a structured error reply.","commonSituations":"Old agent versions not supporting a requested tool; remote machine state changed (window closed, app quit); remote backend permission or environment problems; network-induced agent failures reported as structured errors.","solutions":["Read the forwarded r.error.message in the thrown error — it names the actual remote failure","Upgrade the remote agent if the tool/code is unsupported (old agent without --serve features)","Re-establish the remote session/channel and retry if the agent reported a transient failure","Reproduce the failing precondition locally to confirm the remote environment state"],"exampleFix":"// before\nconst r = await remoteCall(...); // returns { ok: false, error: { message: \"no window\" } }\n// after — ensure the target window/app exists remotely, then retry\nawait getAppState({}); // verify remote state before re-issuing the action","handlingStrategy":"try-catch","validationCode":"// no local check can predict remote failures; verify remote state before acting:\nconst st = await getAppState({ computer }); // confirm the target exists remotely first","typeGuard":"const isStructuredError = (r) => r && r.ok === false && typeof r.error?.message === \"string\";","tryCatchPattern":"try { await remoteAction(...) } catch (e) { if (e.code === \"remote_error\") { log(e.message); if (isTransient(e.message)) await reconnectAndRetry(); } else throw e; }","preventionTips":["Log the forwarded remote message verbatim for diagnosis","Keep the remote agent version compatible with the server's tool set","Check remote app/window state before dispatching actions","Treat remote errors as environment problems, not client bugs"],"tags":["mcp","computer-use","remote","passthrough"],"backgroundTag":"upstream-api-error","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T21:17:16.096Z"}