openai/codex · error · anyhow::Error

duplicate code-mode request ID

Error message

duplicate code-mode request ID {request_id:?}

What it means

RequestRegistry duplicate-ID guard: start() was called with a request_id that is either currently active or in the recent-completion set, i.e. the client reused a request ID, which the protocol forbids.

Solutions

  1. Update the client to generate unique request IDs per request
  2. Report if IDs are correctly unique but still collide (registry bug)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/code-mode-host/src/lib.rs:704 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/21ce0c07691118d1. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/code-mode-host/src/lib.rs:704

    kind: RequestKind,
    cancellation: CancellationToken,
}

#[derive(Default)]
struct RequestRegistry {
    active: HashMap<RequestId, ActiveRequest>,
    recent: HashSet<RequestId>,
    recent_order: VecDeque<RequestId>,
}

impl RequestRegistry {
    fn start(
        &mut self,
        request_id: RequestId,
        kind: RequestKind,
    ) -> Result<CancellationToken, anyhow::Error> {
        if self.active.contains_key(&request_id) || self.recent.contains(&request_id) {
            anyhow::bail!("duplicate code-mode request ID {request_id:?}");
        }
        let cancellation = CancellationToken::new();
        self.active.insert(
            request_id,
            ActiveRequest {
                kind,
                cancellation: cancellation.clone(),
            },
        );
        Ok(cancellation)
    }

    fn cancel(&mut self, request_id: RequestId) {
        if let Some(request) = self.active.get(&request_id)
            && request.kind.is_cancellable()
        {
            request.cancellation.cancel();
        }

View on GitHub (pinned to 339751715c)