{"record":{"id":"9413dbef1080e2de","repo":"openai/codex","slug":"thread-state-thread-id-r-already-has-an-active-g","errorCode":null,"errorMessage":"thread {state.thread_id!r} already has an active goal operation","messagePattern":"thread (.+?) already has an active goal operation","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdk/python/src/openai_codex/_message_router.py","lineNumber":134,"sourceCode":"        item = turn_queue.get()\n        if isinstance(item, BaseException):\n            raise item\n        return item\n\n    def register_goal(self, thread_id: str) -> _GoalOperationState:\n        \"\"\"Register one thread-scoped logical goal operation before it starts.\"\"\"\n        state = _GoalOperationState(thread_id=thread_id)\n        state.activate_turn_routing()\n        return self._register_goal(state)\n\n    def reserve_goal(self, thread_id: str) -> _GoalOperationState:\n        \"\"\"Reserve a thread route without accepting physical turns yet.\"\"\"\n        return self._register_goal(_GoalOperationState(thread_id=thread_id))\n\n    def _register_goal(self, state: _GoalOperationState) -> _GoalOperationState:\n        with self._lock:\n            if state.thread_id in self._goal_operations:\n                raise RuntimeError(\n                    f\"thread {state.thread_id!r} already has an active goal operation\"\n                )\n            self._goal_operations[state.thread_id] = state\n        return state\n\n    def unregister_goal(self, state: _GoalOperationState) -> None:\n        \"\"\"Stop routing notifications to a completed logical goal operation.\"\"\"\n        with self._lock:\n            if self._goal_operations.get(state.thread_id) is state:\n                self._goal_operations.pop(state.thread_id)\n\n    def has_goal(self, thread_id: str) -> bool:\n        \"\"\"Return whether a logical goal operation owns this thread route.\"\"\"\n        with self._lock:\n            return thread_id in self._goal_operations\n\n    def route_response(self, msg: dict[str, JsonValue]) -> None:\n        \"\"\"Deliver a JSON-RPC response or error to its request waiter.\"\"\"","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/sdk/python/src/openai_codex/_message_router.py#L116-L152","documentation":"Error \"thread {state.thread_id!r} already has an active goal operation\" thrown in openai/codex.","triggerScenarios":"Thrown at sdk/python/src/openai_codex/_message_router.py:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the active goal operation on the thread to finish before starting another goal."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}