BigPizzaV3/CodexPlusPlus · error
Codex turn/start 未返回 turn id
Error message
Codex turn/start 未返回 turn id
What it means
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.
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
Defensive patterns
Strategy: try-catch
Try / catch
match server.run_turn(prompt).await {
Err(e) if e.to_string().contains("未返回 turn id") => {
eprintln!("CLI/library protocol mismatch on turn id");
// stop retrying; require a version pin fix
}
r => r,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/bc2f1d4182f6435f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/connect/app_server.rs:235
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();
}
if let Some(reported_usage) = extract_turn_usage(&message) {
usage = reported_usage;
}
View on GitHub (pinned to b1ed92e5e4)