Skip to content

[Feature]: A2A服务端的会话隔离与保持问题 #820

Description

@gph01

目前我在使用agentscope的a2a功能,通过手动方式创建出AgentScopeA2aServer,

ReActAgent.Builder reactAgentBuilder = ReActAgent.builder().memory(memory).xxx;
AgentScopeA2aServer server = AgentScopeA2aServer.builder(reactAgentBuilder).xxx.build();

我发现当a2a客户端发起多次请求后,服务端智能体在执行时会共用同一个memory,导致消息会无限增长,无法保证会话隔离。
经过分析后发现时由于BaseReActAgentRunner#stream( requestMessages, options)方法的第57行,虽然通过ReActAgent.Builder#builder()创建了多个ReActAgent实例,但ReActAgent实例共用reactAgentBuilder的memory。

目前我想通过主智能体调用多个子智能体,其中主智能体是a2a的客户端,多个子智能体是多个a2a的服务端,在主智能体侧 我可以通过会话管理功能 agent.loadFrom(session, "sessionId")和agent.saveTo(session, "sessionId")做到用户和主智能体的会话隔离与保持,但是由于上述原因,我不知道该如何做到主智能体与子智能体在用户维度同样做到会话隔离与保持。

请问目前框架是否是不支持a2a客户端与服务端的会话隔离与保持呢,后续时候有支持的计划呢?或者对于我们这些框架使用侧来说,在使用侧通过编码的方式来解决该问题呢,如果可以的话,能否提供一些解决思路呢,多谢各位老师~~

Activity

  1. added
    enhancement
    on Feb 24, 2026
  2. chcodex commented on Feb 27, 2026

    @chcodex
    Contributor

    这块感觉是有问题 ,a2a协议中会话隔离不是通过contextId来实现吗,不知道为啥AgentRequestOptions里面弄了个sessionId,而且通过A2aAgent客户端进行调用也没法传递contextId或者是sessionId

  3. chcodex commented on Feb 27, 2026

    @chcodex
    Contributor

    @fang-tech @AlbumenJ 谁能帮忙解答下?

  4. chcodex commented on Feb 27, 2026

    @chcodex
    Contributor
    Image
  5. chcodex commented on Feb 27, 2026

    @chcodex
    Contributor

    这里sessionId没有放到metadata候选调用a2a智能体时,在agentRunner里面也拿不到

  6. chcodex commented on Feb 27, 2026

    @chcodex
    Contributor
    Image Image

    而且这个sessionId 存的地方和拿的地方对不上,即便上面的userMsg存放了sessionId,在这里也拿不到

  7. amyaxy commented on Mar 9, 2026

    @amyaxy
    Contributor

    io.agentscope.core.a2a.server.executor.AgentScopeAgentExecutor

    Image Image

    上述是现有的逻辑,但A2A扩展的元数据支持尚未完成,可以暂时通过msg本身传递userId,

    目前官方还没修复,可以参考这里 io.agentscope.examples.bobatea.business.config.AgentScopeRunner

    Image
  8. added this to the 1.0.12 milestone on Apr 3, 2026
  9. removed this from the 1.0.12 milestone on Apr 28, 2026
  10. added
    area/ext/integration
    on May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ext/integrationenhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions