- Notifications
You must be signed in to change notification settings - Fork1k
feat: add RunContext support to history processors#2002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
PR Change SummaryAdded support for RunContext in history processors to enable dynamic message processing based on the current run context.
Modified Files
How can I customize these reviews?Check out theHyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
@@ -12,6 +12,7 @@ | |||
from opentelemetry.trace import Tracer | |||
from typing_extensions import TypeGuard, TypeVar, assert_never | |||
from pydantic_ai._function_schema import _takes_ctx as is_takes_ctx # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Since there is notakes_ctx
parameter, here's an attempt to probe it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This PR adds RunContext support to history processors, enabling dynamic message processing based on contextual dependencies.
- Added tests in tests/test_history_processor.py to validate context-aware processors.
- Updated _agent_graph.py to support new processor signatures by passing a RunContext instance.
- Enhanced documentation in docs/message-history.md with examples on using RunContext in history processors.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/test_history_processor.py | Added tests for synchronous, asynchronous, and mixed signature processors. |
pydantic_ai_slim/pydantic_ai/_agent_graph.py | Updated history processing to support RunContext in processors. |
docs/message-history.md | Documented the usage of RunContext in history processors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks! :)
I added a bit more type safety in the PR. 🙏
7fdd745
intopydantic:mainUh oh!
There was an error while loading.Please reload this page.
Thanks |
Following:#1970
Now we can do message processing dynamically based on
Context