Skip to content

feat(HITL): Emit UserConfirmResultEvent when resuming permission HITL - #2511

Merged
jujn merged 4 commits into
mainfrom
emit-user-confirm-result-event
Aug 5, 2026
Merged

feat(HITL): Emit UserConfirmResultEvent when resuming permission HITL#2511
jujn merged 4 commits into
mainfrom
emit-user-confirm-result-event

Conversation

@jujn

@jujn jujn commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Emit UserConfirmResultEvent when ReActAgent accepts ConfirmResult payloads while resuming permission HITL.
  • Persist the pending confirmation request replyId on the live assistant message so the result event can correlate with the earlier RequireUserConfirmEvent.
  • Validate that resume ConfirmResults fully cover all current ASKING tool calls before emitting the event or mutating context.
  • Update HITL tests and event docs for the new resume-event behavior.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

Copilot AI review requested due to automatic review settings July 31, 2026 12:36
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.85246% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...e/src/main/java/io/agentscope/core/ReActAgent.java 68.33% 9 Missing and 10 partials ⚠️

📢 Thoughts on this report? Let us know!

@jujn
jujn marked this pull request as draft July 31, 2026 14:22
@jujn
jujn force-pushed the emit-user-confirm-result-event branch from d41ced1 to ca2d354 Compare August 2, 2026 14:41
@jujn
jujn marked this pull request as ready for review August 2, 2026 14:41
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@zouyx zouyx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Reviewed confirmation validation, replyId correlation, and partial-confirmation behavior. ReActAgentHitlTest passes locally; CI is green.

@zouyx zouyx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation requirement: this PR changes the observable streamEvents contract by emitting UserConfirmResultEvent on resume and correlating it with the earlier RequireUserConfirmEvent replyId, but it contains no docs/ update. The current English and Chinese message-and-event docs still call UserConfirmResultEvent an input event and do not document getReplyId correlation. Please update both language versions, ideally alongside the HITL flow documentation, and add this behavior to the PR checklist before merging.

}
normalized.add(result);
}
return List.copyOf(normalized);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个有必要 copyOf 吗?

* correlation metadata there lets the next call recover it from session state.
*/
private void persistPendingConfirmRequest(String replyId) {
Msg lastAssistant = findLastAssistantMsg();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我看这个动作和上面是一样,是否作为参数传进来就好了?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是在 actingStream 里面调的,只能重新 findLastAssistantMsg 一次了

* HITL request.
*/
private void clearPendingConfirmRequest() {
Msg lastAssistant = findLastAssistantMsg();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

甚至我看不太懂,这个方法和上面方法的区别是什么?多了个 if?

return "";
}
Object raw = confirmRequestMsg.getMetadata().get(Msg.METADATA_CONFIRM_REQUEST_REPLY_ID);
return raw instanceof String s ? s : "";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: when resuming a persisted ASKING state created before this change, METADATA_CONFIRM_REQUEST_REPLY_ID will be absent, so UserConfirmResultEvent#getReplyId() returns an empty string. The resume itself still works, and the original reply ID cannot be recovered, so this behavior seems reasonable. However, the documentation currently guarantees that the ID always matches the earlier RequireUserConfirmEvent. Could we document that replyId may be empty for legacy or manually restored states that do not contain the new correlation metadata?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以先 approve 吗?因为明天可能要发版,其它的PR需要等这个合入

@jujn
jujn merged commit a980c9b into main Aug 5, 2026
11 checks passed
@jujn
jujn deleted the emit-user-confirm-result-event branch August 5, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants