[GH-ISSUE #754] Anthropic API: tool calls intermittently emitted inside thinking and returned as end_turn #341

Closed
opened 2026-11-04 01:42:08 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @JakeCow on GitHub (Oct 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/754

AI disclosure: This issue was created with the assistance of AI based on captured Pi session logs and raw SSE traffic. Im not a dev :)

strata-failing-sse.txt

System

  • OS: Ubuntu 26.04.1 LTS
  • Kernel: 7.0.0-34-generic
  • CPU: AMD Ryzen 7 9800X3D
  • RAM: 32 GB DDR5-6000
  • GPU: NVIDIA GeForce RTX 3090 24 GB
  • NVIDIA driver: 595.91.07
  • CUDA: 13.2
  • Strata: Docker, v0.1.38
  • Model: qwen3.8-flash-next-coder-iq1_m
  • Context: 262144
  • API: Anthropic-compatible /v1/messages
  • Client: Pi 1.0.2
  • Pi thinking mode: low (budget_tokens: 2048)

Setup

  • Strata: current Docker build / v0.1.38-era code
  • Model: qwen3.8-flash-next-coder-iq1_m
  • API: /v1/messages
  • Client: Pi 1.0.2
  • Pi thinking: low
  • Request thinking budget: 2048
  • Context: well below 262K

With thinking enabled, Strata intermittently emits a complete intended tool call inside the Anthropic thinking block instead of producing a structured tool_use.

Raw SSE from a failing request:

event: content_block_delta
data: {"type":"content_block_delta","index":0,
       "delta":{"type":"thinking_delta","thinking":"<tool_call>"}}

...

event: content_block_delta
data: {"type":"content_block_delta","index":0,
       "delta":{"type":"thinking_delta","thinking":"</tool_call>"}}

Immediately afterwards:

event: content_block_stop
data: {"type":"content_block_stop","index":0}

event: message_delta
data: {"type":"message_delta",
       "delta":{"stop_reason":"end_turn","stop_sequence":null},
       "usage":{"input_tokens":243,
                "cache_read_input_tokens":28792,
                "output_tokens":79}}

event: message_stop
data: {"type":"message_stop"}

There is no Anthropic tool_use content block in the failed turn.

Successful turns in the same session correctly produce:

event: content_block_start
data: {"type":"content_block_start","index":2,
       "content_block":{"type":"tool_use", ...}}

event: message_delta
data: {"type":"message_delta",
       "delta":{"stop_reason":"tool_use", ...}}

Reproduction

Using the same multi-step tool workload:

thinking low: C1 FAIL / C2 FAIL / C3 FAIL
thinking off: C4 PASS

Failures occurred at different context sizes (~21K–34K), so this does not appear to be a context-limit or timeout issue.

Expected

When the model transitions from reasoning to a tool call, Strata should emit a structured Anthropic tool_use block and stop_reason: "tool_use".

Actual

The intended tool call is sometimes streamed as thinking_delta, followed by a clean end_turn, causing the client agent loop to stop.

Originally created by @JakeCow on GitHub (Oct 4, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/754 **AI disclosure:** This issue was created with the assistance of AI based on captured Pi session logs and raw SSE traffic. Im not a dev :) [strata-failing-sse.txt](https://github.com/user-attachments/files/33023543/strata-failing-sse.txt) ## System - OS: Ubuntu 26.04.1 LTS - Kernel: 7.0.0-34-generic - CPU: AMD Ryzen 7 9800X3D - RAM: 32 GB DDR5-6000 - GPU: NVIDIA GeForce RTX 3090 24 GB - NVIDIA driver: 595.91.07 - CUDA: 13.2 - Strata: Docker, v0.1.38 - Model: `qwen3.8-flash-next-coder-iq1_m` - Context: 262144 - API: Anthropic-compatible `/v1/messages` - Client: Pi 1.0.2 - Pi thinking mode: `low` (`budget_tokens: 2048`) **Setup** - Strata: current Docker build / v0.1.38-era code - Model: `qwen3.8-flash-next-coder-iq1_m` - API: `/v1/messages` - Client: Pi 1.0.2 - Pi thinking: `low` - Request thinking budget: `2048` - Context: well below 262K With thinking enabled, Strata intermittently emits a complete intended tool call inside the Anthropic `thinking` block instead of producing a structured `tool_use`. Raw SSE from a failing request: ```text event: content_block_delta data: {"type":"content_block_delta","index":0, "delta":{"type":"thinking_delta","thinking":"<tool_call>"}} ... event: content_block_delta data: {"type":"content_block_delta","index":0, "delta":{"type":"thinking_delta","thinking":"</tool_call>"}} ``` Immediately afterwards: ```text event: content_block_stop data: {"type":"content_block_stop","index":0} event: message_delta data: {"type":"message_delta", "delta":{"stop_reason":"end_turn","stop_sequence":null}, "usage":{"input_tokens":243, "cache_read_input_tokens":28792, "output_tokens":79}} event: message_stop data: {"type":"message_stop"} ``` There is no Anthropic `tool_use` content block in the failed turn. Successful turns in the same session correctly produce: ```text event: content_block_start data: {"type":"content_block_start","index":2, "content_block":{"type":"tool_use", ...}} event: message_delta data: {"type":"message_delta", "delta":{"stop_reason":"tool_use", ...}} ``` ### Reproduction Using the same multi-step tool workload: ```text thinking low: C1 FAIL / C2 FAIL / C3 FAIL thinking off: C4 PASS ``` Failures occurred at different context sizes (~21K–34K), so this does not appear to be a context-limit or timeout issue. ### Expected When the model transitions from reasoning to a tool call, Strata should emit a structured Anthropic `tool_use` block and `stop_reason: "tool_use"`. ### Actual The intended tool call is sometimes streamed as `thinking_delta`, followed by a clean `end_turn`, causing the client agent loop to stop.
Author
Owner

@Niko1221 commented on GitHub (Oct 7, 2026):

Closing as a duplicate of #804, which was fixed in 0.1.40: a tool call written inside the thinking block is now run (at a line start, outside code fences) instead of ending the turn as end_turn. 0.1.40.1 tightened it further so quoted calls stay text. Please reopen with the log if your Pi client still sees it.

<!-- gh-comment-id:6037777282 --> @Niko1221 commented on GitHub (Oct 7, 2026): Closing as a duplicate of #804, which was fixed in 0.1.40: a tool call written inside the thinking block is now run (at a line start, outside code fences) instead of ending the turn as end_turn. 0.1.40.1 tightened it further so quoted calls stay text. Please reopen with the log if your Pi client still sees it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#341
No description provided.