Skip to content

Bug: session ends after MCP tool calls when using Anthropic-compatible gateways #11417

Closed

Description

@wang0898

Description

When using the Anthropic provider behind an Anthropic-compatible gateway/proxy, MCP tools can run successfully but the chat stops without producing the final assistant reply.

What happens

  • The model triggers one or more MCP tools
  • The tools complete successfully
  • The session loop exits right after the tool parts, so the model never gets a follow-up turn to read tool results and produce the final text response

What I expected

  • If the latest assistant message contains tool parts, the session should continue until the model outputs a final text reply.

Why this seems to happen
Some gateways/proxies may return finish_reason=stop even though the assistant message still contains tool parts (sometimes even text + tool in the same message). OpenCode treats this as “done” and exits early.

How to reproduce (high level)

  • Configure Anthropic provider via an Anthropic-compatible gateway/proxy
  • Enable any MCP server(s)
  • Ask the model to call two MCP tools (serial or parallel) and then output a single final line (e.g. “DONE”)
  • Observe: tools run, but the final line is never produced

Notes

  • OpenAI provider does not show this behavior in the same setup.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Jan 31, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. github-actions commented on Apr 2, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions