openai/codex · error · anyhow::Error
either threadId or conversationId must be provided
Error message
either threadId or conversationId must be provided
What it means
CodexToolCallReplyParam::get_thread_id found neither thread_id nor the legacy conversation_id on the MCP tool call reply, so there is no conversation to continue. thread_id is the required modern field; conversation_id is tolerated only for backward compatibility.
Solutions
- Set threadId on the tool call reply to the id returned when the session was created
- Legacy clients should migrate from conversationId to threadId
- Validate outgoing replies before sending so missing ids fail fast client-side
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at codex-rs/mcp-server/src/codex_tool_config.rs:215 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/01dd89ffa0b0ad2c.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/mcp-server/src/codex_tool_config.rs:215
/// This field is required, but we keep it optional here for backward
/// compatibility for clients that still use conversationId.
#[serde(default, skip_serializing_if = "Option::is_none")]
thread_id: Option<String>,
/// The *next user prompt* to continue the Codex conversation.
pub prompt: String,
}
impl CodexToolCallReplyParam {
pub(crate) fn get_thread_id(&self) -> anyhow::Result<ThreadId> {
if let Some(thread_id) = &self.thread_id {
let thread_id = ThreadId::from_string(thread_id)?;
Ok(thread_id)
} else if let Some(conversation_id) = &self.conversation_id {
let thread_id = ThreadId::from_string(conversation_id)?;
Ok(thread_id)
} else {
Err(anyhow::anyhow!(
"either threadId or conversationId must be provided"
))
}
}
}
/// Builds a `Tool` definition for the `codex-reply` tool-call.
pub(crate) fn create_tool_for_codex_tool_call_reply_param() -> Tool {
let schema = SchemaSettings::draft2019_09()
.with(|s| {
s.inline_subschemas = true;
s.option_add_null_type = false;
})
.into_generator()
.into_root_schema_for::<CodexToolCallReplyParam>();
let input_schema = create_tool_input_schema(schema, "Codex reply tool schema should serialize");
View on GitHub (pinned to 339751715c)