Skip to content

feat(a2a): route remote reasoning events through middleware - #2953

Draft
wmh123wmh1 wants to merge 1 commit into
agentscope-ai:mainfrom
wmh123wmh1:investigate/issue-2612-a2a-middleware
Draft

feat(a2a): route remote reasoning events through middleware#2953
wmh123wmh1 wants to merge 1 commit into
agentscope-ai:mainfrom
wmh123wmh1:investigate/issue-2612-a2a-middleware

Conversation

@wmh123wmh1

Copy link
Copy Markdown
Contributor

Summary

  • add middleware() and middlewares() configuration to A2aAgent.Builder
  • keep registered middlewares in the same order convention as ReActAgent
  • bridge the A2A reasoning lifecycle (start, chunk, end) into MiddlewareBase.onReasoning()
  • preserve the existing Hook API and deprecated stream() behavior
  • add focused builder and event-order compatibility tests

Intentionally limited scope

This is a small draft implementation to validate the integration direction with maintainers.

  • No streamEvents() API is added.
  • onActing(), onModelCall(), and onSystemPrompt() are unchanged.
  • Existing Hook dispatch and legacy response behavior are retained.
  • The A2A bridge currently exposes the remote lifecycle entries as CustomEvents to the reasoning middleware; the returned middleware event stream is consumed for lifecycle operators, while response rewriting remains out of scope for this first pass.

Refs #2612

Tests

  • mvn -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-a2a/agentscope-extensions-a2a-client -am -DskipITs test
    • agentscope-core: 2316 tests, 0 failures, 9 skipped
    • A2A client: 112 tests, 0 failures

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.48718% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...scope/core/a2a/agent/event/ClientEventContext.java 72.41% 1 Missing and 7 partials ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant