{"record":{"id":"01d5d74c790123dc","repo":"can1357/oh-my-pi","slug":"timed-out-waiting-for-agent-end-stderr-self-std","errorCode":null,"errorMessage":"Timed out waiting for agent_end. Stderr: {self.stderr}","messagePattern":"Timed out waiting for agent_end\\. Stderr: (.+?)","errorType":"exception","errorClass":"RpcTimeoutError","httpStatus":null,"severity":"error","filePath":"python/omp-rpc/src/omp_rpc/client.py","lineNumber":1368,"sourceCode":"                async_errors = self._async_errors.snapshot_from(start_async_error_index)\n                if len(async_errors) > 0:\n                    raise async_errors[0]\n\n                event_payloads = self._events.snapshot_from(start_index)\n                if any(\n                    payload.get(\"type\") == \"agent_end\"\n                    and payload.get(\"isTerminal\") is not False\n                    for payload in event_payloads\n                ):\n                    events = tuple(\n                        cast(RpcAgentEvent, parse_notification(payload))\n                        for payload in event_payloads\n                    )\n                    return events\n\n                remaining = deadline - time.monotonic()\n                if remaining <= 0:\n                    raise RpcTimeoutError(\n                        f\"Timed out waiting for agent_end. Stderr: {self.stderr}\"\n                    )\n                self._event_condition.wait(remaining)\n\n    def _request(self, command_type: str, **payload: JsonValue) -> JsonObject:\n        process = self._require_process()\n        request_id = self._next_request_id()\n        envelope: JsonObject = {\"id\": request_id, \"type\": command_type}\n        for key, value in payload.items():\n            if value is not None:\n                envelope[key] = value\n\n        response_queue: queue.Queue[JsonObject | BaseException] = queue.Queue(maxsize=1)\n        with self._state_lock:\n            self._pending[request_id] = _PendingRequest(\n                command=command_type, response_queue=response_queue\n            )\n","sourceCodeStart":1350,"sourceCodeEnd":1386,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/python/omp-rpc/src/omp_rpc/client.py#L1350-L1386","documentation":"RpcTimeoutError raised when no agent_end event arrives within the requested (or default 60s) timeout while the process is still alive. Stderr is included to help diagnose a hung server.","triggerScenarios":"Calling wait_for_agent_end(timeout=T) where the agent run legitimately takes longer than T, or the server is stuck (LLM call hanging, tool awaiting input, deadlock in host-tool dispatch).","commonSituations":"Slow model responses or long tool executions exceeding the default 60s; passing timeout=None-intent but getting default; server hung on a host-tool that never responds.","solutions":["Pass a larger timeout to wait_for_agent_end for long-running prompts","Check client.stderr for signs the server is stuck (pending tool calls, retries)","Poll asynchronously instead of blocking: use event listeners and a longer supervising deadline","If the server is genuinely hung, abort/stop the prompt and restart the client"],"exampleFix":"// before\nevents = client.wait_for_agent_end()  # default 60s\n// after\nevents = client.wait_for_agent_end(timeout=600)  # long agent runs","handlingStrategy":"try-catch","validationCode":"timeout = max(600, expected_run_seconds * 2)  # size timeout to workload","typeGuard":null,"tryCatchPattern":"try:\n    events = client.wait_for_agent_end(timeout=600)\nexcept RpcTimeoutError as exc:\n    log.error(\"agent run exceeded deadline; stderr=%s\", client.stderr)\n    client.abort()  # stop the hung run before retrying","preventionTips":["Always pass an explicit timeout sized to your longest expected run","Monitor client.stderr for hangs (pending tools, retry loops)","Abort and restart the client when a timeout fires rather than blind-retrying"],"tags":["rpc","timeout","streaming","ipc"],"backgroundTag":"rpc-timeout","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}