Class A2aAgent

java.lang.Object
io.agentscope.core.agent.AgentBase
io.agentscope.core.a2a.agent.A2aAgent
All Implemented Interfaces:
io.agentscope.core.agent.Agent, io.agentscope.core.agent.CallableAgent, io.agentscope.core.agent.ObservableAgent, io.agentscope.core.agent.StreamableAgent, io.agentscope.core.state.StateModule

public class A2aAgent extends io.agentscope.core.agent.AgentBase
The implementation of Agent for A2A(Agent2Agent).

Agent description should get from AgentCard. If AgentCard get failed, description will be default value from Agent.getDescription()

Example Usage:


  // Simple usage.
  AgentCard agentCard = generateAgentCardByCode();
  A2aAgent a2aAgent = A2aAgent.builder().name("remote-agent-name").agentCard(agentCard).build();

  // Auto get AgentCard
  AgentCardResolver agentCardResolver = new WellKnownAgentCardResolver("http://127.0.0.1:8080", "/.well-known/agent-card.json", Map.of());
  A2aAgent a2aAgent = A2aAgent.builder().name("remote-agent-name").agentCardResolver(agentCardResolver).build();
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Create a new A2aAgent.Builder instance for A2aAgent.
    protected reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    doCall(List<io.agentscope.core.message.Msg> msgs)
     
    protected reactor.core.publisher.Mono<Void>
    doObserve(io.agentscope.core.message.Msg msg)
     
    io.agentscope.core.memory.Memory
     
    protected reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    handleInterrupt(io.agentscope.core.interruption.InterruptContext context, io.agentscope.core.message.Msg... originalArgs)
     
    void
     
    void
    interrupt(io.agentscope.core.message.Msg msg)
     

    Methods inherited from class io.agentscope.core.agent.AgentBase

    addHook, addSystemHook, call, call, call, checkInterruptedAsync, doCall, doCall, getAgentId, getDescription, getHooks, getInterruptFlag, getInterruptSource, getName, getSortedHooks, getSubscriberCount, hasSubscribers, interrupt, observe, observe, removeHook, removeSubscribers, removeSystemHook, resetInterruptFlag, resetSubscribers, stream, stream, stream, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.agentscope.core.agent.CallableAgent

    call, call, call, call, call, call, call

    Methods inherited from interface io.agentscope.core.state.StateModule

    loadFrom, loadFrom, loadIfExists, loadIfExists, saveTo, saveTo

    Methods inherited from interface io.agentscope.core.agent.StreamableAgent

    stream, stream, stream, stream, stream, stream, stream, stream
  • Method Details

    • doCall

      protected reactor.core.publisher.Mono<io.agentscope.core.message.Msg> doCall(List<io.agentscope.core.message.Msg> msgs)
      Specified by:
      doCall in class io.agentscope.core.agent.AgentBase
    • interrupt

      public void interrupt()
      Specified by:
      interrupt in interface io.agentscope.core.agent.Agent
      Overrides:
      interrupt in class io.agentscope.core.agent.AgentBase
    • interrupt

      public void interrupt(io.agentscope.core.message.Msg msg)
      Specified by:
      interrupt in interface io.agentscope.core.agent.Agent
      Overrides:
      interrupt in class io.agentscope.core.agent.AgentBase
    • doObserve

      protected reactor.core.publisher.Mono<Void> doObserve(io.agentscope.core.message.Msg msg)
      Overrides:
      doObserve in class io.agentscope.core.agent.AgentBase
    • handleInterrupt

      protected reactor.core.publisher.Mono<io.agentscope.core.message.Msg> handleInterrupt(io.agentscope.core.interruption.InterruptContext context, io.agentscope.core.message.Msg... originalArgs)
      Specified by:
      handleInterrupt in class io.agentscope.core.agent.AgentBase
    • builder

      public static A2aAgent.Builder builder()
      Create a new A2aAgent.Builder instance for A2aAgent.
      Returns:
      new builder instance
    • getMemory

      public io.agentscope.core.memory.Memory getMemory()