Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused provider capability override is consistent with the Converse implementation and is covered by sync and async tests.
0 open findings
What changed in this PR
Adds graceful non-streaming fallback for Bedrock Converse structured output.
Changes:
- Disables streaming when a data model is supplied.
- Adds synchronous and asynchronous fallback tests.
- Documents Bedrock Converse behavior.
| File | Description |
|---|---|
chatlas/_provider_bedrock_converse.py |
Reports structured output as non-streamable. |
tests/test_provider_bedrock_converse.py |
Tests fallback, JSON output, warnings, and history. |
docs/get-started/structured-data.qmd |
Documents the fallback behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cpsievert
force-pushed
the
bedrock-converse-stream-fallback
branch
from
October 12, 2026 22:44
2a74e91 to
bff6d30
Compare
cpsievert
force-pushed
the
bedrock-converse-stream-fallback
branch
from
October 12, 2026 22:56
bff6d30 to
4be2cfc
Compare
cpsievert
force-pushed
the
bedrock-converse-stream-fallback
branch
from
October 12, 2026 23:00
4be2cfc to
945dfc9
Compare
cpsievert
force-pushed
the
bedrock-converse-stream-fallback
branch
from
October 12, 2026 23:02
945dfc9 to
323564a
Compare
cpsievert
force-pushed
the
bedrock-converse-stream-fallback
branch
from
October 12, 2026 23:05
323564a to
2692b45
Compare
Bedrock Converse extracts structured data through a forced tool call (like Anthropic's tool mode), and Converse streams tool input in its own event type rather than as text. As a result, streaming with a data_model silently yielded zero chunks, violating the `"".join(chunks)` contract. Override `can_stream()` so `Chat` transparently downgrades to a single non-streaming request (with a warning), yielding the complete JSON as one chunk.
cpsievert
force-pushed
the
bedrock-converse-stream-fallback
branch
from
October 16, 2026 16:45
2692b45 to
624bc7e
Compare
This was referenced Oct 16, 2026
… into bedrock-converse-stream-fallback
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ChatBedrock()with the default Converse API extracts structured data through a forced tool call (the same strategy as Anthropic's tool mode, reusingAnthropicProvider.create_data_model_toolwith a{"data": ...}-wrapped input schema). But Converse streams tool input in its own event type rather than as text deltas, andstream_content()only surfacesdelta.text— so:No crash like #317, but arguably worse: a silent empty stream that violates the documented
"".join(chunks)contract. The final turn does record theContentJsoncorrectly, which makes the empty stream even more surprising.Note that streaming the raw tool input wouldn't fix the contract either, since it's
{"data": ...}-wrapped — so graceful degradation (as with Anthropic tool mode) is the right answer.Fix
BedrockConverseProvider.can_stream()returnsFalsewhen adata_modelis present, soChattransparently downgrades to a single non-streaming request: one chunk containing the complete JSON, plus the fallback warning from #317.Test plan
tests/test_provider_bedrock_converse.pymirror the Anthropic downgrade tests from Fix crash when streaming structured data (Anthropic tool mode) #317 (mocked_converse/_converse_async, assert warning, single-chunk JSON round-trip, andContentJsonin history)pytest tests/test_provider_bedrock_converse.py— 107 passed