Skip to content

First ACP call that touches an MCP tool fails after service restart with cancel-scope error #55

Description

@rkboyce

Summary

After restarting the ACP/MCP services, the first ACP flow call that references an MCP tool fails consistently with a cancel-scope error. Retrying the exact same user action immediately after that first failure succeeds, and the system is stable after that.

Observed error

MCP tool call failed: Attempted to exit a cancel scope that isn't the current tasks's current cancel scope

In one recent shell run, this surfaced from the ACP workflow dialogue flow as:

{
  "status": "error",
  "error": "workflow_context_dialogue_prompt_failed",
  "details": {
    "status": "error",
    "tool": "workflow_context_dialogue",
    "warnings": [
      "MCP tool call failed: Attempted to exit a cancel scope that isn't the current tasks's current cancel scope"
    ]
  }
}

Reproduction pattern

  1. Restart ACP and MCP services.
  2. Trigger any ACP flow that touches an MCP tool or prompt bundle.
  3. The first such call fails with the cancel-scope error above.
  4. Retry the same action immediately.
  5. The retry succeeds, and subsequent calls are stable.

Current impact

  • The failure is transient but user-visible.
  • It affects the first /ohdsi contextual guidance call after restart.
  • It also likely affects any other first ACP flow invocation that needs MCP-backed prompt/tool access.

Notes

  • This appears to be a service lifecycle / MCP client state issue rather than a workflow-specific prompt problem.
  • The repeated pattern strongly suggests a warm-up / first-call bug in ACP<->MCP interaction.
  • We are deferring this for now because the system is stable after the first retry, but it should be fixed because it degrades first-use reliability and complicates debugging.

Suggested investigation areas

  • MCP client initialization / reconnect logic after ACP startup
  • prompt bundle tool calls on the first request after service restart
  • cancel-scope management around MCP tool invocation and cleanup
  • whether a one-time warm-up call would mask or confirm the underlying issue

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions