Skip to content

Let stream accept an agents.Context instead of model/messages/tools - #98

Merged
msullivan merged 1 commit into
mainfrom
context-kwarg
May 11, 2026
Merged

Let stream accept an agents.Context instead of model/messages/tools#98
msullivan merged 1 commit into
mainfrom
context-kwarg

Conversation

@msullivan

Copy link
Copy Markdown
Contributor

Adds a StreamContext Protocol (so the model layer doesn't have to
import the agents package) and overloads stream to accept a kw-only
context= in addition to the existing positional model, messages
(plus tools=). Mixing positional model/messages with context= is a
runtime TypeError.

Updates the default agent loop, all custom-loop examples, and the
context-bearing tests to use the shorthand.

@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
py-ai Ready Ready Preview, Comment May 11, 2026 7:43pm

Request Review

Adds a `StreamContext` Protocol (so the model layer doesn't have to
import the agents package) and overloads `stream` to accept a kw-only
`context=` in addition to the existing positional `model, messages`
(plus `tools=`).  Mixing positional model/messages with `context=` is a
runtime TypeError.

Updates the default agent loop, all custom-loop examples, and the
context-bearing tests to use the shorthand.
@msullivan
msullivan merged commit 0f8866c into main May 11, 2026
6 checks passed
@msullivan
msullivan deleted the context-kwarg branch May 11, 2026 19:51
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.

2 participants