Anthropic provider: cache breakpoint lands on a thinking block (400: thinking.cache_control: Extra inputs are not permitted)

オープン
#455 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

Start in src/provider/anthropic.rs at Breakpoint 3 around lines 632–660, then inspect bridge_breakpoint around line 935 and the existing is_empty_text helper. Build the request described in the issue and check that thinking blocks never receive cache_control, while an earlier cacheable block still gets a breakpoint. Done means both breakpoint paths follow that rule.

索引モデルが issue の本文から書いたものです。

説明

Ask (narrow): in src/provider/anthropic.rs (0.27.9), never put cache_control on a thinking or redacted_thinking block. Anthropic accepts cache_control only on text / tool_use / tool_result / image / document blocks.

Where: Breakpoint 3 (~L632-660) scans back from the second-to-last message and sets cache_control on content.last_mut() whenever it is not an empty text block (is_empty_text, L921). bridge_breakpoint (L935) uses the same last-block rule. Neither excludes thinking blocks.

Trigger: any assistant message whose last block is thinking: a refusal (stop_reason: refusal) that kept only its thinking, an interrupted turn, or a thinking-only turn. Seen in yoyo Day 261 (yologdev/yoyo-evolve#1206):

error: API error: HTTP 400 Bad Request: messages.19.content.0.thinking.cache_control: Extra inputs are not permitted

Because the picker is deterministic, every following request rebuilds the same body, so the session may stay poisoned (not measured on yoagent; opencode reported exactly that for the same defect).

Fix shape used elsewhere (litellm aa3d59d0, antra-tess/membrane 2d405944 lastCacheableBlockIndex, opencode #51141): pick the last cacheable block in the message; if the message has none, keep scanning to the previous message. Same rule in bridge_breakpoint.

Test: a request built from [user, assistant(thinking only), user] has no cache_control on any thinking block and still has one breakpoint on an earlier cacheable block.

yoyo-side: #1206 tracks the yoyo test that pins this once a release ships.

主要言語
Rust
スター
327
フォーク
46
平均マージ
2時間 36分
マージ済み PR(30日)
107

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

yologdev/yoagent のほかの issue

yologdev/yoagent の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。