feat(ai): add experimental_context parameter to prepareStep callback#10171
Merged
lgrammel merged 2 commits intovercel:mainfrom Dec 10, 2025
Merged
Conversation
Contributor
Author
|
Closing for #9682 |
|
Any change to reconsider this PR? #9682 is not really an alternative since the options cannot be changed (as far as I know) in the tools execution. Also, options is not available (yet?) on the prepareStep either. I think it would be very convenient to have the context available on the prepareStep arguments. In our use case, we have a tool that delegates/handoffs to an agent and setting the agentId on the context and the prepareStep would retrieve the necesary tools for that agent and set the system/activeTools for the specific agent. Can we reconsider this? Or is there a recommended alternative to achieve this? |
1 task
Contributor
Author
|
Any chance this can be merged please? I'm happy to make any changes if required. |
lgrammel
approved these changes
Dec 10, 2025
5 tasks
lgrammel
added a commit
that referenced
this pull request
Dec 10, 2025
## Background Similar to modifying messages, model, etc. it would be useful to be able to modify the experimental context for each step. ## Summary * improve jsdoc of `PrepareStepFunction` and `PrepareStepResult` * allow modification of `experimental_context` in `prepareStep` ## Related Issues Builds on #10171 Resolves #10482
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.
Background
experimental_contextis only available in tool execution but not in the prepareStep callback. This prevents developers from using context data (like user session info or auth state) when making step-specific decisions in multi-step workflows.Summary
Added experimental_context as an optional parameter to the prepareStep callback.
Manual Verification
Tested with both generateText and streamText.
Checklist
pnpm changesetin the project root)