[PR #11418] fix(opencode): keep session loop running after tool parts #13781

Closed
opened 2026-02-16 18:18:36 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11418

State: closed
Merged: No


What does this PR do?

When using the Anthropic provider behind an Anthropic-compatible gateway/proxy, the model may return finish_reason=stop while the assistant message still contains tool parts. In that case OpenCode could exit the session loop right after tool execution, so the model never gets a follow-up turn to consume tool results and produce the final text reply.

This change keeps the session loop running whenever the latest assistant message contains tool parts, allowing the model to produce the final response.

Fixes #11417

How did you verify your code works?

  • bun test test/session/prompt-loop.test.ts
  • Manually reproduced with prompts that trigger multiple MCP tool calls (serial and parallel) and verified a final one-line response is produced after tools complete.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11418 **State:** closed **Merged:** No --- ### What does this PR do? When using the Anthropic provider behind an Anthropic-compatible gateway/proxy, the model may return `finish_reason=stop` while the assistant message still contains tool parts. In that case OpenCode could exit the session loop right after tool execution, so the model never gets a follow-up turn to consume tool results and produce the final text reply. This change keeps the session loop running whenever the latest assistant message contains tool parts, allowing the model to produce the final response. Fixes #11417 ### How did you verify your code works? - `bun test test/session/prompt-loop.test.ts` - Manually reproduced with prompts that trigger multiple MCP tool calls (serial and parallel) and verified a final one-line response is produced after tools complete.
yindo added the pull-request label 2026-02-16 18:18:36 -05:00
yindo closed this issue 2026-02-16 18:18:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13781