fix: clear jump_to state after each MessagesModelHook execution to prevent residual values#4423
Open
zhexueqi wants to merge 1 commit intoalibaba:mainfrom
Open
Conversation
…event residual values When a MessagesModelHook overrides canJumpTo() to return List.of(JumpTo.end), the framework registers a conditional edge that reads the jump_to field from state. Previously, if beforeModel/afterModel returned AgentCommand without a JumpTo intent, the jump_to field was not written to state, leaving any residual value from a previous execution intact. This caused the workflow to terminate prematurely even when the hook did not intend to jump. Fix: Always write jump_to to state in BeforeModelAction and AfterModelAction. When the AgentCommand has no JumpTo intent, explicitly set null to clear any stale value from prior executions. Fixes alibaba#4421
1 task
|
I've verified this PR fixes the issue described in #4421. Thanks for the quick fix! Tested on my local environment with the Thanks again! |
Collaborator
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.
Problem
When a
MessagesModelHookoverridescanJumpTo()to returnList.of(JumpTo.end), the framework registers a conditional edge that reads thejump_tofield from state to decide routing.Previously, if
beforeModel()orafterModel()returnednew AgentCommand(messages)(no jump intent), thejump_tofield was not written to state. This left any residual value from a previous execution intact, causing the workflow to terminate prematurely even when the hook did not intend to jump.Root Cause
In
MessagesModelHook.BeforeModelActionandAfterModelAction:Fix
Always write jump_to to state. When there is no jump intent, explicitly set null to clear any stale value from prior executions.
// After fix - always clears or sets jump_to
result.put("jump_to", command.getJumpTo() != null ? command.getJumpTo().name() : null);
Fixes #4421