{"record":{"id":"bc2f1d4182f6435f","repo":"BigPizzaV3/CodexPlusPlus","slug":"codex-turn-start-turn-id","errorCode":null,"errorMessage":"Codex turn/start 未返回 turn id","messagePattern":"Codex turn/start 未返回 turn id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/connect/app_server.rs","lineNumber":235,"sourceCode":"        let mut usage = TurnUsage::default();\n        let deadline = tokio::time::Instant::now() + TURN_TIMEOUT;\n        while !response_received || !turn_completed {\n            let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());\n            if remaining.is_zero() {\n                bail!(\"等待 Codex 回复超时\");\n            }\n            let message = self.read_message(remaining).await?;\n            if is_server_request(&message) {\n                self.reject_server_request(&message).await?;\n                continue;\n            }\n            if response_id(&message) == Some(id) {\n                if let Some(error) = rpc_error(&message) {\n                    bail!(\"Codex turn/start 失败：{error}\");\n                }\n                let result = message.get(\"result\").cloned().unwrap_or(Value::Null);\n                if extract_turn_id(&result).is_none() {\n                    bail!(\"Codex turn/start 未返回 turn id\");\n                }\n                if model.is_empty() {\n                    model = extract_model(&result).unwrap_or_default();\n                }\n                if let Some(reported_usage) = extract_turn_usage(&result) {\n                    usage = reported_usage;\n                }\n                response_received = true;\n                continue;\n            }\n\n            if model.is_empty() {\n                model = extract_model(&message).unwrap_or_default();\n            }\n            if let Some(reported_usage) = extract_turn_usage(&message) {\n                usage = reported_usage;\n            }\n","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/connect/app_server.rs#L217-L253","documentation":"After a successful turn/start RPC response (no rpc_error), run_turn verifies the result contains a turn id via extract_turn_id. If the result payload has no turn id, the library throws this error because it cannot correlate subsequent events with the turn. This indicates a protocol/shape mismatch with the installed Codex app-server.","triggerScenarios":"run_turn receives a well-formed, error-free turn/start response whose result lacks the turn-id field — typically from an older or newer Codex CLI whose app-server response schema changed.","commonSituations":"Codex CLI updated to a version that renamed/moved the turn id in the result, or downgraded CLI predating the turn-id field the library expects.","solutions":["Align versions: update (or downgrade) the Codex CLI to the version this library targets","Inspect the raw turn/start result payload to see where the turn id now lives","Pin a known-compatible CLI version while upgrading the library"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match server.run_turn(prompt).await {\n    Err(e) if e.to_string().contains(\"未返回 turn id\") => {\n        eprintln!(\"CLI/library protocol mismatch on turn id\");\n        // stop retrying; require a version pin fix\n    }\n    r => r,\n}","preventionTips":["Pin the Codex CLI version in CI/dev environments","Smoke-test a turn after every CLI upgrade","Log raw turn/start results to catch schema changes early"],"tags":["json-rpc","protocol","version-mismatch","ipc"],"backgroundTag":"unexpected-response-shape","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}