feat(py): add tool restarts and refactor Interrupts#5069
Merged
huangjeff5 merged 11 commits intomainfrom Apr 30, 2026
Merged
Conversation
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the tool interrupt and resume mechanism, replacing the specific ToolInterruptError with a more general Interrupt exception and introducing flat keyword options for resuming generation (resume_respond, resume_restart, and resume_metadata). Key additions include a restart method on the Tool class to facilitate re-running tools with modified inputs, a define_interrupt helper for explicit human-in-the-loop checkpoints, and updated logic in the generation loop to handle pending outputs and resumed contexts. Feedback focuses on maintaining consistent error types by using GenkitError instead of ValueError and fixing Markdown formatting issues in the sample documentation.
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 7, 2026
huangjeff5
commented
Apr 8, 2026
huangjeff5
commented
Apr 8, 2026
huangjeff5
commented
Apr 8, 2026
pavelgj
reviewed
Apr 17, 2026
pavelgj
approved these changes
Apr 30, 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.
raise Interruptinstead ofctx.Interrupt(); this way there is clearer separation and you only pass ctx when needed.define_interrupt.