Skip to content

fix(agui): add metadata field to AguiMessage for HITL confirm results - #2452

Open
Blue-Berrys wants to merge 2 commits into
agentscope-ai:mainfrom
Blue-Berrys:fix/1726-agui-message-metadata
Open

fix(agui): add metadata field to AguiMessage for HITL confirm results#2452
Blue-Berrys wants to merge 2 commits into
agentscope-ai:mainfrom
Blue-Berrys:fix/1726-agui-message-metadata

Conversation

@Blue-Berrys

@Blue-Berrys Blue-Berrys commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • Add optional metadata to AguiMessage (JSON-compatible, backward compatible).
  • Map metadata bidirectionally in AguiMessageConverter so agentscope_confirm_results can reach Msg.metadata.
  • Add converter regression tests for HITL confirm metadata.

Closes #1726

Description

AG-UI messages previously had no metadata channel, so frontends could not attach HITL ConfirmResults under agentscope_confirm_results. This blocked permission confirmation over AG-UI.

Checklist

  • Code has been formatted with mvn spotless:apply
  • Targeted tests pass (AguiMessageConverterTest, 26 tests)
  • Related documentation has been updated (N/A)
  • Code is ready for review

Testing

JAVA_HOME=/path/to/jdk21 mvn \
  -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agui -am \
  -Dspotless.check.skip=true \
  -Dtest=AguiMessageConverterTest,AguiModelTest \
  -Dsurefire.failIfNoSpecifiedTests=false \
  test

Allow AG-UI clients to pass agentscope_confirm_results via message
metadata so permission confirmation can complete over the protocol.
Closes agentscope-ai#1726.
@CLAassistant

CLAassistant commented Jul 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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.

@oss-maintainer oss-maintainer 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.

Review — Approved ✅

This addresses the critical HITL confirmation gap in the AG-UI adapter (#2437, #1726).

Code analysis:

  • Adding metadata as an optional Map<String, Object> field to AguiMessage is the right approach — it's the natural place for HITL confirm results without disrupting the existing message model.
  • Backward compatibility is well handled: existing 5-arg constructor delegates to the new 6-arg one with null metadata. All static factory methods updated.
  • Immutable map wrapping (Collections.unmodifiableMap(new LinkedHashMap<>(...))) is correct.
  • @JsonInclude(JsonInclude.Include.NON_EMPTY) ensures metadata doesn't pollute serialized output when absent.
  • equals()/hashCode()/toString() all properly updated.

Converter:

  • Bidirectional metadata transfer in toMsg() and toAguiMessage() is clean and null-safe.

Tests:

  • Roundtrip tests for metadata in both directions + empty metadata edge case. Good coverage.

This is the missing bridge for RequireUserConfirmEvent mentioned in #2437. Well done.

LGTM. Please sign the CLA.

Skip redundant async mirrors when the write target is already local disk,
and drain pending mirrors on HarnessAgent.close() so CI no longer flakes
on LocalFilesystemUserIsolationExampleTest.
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

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.

[Bug]:AG-UI 协议缺少 metadata 支持,导致无法完成权限确认流程

3 participants