Conversation
…oolset interface Co-authored-by: a7ul <4029423+a7ul@users.noreply.github.com> Agent-Logs-Url: https://github.com/a7ul/vibes/sessions/123b1eb5-ab1f-4bd4-96d5-a400b2803a78
Copilot
AI
changed the title
[WIP] Chore: port pydantic-ai v1.71.0 changes
chore: port pydantic-ai v1.71.0 — Toolset forRun/forRunStep lifecycle hooks
Mar 25, 2026
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.
Ports the
AbstractToolset.for_run/for_run_stepstate-isolation hooks introduced in pydantic-ai v1.71.0 to the TypeScript SDK. Bumps tracked version to1.71.0.Changes
lib/toolsets/toolset.ts— Two optional methods added to theToolset<TDeps>interface:forRun?(ctx)— called once per run before the first model turn; return a run-scoped instance (default:this)forRunStep?(ctx)— called at the start of each model turn with the run-scoped instance; return a step-scoped instance (default:this)lib/execution/_run_utils.ts— NewinitToolsetsForRun()helper (exported) fans outforRuncalls; privateresolveToolsetsForStep()fans outforRunStepcalls per turn;prepareTurn()gains an optionalrunScopedToolsetsparam that triggers step resolutionlib/execution/run.ts/stream.ts/event_stream.ts— Each entry-point callsinitToolsetsForRunbefore the turn loop and threads the run-scoped array throughprepareTurntests/toolsets_test.ts— 5 new tests:forRuncalled once per run, run isolation,forRunStepcalled per turn, per-step distinct instances, both hooks combineddocs/reference/features.mdx— New rows forforRunandforRunStepin the Toolsets parity tableUsage example
Original prompt
This section details on the original issue you should resolve
<issue_title>chore: port pydantic-ai v1.71.0 changes</issue_title>
<issue_description>## Versions
v1.70.0v1.71.0Release Summary
Pydantic AI Release: v1.70.0 → v1.71.0
PyPI: https://pypi.org/project/pydantic-ai/1.71.0/
GitHub Release: https://github.com/pydantic/pydantic-ai/releases/tag/v1.71.0
Compare: pydantic/pydantic-ai@v1.70.0...v1.71.0
Release Notes
What's Changed
🚀 Features
AgentSpecandAgent.from_filefor loading agents from YAML/JSON, with support for templated instructions referencing deps (viaTemplateStr)Hookscapability for defining hooks using decoratorsThinkingcapability and cross-providerthinkingmodel settingWebSearch,WebFetch,MCP,ImageGenerationthat automatically fall back from builtin (provider) tools to local toolsAbstractToolset.for_runandfor_run_stepfor state isolationopenai:gpt-5.4-miniandopenai:gpt-5.4-nanoFull Changelog:
Changed Files in pydantic-ai