Skip to content

[Bug] strands-agents: a failed MCP call closes the shared connection under in-flight calls #100

Closed

Description

@wankhede04

What are you really trying to do?

Run several MCP tool calls concurrently through the Strands integration against one MCP server, without one
failing call breaking the others.

Describe the bug

When a listTools or callTool Activity fails, its catch block runs await _evictConnection(server) right away
(typescript/strands-agents/src/temporal-mcp-client.ts). Any other call using the same pooled connection then
fails with "Connection closed" and is retried, which can repeat side effects of non-idempotent tools.

Failures that trigger it include client-side ones over a healthy connection, such as non-object tool arguments or
a result that fails the tool's output schema.

This package was imported from sdk-typescript, where #2259 stopped the idle timer from closing a connection that
has a call in flight. This is the failure path, which that change did not cover.

Minimal Reproduction

One server, two concurrent calls through buildCallToolActivity: a slow call, and a call whose result fails the
tool's output schema. The test uses a fake MCP client that rejects in-flight requests when disconnect() is
called, as the real MCP transport does.

slow call: FAILED (Connection closed)
disconnect client-1
fail call rejected: tool output did not match schema

Expected: the slow call returns its result, and the connection is closed only after it finishes.

Environment/Versions

  • OS and processor: macOS, Apple Silicon (not OS-specific)
  • Temporal Version: typescript/strands-agents at ai-integrations main (5e4312c), Node 22.22.2, pnpm 10.27.0
  • Are you using Docker or Kubernetes or building Temporal from source? Unit-test level (make test), no cluster

Additional context

typescript/vercel-ai-sdk already avoids this: it marks a failed pooled connection broken and closes it once its
refCount reaches 0 (typescript/vercel-ai-sdk/src/activities.ts). I propose the same here: mark the record
broken, stop handing it out so later calls open a fresh connection, and disconnect it when the last in-flight
call releases it. I have a small patch and tests ready and will open a PR if this looks right. The Python Strands
integration has the same pattern and should get the same treatment separately.

Activity

  1. added
    bug
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions