openai/codex · error · InvalidRequestError

-32600

-32600

Error message

thread must be idle before starting a goal: {thread_id}

What it means

Error "thread must be idle before starting a goal: {thread_id}" thrown in openai/codex.

Source

Thrown at sdk/python/src/openai_codex/client.py:567

            pass

    def start_goal_operation(
        self,
        thread_id: str,
        objective: str,
    ) -> tuple[_GoalOperationState, str]:
        """Start a logical goal and wait for its runtime-generated first turn."""
        with self._thread_start_lock(thread_id):
            return self._start_goal_operation(thread_id, objective)

    def _start_goal_operation(
        self,
        thread_id: str,
        objective: str,
    ) -> tuple[_GoalOperationState, str]:
        thread = self.thread_read(thread_id).thread
        if not isinstance(thread.status.root, IdleThreadStatus):
            raise InvalidRequestError(
                -32600,
                f"thread must be idle before starting a goal: {thread_id}",
            )
        if thread.ephemeral or thread.path is None:
            raise InvalidRequestError(
                -32600,
                f"thread must be persisted before starting a goal: {thread_id}",
            )

        state = self.reserve_goal_operation(thread_id)
        activated = False
        try:
            self.thread_goal_clear(thread_id)
            state.activate_turn_routing()
            self.thread_goal_set(
                thread_id,
                objective=objective,
                status=ThreadGoalStatus.active,

View on GitHub (pinned to 339751715c)

Solutions

  1. Wait for the thread current turn to complete before starting a goal on it.

When it happens

Trigger: Thrown at sdk/python/src/openai_codex/client.py:567 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/3cea234908129c6c. Report an issue: GitHub.