xai-org/grok-build · critical

initialize through bridge

Error message

initialize through bridge

What it means

The ACP `initialize` request sent through the leader bridge resolved to an error (or the channel closed) and `.expect("initialize through bridge")` panicked. Initialize is the first ACP handshake message; failing here means the bridged agent did not return a valid InitializeResponse.

Source

Thrown at crates/codegen/xai-grok-pager/src/app/leader_cluster/mod.rs:476

                    )
                    .meta(
                        serde_json::json!({
                            "startupHints": {
                                "nonInteractive": true,
                                "skipGitStatus": true,
                                "skipProjectLayout": true
                            },
                            "clientType": "pager-cluster",
                            "clientVersion": "0.0.0-test",
                        })
                        .as_object()
                        .cloned(),
                    ),
                &tx,
            ),
        )
        .await
        .expect("initialize through bridge");
        if !self.authenticated {
            let _: acp::AuthenticateResponse = bounded(
                "authenticate",
                acp_send(
                    acp::AuthenticateRequest::new(acp::AuthMethodId::new("xai.api_key"))
                        .meta(serde_json::json!({ "headless": true }).as_object().cloned()),
                    &tx,
                ),
            )
            .await
            .expect("authenticate through bridge");
            self.authenticated = true;
        }

        let mut app = AppView::new(tx, ModelState::default(), Vec::new());
        app.leader_mode = true;
        app.auth_state = AuthState::Done;
        app.trust_state = TrustState::Done;

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Inspect the agent logs for a panic or error during initialize.
  2. Confirm both sides speak the same ACP protocol version (initialize params carry protocolVersion).
  3. Increase the bounded timeout if the agent is slow to start, or add readiness probing before initialize.
  4. Replace the expect with error propagation so leader connect can fall back to the embedded agent.

Example fix

// before
.expect("initialize through bridge");
// after
let init = bounded(...).await.map_err(|e| ClientError::InitializeFailed(e.to_string()))?;
Defensive patterns

Strategy: retry

Validate before calling

// verify channel liveness before sending initialize
if tx.is_closed() {
    return Err(ClientError::BridgeClosed("cannot initialize".into()));
}

Try / catch

match bounded("initialize", acp_send(init_req, &tx)).await {
    Ok(resp) => resp,
    Err(e) => return Err(ClientError::InitializeFailed(e.to_string())),
}

Prevention

When it happens

Trigger: Sending `acp::InitializeRequest` over the leader bridge and the agent replies with an ACP error, the bridge channel closes before the response, or the response times out at the bounded() wrapper.

Common situations: Agent-side crash during startup; version mismatch between pager and agent ACP protocol versions; authentication/transport misconfiguration so the agent rejects the session; slow agent startup exceeding the bounded timeout.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/5a765e5a91a5bf11. Report an issue: GitHub.