t8y2/dbx · error

agent session already exists: {id}

Error message

agent session already exists: {id}

What it means

Bailed by the TDengine runtime open_session when a session with the requested agentSessionId already exists (after the empty-id check). Sessions are not silently replaced; opening the same id twice is a client-side protocol error, so the second open is refused.

Source

Thrown at agents/drivers/tdengine/src/runtime.rs:232

                    bail!("unknown method: {method}");
                }
                let id = session_id(&params).unwrap_or_else(|| LEGACY_SESSION_ID.to_string());
                let session = self.session(&id).await?;
                let mut driver = session.driver.lock().await;
                let (token, _operation) = session.begin_operation();
                dispatch_driver(&mut driver, method, &params, &token).await
            }
        }
    }

    async fn open_session(&self, id: &str, params: ConnectParams) -> Result<()> {
        if id.trim().is_empty() {
            bail!("agentSessionId is required");
        }
        {
            let sessions = self.sessions.read().await;
            if sessions.contains_key(id) {
                bail!("agent session already exists: {id}");
            }
        }
        let slot = self
            .session_slots
            .clone()
            .try_acquire_owned()
            .map_err(|_| anyhow!("agent session limit reached: {MAX_AGENT_SESSIONS}"))?;
        let mut driver = TdengineDriver::new();
        driver.connect(params).await?;
        let session = Arc::new(AgentSession {
            driver: Mutex::new(driver),
            active: StdMutex::new(None),
            next_operation_id: AtomicU64::new(1),
            _slot: slot,
        });
        let mut sessions = self.sessions.write().await;
        if sessions.contains_key(id) {
            bail!("agent session already exists: {id}");

View on GitHub (pinned to c0390bff16)

Solutions

  1. Use a fresh unique agentSessionId for each new session
  2. Close the existing session (close_session) before reopening with the same id
  3. Check the client for accidental duplicate open_session calls
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at agents/drivers/tdengine/src/runtime.rs:232 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/cead579e73019dae. Report an issue: GitHub.