fix: Fix State restoration in Agent from a before_run hook - #12253
Merged
Conversation
…step counter is correctly picked up from the restored state
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
sjrl
commented
Aug 6, 2026
Comment on lines
+877
to
+878
| # A before_run hook can restore a saved State, so resume the execution counter from its step count. | ||
| exe_context.counter = exe_context.state.data.get("step_count", 0) |
Contributor
Author
There was a problem hiding this comment.
This is the new line that fixes the original issue
sjrl
commented
Aug 6, 2026
Comment on lines
+960
to
+961
| # A before_run hook can restore a saved State, so resume the execution counter from its step count. | ||
| exe_context.counter = exe_context.state.data.get("step_count", 0) |
Contributor
Author
There was a problem hiding this comment.
Same new line in the async method
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Related Issues
Proposed Changes:
Keep an Agent's execution counter in sync with
step_countrestored by abefore_runhook, so restarted Agents continue from the saved step instead of resetting the count.Related to the work being done in deepset-ai/hayhooks#253 for durable agent execution.
While I was working on this I realized I could help improve readability of the Agent code by using the keyword args when calling functions.
How did you test it?
Added new tests
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.