Skip to content

fix: Fix returned Anthropic reasoning blocks - #455

Open
jacoblee93 wants to merge 1 commit into
databricks:mainfrom
jacoblee93:jacob/reasoning
Open

fix: Fix returned Anthropic reasoning blocks#455
jacoblee93 wants to merge 1 commit into
databricks:mainfrom
jacoblee93:jacob/reasoning

Conversation

@jacoblee93

Copy link
Copy Markdown

Preserve structured content blocks returned by Databricks chat models instead of JSON-serializing them.

This fixes Anthropic reasoning responses where the initial streamed chunk contains a structured reasoning block and subsequent chunks contain answer text. Previously, LangChain combined these into a mixed list:

[reasoning_block, "answer text"]

Changes

  • Preserve list-based structured content in non-streaming and streaming message conversion.
  • After a structured streaming chunk is received, convert subsequent text deltas into indexed text blocks:
  [
      reasoning_block,
      {"type": "text", "text": "answer text", "index": 1},
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant