openai/codex · error · RuntimeError

the connected Codex runtime did not activate goal mode for…

Error message

the connected Codex runtime did not activate goal mode for this turn

What it means

The goal-mode watcher saw the turn complete without the runtime ever signaling that goal mode was activated for it (the activation flag stayed false through TurnCompletedNotification). This means the connected Codex runtime ignored or did not support the goal request, so the SDK cannot attribute the turn to the goal.

Solutions

  1. Start the goal through the SDK goal API against a runtime version that supports goal mode; ensure the turn was created as a goal turn.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at sdk/python/src/openai_codex/_goal.py:290 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/3f8e50107a6f6d40. Report an issue: GitHub.

Appendix: source

Thrown at sdk/python/src/openai_codex/_goal.py:290

        if isinstance(payload, TurnCompletedNotification):
            self.active = False
            self.last_completed = payload
            if payload.turn.status == TurnStatus.interrupted:
                return [
                    self._completion(
                        notification.method,
                        self.failed_completion or payload,
                    )
                ], True
            if payload.turn.status == TurnStatus.failed:
                self.failed_completion = payload
                if self.cleared or _terminal_goal_status(self.status):
                    self.state.finish()
                    return [self._completion(notification.method, payload)], True
                return [], False
            if self.status is None and not self.cleared:
                raise RuntimeError(
                    "the connected Codex runtime did not activate goal mode for this turn"
                )
            if self.cleared or _terminal_goal_status(self.status):
                self.state.finish()
                return [
                    self._completion(
                        notification.method,
                        self.failed_completion or payload,
                    )
                ], True
            return [], False

        events = [_logical_notification(notification, logical_turn_id)]
        if isinstance(payload, ThreadGoalUpdatedNotification):
            self.status = payload.goal.status
            if self.status == ThreadGoalStatus.active:
                self.cleared = False
            events = []

View on GitHub (pinned to 339751715c)