BigPizzaV3/CodexPlusPlus · error

Codex turn/start 失败:

Error message

Codex turn/start 失败:{error}

What it means

When the JSON-RPC response to the turn/start request carries an error payload, run_turn surfaces it with this message, embedding the server-provided error text. It means Codex explicitly rejected the turn/start RPC rather than timing out or crashing silently.

Solutions

  1. Read the embedded {error} text — it comes from Codex itself and usually names the cause
  2. Verify the model name in config matches a model the installed CLI supports (`codex` / app-server model list)
  3. Re-authenticate with Codex (check auth status) and confirm work_dir/sandbox settings are valid
  4. Update the Codex CLI and the library so protocol expectations match

Example fix

// before
AppServerConfig { model: "gpt-5-turbo-preview".into(), .. } // removed model
// after
AppServerConfig { model: "gpt-5".into(), .. } // model supported by installed CLI
Defensive patterns

Strategy: validation

Validate before calling

// before start: confirm the model is one the CLI accepts
if !supported_models().contains(&config.model) {
    eprintln!("model {} not supported by installed CLI", config.model);
}

Try / catch

match server.run_turn(prompt).await {
    Err(e) if e.to_string().contains("turn/start 失败") => {
        eprintln!("server rejected turn: {e}");
        // switch model / re-auth / adjust sandbox based on embedded cause
    }
    r => r,
}

Prevention

When it happens

Trigger: run_turn sends turn/start; the matching response (by id) contains rpc_error — e.g. invalid model name, rejected session/thread, sandbox or work_dir problems, Codex-side auth failure, malformed turn parameters.

Common situations: Configured model string no longer exists after a CLI update, expired ChatGPT/Codex authentication, work_dir deleted or inaccessible, sandbox mode value not accepted by the installed CLI version.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/809d0a561d7f6c7c. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/connect/app_server.rs:231

        let mut response_received = false;
        let mut turn_completed = false;
        let mut reply_parts = Vec::new();
        let mut model = self.config.model.trim().to_string();
        let mut usage = TurnUsage::default();
        let deadline = tokio::time::Instant::now() + TURN_TIMEOUT;
        while !response_received || !turn_completed {
            let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());
            if remaining.is_zero() {
                bail!("等待 Codex 回复超时");
            }
            let message = self.read_message(remaining).await?;
            if is_server_request(&message) {
                self.reject_server_request(&message).await?;
                continue;
            }
            if response_id(&message) == Some(id) {
                if let Some(error) = rpc_error(&message) {
                    bail!("Codex turn/start 失败:{error}");
                }
                let result = message.get("result").cloned().unwrap_or(Value::Null);
                if extract_turn_id(&result).is_none() {
                    bail!("Codex turn/start 未返回 turn id");
                }
                if model.is_empty() {
                    model = extract_model(&result).unwrap_or_default();
                }
                if let Some(reported_usage) = extract_turn_usage(&result) {
                    usage = reported_usage;
                }
                response_received = true;
                continue;
            }

            if model.is_empty() {
                model = extract_model(&message).unwrap_or_default();
            }

View on GitHub (pinned to b1ed92e5e4)