Skip to content

Fix tool call stuck as running when moved out of active reasoning block#2360

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/fix-docker-agent-issue-2333-01589bab
Apr 10, 2026
Merged

Fix tool call stuck as running when moved out of active reasoning block#2360
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/fix-docker-agent-issue-2333-01589bab

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented Apr 9, 2026

Problem

When an MCP tool call (e.g. go_workspace from gopls) completed successfully, the TUI kept displaying it as running with an ever-increasing duration and the 60-second warning.

Root Cause

AddOrUpdateToolCall only checked the active (last) reasoning block when looking for an existing tool call to update. If the tool call was added to a reasoning block that later became inactive (because new messages were appended), the lookup missed it and created a duplicate standalone entry stuck at ToolStatusRunning forever.

Meanwhile, AddToolResult correctly scanned all reasoning blocks and updated the original entry — but the duplicate was never cleaned up.

Fix

Changed AddOrUpdateToolCall to scan all reasoning blocks for existing tool calls, matching the approach already used by AddToolResult.

Testing

Added TestAddOrUpdateToolCallFindsToolInNonActiveReasoningBlock which:

  • Creates a reasoning block with a pending tool call
  • Appends an assistant message so the reasoning block becomes inactive
  • Calls AddOrUpdateToolCall with Running status
  • Verifies no duplicate message is created and the tool count remains 1

The test fails on the old code (3 messages instead of 2) and passes with the fix.

Fixes #2333

AddOrUpdateToolCall only checked the active (last) reasoning block for
existing tool calls. If a tool call was added to a reasoning block that
later became inactive (due to new messages being appended), the lookup
missed it and created a duplicate entry. The duplicate stayed stuck at
ToolStatusRunning indefinitely while AddToolResult updated the original
in the old reasoning block.

Scan all reasoning blocks instead of only the active one, matching the
approach already used by AddToolResult.

Fixes docker#2333

Assisted-By: docker-agent
@dgageot dgageot requested a review from a team as a code owner April 9, 2026 14:00
@dgageot dgageot merged commit d7c623e into docker:main Apr 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Never ending gopls tool call

2 participants