{"record":{"id":"3c1b8b120916eacd","repo":"can1357/oh-my-pi","slug":"async-error-history-limit-was-exceeded-while-waiti","errorCode":null,"errorMessage":"Async error history limit was exceeded while waiting for agent_end. Increase max_event_history if your host needs to retain more background failures.","messagePattern":"Async error history limit was exceeded while waiting for agent_end\\. Increase max_event_history if your host needs to retain more background failures\\.","errorType":"exception","errorClass":"RpcError","httpStatus":null,"severity":"error","filePath":"python/omp-rpc/src/omp_rpc/client.py","lineNumber":1345,"sourceCode":"        self,\n        start_index: int,\n        start_async_error_index: int,\n        timeout: float | None = None,\n    ) -> tuple[RpcAgentEvent, ...]:\n        deadline = time.monotonic() + (timeout if timeout is not None else 60.0)\n        with self._event_condition:\n            while True:\n                if self._closed_error is not None:\n                    raise RpcProcessExitError(str(self._closed_error))\n\n                if start_index < self._events.offset:\n                    raise RpcError(\n                        \"Event history limit was exceeded while waiting for agent_end. \"\n                        \"Increase max_event_history to retain more streamed events.\"\n                    )\n\n                if start_async_error_index < self._async_errors.offset:\n                    raise RpcError(\n                        \"Async error history limit was exceeded while waiting for agent_end. \"\n                        \"Increase max_event_history if your host needs to retain more background failures.\"\n                    )\n\n                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                    )","sourceCodeStart":1327,"sourceCodeEnd":1363,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/python/omp-rpc/src/omp_rpc/client.py#L1327-L1363","documentation":"Same eviction guard as the event-history error but for the background async-error ring buffer: while waiting for agent_end, the waiter's starting async-error index was already evicted (start_async_error_index < self._async_errors.offset), so earlier background failures can no longer be surfaced reliably.","triggerScenarios":"More than max_event_history worth of async errors accumulated between capturing the start index and the agent_end wait (default error history limit is 128); hosts that generate many background tool failures during long runs.","commonSituations":"Long-lived sessions where background tasks (extensions, host tools) repeatedly fail; reusing one client across many prompts without inspecting async errors; low error-history limits on busy hosts.","solutions":["Increase max_event_history so the async-error buffer grows accordingly","Drain/snapshot async errors between runs instead of letting them accumulate beyond the buffer","Fix or disable the repeatedly failing background tool/extension generating the error flood","Check async errors promptly via the client's async-error API rather than only at agent_end"],"exampleFix":"// before\nclient = make_client(max_event_history=128)  # error ring evicts on busy hosts\n// after\nclient = make_client(max_event_history=10_000)","handlingStrategy":"validation","validationCode":"if start_async_error_index < client.async_errors_offset():\n    raise RuntimeError(\"async error history evicted; raise max_event_history\")","typeGuard":null,"tryCatchPattern":"try:\n    client.wait_for_agent_end()\nexcept RpcError as exc:\n    if \"Async error history limit\" in str(exc):\n        log.warning(\"background failures lost; increase max_event_history\")\n    else:\n        raise","preventionTips":["Snapshot async errors between prompts instead of accumulating them","Fix noisy background tools/extensions that flood the error ring","Raise max_event_history on long-lived hosts"],"tags":["rpc","error-history","buffer-overflow","async"],"backgroundTag":"event-history-overflow","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}