Handle signature_delta streaming event for Anthropic thinking blocks

The Anthropic streaming API sends thinking block signatures via a
signature_delta event, not in content_block_start or content_block_stop.
The parser was ignoring this event type, falling back to the empty
placeholder signature from content_block_start, causing "Invalid
signature in thinking block" errors on multi-turn conversations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-02-23 14:39:42 -05:00
parent 9342b5be76
commit 6071bb0aa7

View file

@ -800,6 +800,19 @@ impl StreamAccumulator {
delta: thinking.to_string(),
}]
}
"signature_delta" => {
let signature = delta
.and_then(|d| d.get("signature"))
.and_then(serde_json::Value::as_str)
.map(String::from);
if let Some(ContentBlockKind::Thinking {
signature: ref mut sig,
}) = self.current_block
{
*sig = signature;
}
vec![]
}
_ => vec![],
}
}