Repository navigation
fix: keep streaming working for output schemas with field aliases - #314
Merged
Eigenwise merged 2 commits intoOct 19, 2026
Merged
Conversation
run_stream() rebuilt the final response with output_schema(**last_response.model_dump()). model_dump() keys the data by field name, so for an output schema with a field alias the call failed with 'Field required' after the whole response had streamed, and the reply was never added to history. Validate with by_name=True so field names are accepted alongside aliases.
…onse run_async_stream() had the same output_schema(**model_dump()) rebuild as run_stream(), so an output schema with a field alias failed the same way once the async stream ended.
Eigenwise
approved these changes
Oct 19, 2026
Eigenwise
left a comment
Owner
There was a problem hiding this comment.
Reproduced the sync and async alias failures against current main. Both pass with this change, including history recording. Combined core suite, Black and Flake8 pass. Thanks.
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.
run_stream()andrun_async_stream()fail at the end of the stream when the output schema has a field alias.run()works fine with the same schema.Both streaming methods rebuild the final response like this:
model_dump()keys the data by field name, but a field declared withalias=only accepts its alias on input. So the whole response streams fine and then fails validation. The reply also never gets added to history.Repro with a real model (gpt-4o-mini through Instructor):
On
main:With this PR:
The fix validates the dumped data with
model_validate(..., by_name=True), so field names are accepted alongside aliases. Schemas without aliases behave exactly as before.by_nameis available from pydantic 2.11, which matches the current floor.I added a regression test for each streaming method. Both fail on
mainand pass here.black --check,flake8andpytest --cov=atomic_agents atomic-agents(623 passed) are green.