Back Home

GitHub Repo

LangChain Fixes Missing Anthropic Streaming Callbacks, Restoring Time-to-First-Token Tracking

On November 2, LangChain released langchain-anthropic 1.7.9, fixing missing streaming events for tool, document, and extended-thinking requests. The update lets LangSmith receive the events needed to calculate time to first token; engineering teams should still verify compatibility with custom callbacks.

Dirck van Baburen · Public domain · Image source
zh-Hant

On November 2, LangChain released langchain-anthropic 1.7.9, adding a callback fix for Anthropic streaming content blocks. The change addresses an observability gap in agent applications: requests using tools, documents, or extended thinking could continue receiving model output while LangSmith lacked time-to-first-token (TTFT) data. The fix was merged and included in the release. Release notes

The issue stemmed from the data type used for streamed content. The maintainers noted that whenever a request includes any of these features, each streaming chunk’s content is a list of content blocks—even if the final response is plain text and no tool is called. The synchronous and asynchronous streaming paths previously triggered on_llm_new_token only when content was a string, so these requests did not emit token callbacks. As a result, LangSmith lacked the events needed to calculate TTFT in use cases such as LangGraph messages mode. Fix details

The new implementation also triggers callbacks for content-block streams, passing token as text while retaining the complete block information in chunk. This matters especially for teams that write their own stream handlers: displayed text and structured data can be accessed separately. The official documentation also explains that LangSmith’s streaming time-to-first-token measurement depends on events; when using the RunTree API directly, developers must add a new_token event to populate this metric. Official tracing documentation

From an engineering perspective, this fix should help teams compare wait times for plain-text and tool-using agent requests, avoiding the misinterpretation of missing measurements as a difference in model behavior. After upgrading, teams should compare identical requests across synchronous, asynchronous, and custom callback paths to confirm that events are restored, text can still be concatenated, and tool and thinking blocks remain accessible through chunk. The release materials provide no inference-speed data and make no commitment to backfill historical traces; evaluation should focus on measurement completeness for new requests rather than expecting model generation to become faster.

Sources

  1. Release langchain-anthropic==1.7.9
  2. fix(anthropic): report streamed content-block tokens to callbacks #41643
  3. Log LLM calls — Time-to-first-token