Bug Report: Asynchronous Integration Initialization Race Condition on Cold-Start
Component: Agent Tool Execution & Runtime Orchestration / MCP Connector Manager
1. Title
[MCP] Race condition between initial user prompt evaluation and background integration tool-mounting causes premature tool availability refusal.
2. Description
When a user initiates a new conversation thread with a prompt that explicitly declares a dependency on a specialized external integration (e.g., Model Context Protocol connectors like @Strava), the runtime dispatcher evaluates the prompt's intent against the available tool inventory concurrently with the background initialization handshake.
If the background tool-mounting and registration process has not completed by the time the first-turn execution pipeline evaluates the prompt, the model treats the dependent tool as unavailable and returns a negative refusal ("I cannot directly access..."). Subsequent identical prompts succeed because the asynchronous background initialization has completed and the tool is now mounted in the runtime context.
3. Steps to Reproduce
- Start a completely new chat session (ensuring a cold-start state where runtime integrations are unmounted).
- Issue a prompt on the very first turn that requires a specific unregistered/initializing integration (e.g., "Using the Strava connector @Strava, count my runs to the marsh this year.").
- Observe Result (Actual): The system returns a refusal stating the integration/connector is inaccessible.
- Resubmit the exact same prompt immediately afterward in the next turn.
- Observe Result (Expected/Actual): The query executes successfully because the integration initialization completed in the background during/after the first turn.
4. Expected Behavior
Prompts that explicitly declare or trigger dependencies on external integrations or connectors should treat initialization as a blocking prerequisite. The orchestration layer should pause execution, await the background handshake and tool mount (with an appropriate timeout threshold), and then route the query to the successfully initialized tool rather than failing prematurely on a cold-start state.
5. Proposed Remediation
- Implement a synchronous gating or dependency-resolution check at the dispatcher level for declared tool namespaces.
- If a tool is in an initializing state (initializing: true), queue the incoming user prompt or hold evaluation until the mount event fires or a hard timeout (e.g., 3000ms) triggers a fallback error.
