Rework models api#55
Merged
Merged
Conversation
anbuzin
commented
Apr 28, 2026
Collaborator
- implement stream context manager
- make messages and parts mutable
- move message aggregation from individual adapters into ai.stream
- simplify adapters to emit only streaming events
- temporarily patch agents and middleware for the new api
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
1. implement stream context manager 2. make messages and parts mutable 3. move message aggregation from individual adapters into ai.stream 4. simplify adapters to emit only streaming events 5. temporarily patch agents and middleware for the new api
msullivan
approved these changes
Apr 29, 2026
|
|
||
| # Bridge: emit MessageStart/MessageEnd around the assistant message | ||
| # the model stream just produced, so _collect_messages and downstream | ||
| # consumers (AI-SDK outbound, label stamping) see the same boundary |
Contributor
There was a problem hiding this comment.
(what is AI-SDK outbound?)
Collaborator
Author
There was a problem hiding this comment.
The part of the AI SDK UI adapter (the one that has useChat) responsible for converting the stream from backend to frontend format
| from collections.abc import AsyncGenerator, AsyncIterable, Awaitable | ||
|
|
||
| from .. import types | ||
| from . import events as events_ |
Contributor
There was a problem hiding this comment.
Why the underscore? Because there are lots of variables named events?
Collaborator
Author
There was a problem hiding this comment.
There's at least one somewhere in there
msullivan
added a commit
that referenced
this pull request
Apr 29, 2026
Gateway will both stream a tool call and provide a full tool-call event after, which leads to duplicate tool calls in the stream, which then blow up in the validator. This duplication in the stream existed previously, but changes in how the stream is assembled in #55 cause it to break tool calling in the agent (no longer using an id-keyed dict to build up the parts). Fix it at the ai-gateway parsing level.
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.