Repository navigation
fix(core): emit tool result events on manual HITL denial and support custom denial reason - #2546
Merged
jujn merged 4 commits intoSep 21, 2026
Merged
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
liulangjietou
force-pushed
the
fix/2492-deny-reason-events
branch
from
August 4, 2026 02:42
03f8c97 to
21897b6
Compare
…custom denial reason Two fixes for the ASK-permission deny flow (issue agentscope-ai#2492): 1. ConfirmResult gains an optional 'reason' field. When the user denies a tool call, the reason (if present) becomes the text of the DENIED tool result instead of the hardcoded "Permission denied by user", so the model can see why the call was rejected. All existing constructors are preserved as delegating overloads; old JSON payloads without 'reason' deserialize unchanged. 2. The manual-deny path in applyConfirmResults now emits the same ToolResultStartEvent -> ToolResultTextDeltaEvent -> ToolResultEndEvent triple that the rule-based auto-deny path already emits. Previously a manual denial only wrote the DENIED ToolResultBlock into context, so streamEvents consumers (e.g. AG-UI frontends) never observed any tool result for the denied call. Closes agentscope-ai#2492
liulangjietou
force-pushed
the
fix/2492-deny-reason-events
branch
from
August 4, 2026 02:45
21897b6 to
6cfffed
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Collaborator
|
This PR has conflicts with the git fetch origin
git checkout fix/2492-deny-reason-events
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
oss-maintainer
approved these changes
Aug 5, 2026
oss-maintainer
left a comment
Collaborator
There was a problem hiding this comment.
Summary
Reviewed the changes in this PR. The modifications look reasonable and follow the project conventions.
Automated review by "github-manager-bot"
…n-events # Conflicts: # agentscope-core/src/test/java/io/agentscope/core/agent/ReActAgentHitlTest.java
5 tasks done
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.
Summary
Fixes #2492 — both points reported in the issue.
1. Custom denial reason (
ConfirmResult.reason)The manual-deny path wrote a hardcoded
"Permission denied by user"tool result.ConfirmResultnow carries an optionalreasonfield: when the user denies a tool call with a reason, that text becomes the DENIED tool result written back to the model context (and the event delta text), so the model can understand why the call was rejected and react accordingly.Backward compatibility:
(confirmed, toolCall)and(confirmed, toolCall, rules)still compile and behave identically).reasondeserialize withreason = null, which falls back to the existing default text — behavior is unchanged for all current callers.2. Manual denial now emits tool result events
Verified asymmetry on
main: the rule-based auto-deny path emitsToolResultStartEvent → ToolResultTextDeltaEvent → ToolResultEndEvent(state DENIED), but the manual user deny path inapplyConfirmResultsonly wrote the DENIEDToolResultBlockinto context —streamEventsconsumers (e.g. AG-UI frontends) never saw any tool result for the denied call.applyConfirmResultsnow emits the same event triple per denied tool call via the call's bound event sink (publishEvent), carrying the denial reason as the delta text. A freshreplyIdis generated for the resume call's denial events, consistent with how each acting phase generates its ownreplyId.Tests
Three new regression tests in
ReActAgentHitlTest:deniedConfirmResultWithCustomReasonWritesReasonToContext— custom reason replaces the default text in the persisted tool result.deniedConfirmResultOnResumeEmitsToolResultEventTriple— Start/Delta/End events are emitted in order with state DENIED and the reason as delta (fails on currentmain).deniedConfirmResultWithoutReasonKeepsDefaultText— no reason supplied → default"Permission denied by user"preserved.Full
agentscope-coresuite passes: 2246 tests, 0 failures.mvn spotless:checkpasses.