feat: add request.messages to StepResult#15052
Merged
Merged
Conversation
felixarntz
approved these changes
May 6, 2026
Collaborator
felixarntz
left a comment
There was a problem hiding this comment.
Looks good, but there are some test failures: https://github.com/vercel/ai/actions/runs/25442150126/job/74636080596?pr=15052
Should we add an example in examples/ai-functions/src/agent where we add some simple compaction logic based on this? that way we have a reference in the repo we can run for testing (and adjust in the future if/when we add a primitive for compaction).
Collaborator
Author
|
@felixarntz was holding off on the compaction example until all the planned changes land. at the end the compaction example will be much simpler than just adding it now |
lgrammel
added a commit
that referenced
this pull request
May 6, 2026
…e storage opt-in (#15057) ## Background Storing the request messages on each step can lead to memory issues, similar to storing the request and response body. See #12126 ## Summary * make `request.messages` optional * add an `include.requestMessages` option for opting into keeping them for each step (default false) ## Related Issues Similar to #12126 Builds on #15052
Contributor
|
🚀 Published in:
|
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
Accessing the input messages for a particular step can help with compaction, e.g. when you want to continue compacted messages in
prepareStep.Summary
Add
request.messagestoStepResult.Example
In
prepareStep, you can access the input messages from the last step viasteps.at(-1).request.messagesFuture Work
include.requestStepsflagresponse.messagesonStepResultto only the messages from that stepinputMessages,responseMessagestoprepareStepparamsmessagesresponse fromprepareStep(continue using those messages)WorkflowAgent@gr2mRelated Issues
Relates to #9631 and #6615