kmail.at
← learning

langchain · difficulty ◆◆

Streaming Claude: content_block_start Now Carries Initial Text

Responsive streaming from the very first token

Your first streamed token was being eaten by the streaming adapter.

2026-07-05 · 6 min read

$ export ANTHROPIC_API_KEY=your_key

What it does

When a model emits both a content_block_start marker and text content in a single streaming chunk, that text was silently dropped. This release preserves the full content from the very first streamed token, so streamed responses begin correctly.

Why it matters

Users expect progressive token display. When the first word or phrase is missing, the UI shows a jarring gap until the next block arrives. For chatbots and real-time assistants, capturing every token from the start keeps streaming responsive and correct.

Example

$ Stream a Claude explanation and print each chunk as it arrives.
Streaming response:
Quantum entanglement is a phenomenon where two particles become interconnected
so that the quantum state of one instantly influences the other, regardless
of the distance between them.

Inspect raw chunks to confirm content_block_start now carries a text attribute.

Common flags

ChatAnthropic.stream()
Streams Claude responses as AIMessageChunk objects
content_block_start
Event carrying the start of a content block
content_block_delta
Event carrying delta text as it streams in
bind_tools()
Bind tool/function schemas to a chat model
AIMessageChunk
Streaming message chunk, concatenable

History

Origin

The issue came from the Anthropic adapter merging a block-start marker with its first text payload into one callback that was only partially handled.

Resolution

The 1.4.8 update taught the adapter to surface text that rides alongside content_block_start, closing the gap in the first token.

Fun facts

Pros & cons

pros

  • + Captures the very first token
  • + Works with existing stream loops
  • + Clear before/after comparison path

cons

  • − Same root fix as the 07-03 entry
  • − Only affects Anthropic provider

Takeaways

  1. 1Verify the first token on streamed output
  2. 2Handle both start and delta events
  3. 3Upgrade to 1.4.8 for the fix

Related commands

← all learning