can1357/oh-my-pi · error · RpcCommandError

{response.get("code") if str else null}

{response.get("code") if str else null}

Error message

{response.get("error", "")}

What it means

RpcCommandError raised when the server responded success=false for a command. It carries the failing command name, the server-provided error string (response['error'], empty string if absent), and an optional string code from response['code'] (None if the code isn't a string).

Source

Thrown at python/omp-rpc/src/omp_rpc/client.py:1408

            with self._state_lock:
                self._pending.pop(request_id, None)
            raise

        try:
            response = response_queue.get(timeout=self._request_timeout)
        except queue.Empty as exc:
            with self._state_lock:
                self._pending.pop(request_id, None)
            raise RpcTimeoutError(
                f"Timed out waiting for response to {command_type}. Stderr: {self.stderr}"
            ) from exc

        if isinstance(response, BaseException):
            raise response

        if not bool(response.get("success", False)):
            raw_code = response.get("code")
            raise RpcCommandError(
                command=str(response.get("command", command_type)),
                error=str(response.get("error", "")),
                code=raw_code if isinstance(raw_code, str) else None,
            )

        data = response.get("data")
        if data is None:
            return {}
        return _clone_json_object(data)

    def _send_notification(self, payload: JsonObject) -> None:
        process = self._require_process()
        self._write_json(process, payload)

    def _normalize_host_tool_result(self, result: object) -> JsonObject:
        if isinstance(result, str):
            return {"content": [{"type": "text", "text": result}]}
        if isinstance(result, Mapping):

View on GitHub (pinned to 9690622007)

Solutions

  1. Read exc.error (and exc.code) for the server's specific reason and fix the request payload accordingly
  2. Verify the command name and arguments against the server's protocol version
  3. Catch RpcCommandError around _request-style calls and branch on code where the server defines codes
  4. Update client and server packages together if a protocol mismatch causes systematic rejections

Example fix

try:
    client.set_model("gpt-5")
except RpcCommandError as exc:
    if exc.code == "model-not-found":
        client.set_model("gpt-5-mini")
    else:
        raise
Defensive patterns

Strategy: try-catch

Validate before calling

# validate payload keys/types against the protocol before sending
def validate_command(name: str, payload: dict) -> None:
    required = COMMAND_SCHEMAS[name]
    missing = required.keys() - payload.keys()
    if missing:
        raise ValueError(f"missing args: {missing}")

Try / catch

try:
    client.run_command("set_model", model=model_id)
except RpcCommandError as exc:
    match exc.code:
        case "model-not-found": pick_fallback_model()
        case _: raise

Prevention

When it happens

Trigger: Any _request command the server rejects: invalid arguments, unknown command, session errors, server-side validation failures. The error text comes verbatim from the server payload.

Common situations: Calling commands with wrong payload shapes after a protocol version change; referencing a missing session/model; server-side tool or permission denials.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/d2c01e35b699f39b. Report an issue: GitHub.