发布

  • anthropic: close thinking block before tool_use when no text in between (#14825)

    frostbyte_neo 发布于 2026-03-13 20:12:05 +00:00

    Root cause: StreamConverter.Process() only incremented contentIndex when
    closing a thinking block if text content was present. When a model emitted
    thinking followed directly by a tool_use block (no text in between),
    thinkingDone was never set and contentIndex was not incremented, causing the
    tool_use content_block_start to reuse index 0. Clients expecting sequential
    indices would then fail to find the tool content block.

    Fix: In the tool call loop, close any open thinking block (thinkingStarted &&
    !thinkingDone) and increment contentIndex before opening the tool_use block,
    mirroring the existing logic that closes an open text block.

    Fixes #14816

    下载附件