BigPizzaV3/CodexPlusPlus · error · RuntimeError
失败:
Error message
{method} 失败:{msg['error']} What it means
_request received an explicit JSON-RPC error response from the app-server (msg contains an 'error' object) and re-raises it wrapped with the method name. This is a server-side rejection of the call (e.g. invalid params, unsupported method, internal error), not a transport failure.
Solutions
- Read the embedded error object in the message for the server's code and message; fix the params passed to the method accordingly.
- Check codex app-server version compatibility if the error says the method is unknown.
- Surface the error to the caller (e.g. WeChat reply) instead of silently dropping the turn.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at tools/codex-wechat/codex_wechat.py:454 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/b9c6fa9d4d58ce1f.
Report an issue: GitHub.
Appendix: source
Thrown at tools/codex-wechat/codex_wechat.py:454
self.proc.stdin.write(json.dumps(message, ensure_ascii=False) + "\n")
self.proc.stdin.flush()
def _request(self, method: str, params: Any, timeout: int | None = None) -> dict[str, Any]:
req_id = self.next_id
self.next_id += 1
self._send({"id": req_id, "method": method, "params": params})
deadline = time.time() + (timeout or self.cfg.codex.timeout_seconds)
while time.time() < deadline:
try:
msg = self.messages.get(timeout=0.5)
except queue.Empty:
if self.proc and self.proc.poll() is not None:
raise RuntimeError(f"app-server 已退出,退出码 {self.proc.returncode}")
continue
if msg.get("id") == req_id:
if "error" in msg:
raise RuntimeError(f"{method} 失败:{msg['error']}")
return msg.get("result") or {}
# 其它通知留给当前请求外的事件循环自然丢弃。
raise TimeoutError(f"{method} 超时")
def _ensure_thread(self, user_id: str) -> str:
thread_id = self.threads.get(user_id)
if thread_id:
return thread_id
params: dict[str, Any] = {
"cwd": self.cfg.codex.workspace,
"approvalPolicy": self.cfg.codex.approval_policy,
"sandbox": self.cfg.codex.sandbox,
"ephemeral": True,
"baseInstructions": "你是运行在微信里的 Codex 助手。全程中文,只把最终答复发给微信用户。",
}
if self.cfg.codex.model:
params["model"] = self.cfg.codex.modelView on GitHub (pinned to b1ed92e5e4)