接口 Agent

所有超级接口:
CallableAgent, ObservableAgent, StreamableAgent
所有已知实现类:
AgentBase, ReActAgent, UserAgent

public interface Agent extends CallableAgent, StreamableAgent, ObservableAgent
Complete agent interface combining all capabilities.

This interface defines the core contract for agents, combining:

Design Philosophy:

  • Memory management is NOT part of the core Agent interface - it's the responsibility of specific agent implementations (e.g., ReActAgent)
  • Structured output is a specialized capability provided by specific agents
  • Observe pattern allows agents to receive messages without generating a reply, enabling multi-agent collaboration

All agents in the AgentScope framework should implement this interface.

Reply contract: a single call(...) invocation produces exactly one terminal Msg. Streaming variants (see StreamableAgent) may emit many events but resolve to a single terminal Msg. This is enforced by the Mono<Msg> return type on the call methods.

  • 方法详细资料

    • getAgentId

      String getAgentId()
      Get the unique identifier for this agent.
      返回:
      Agent ID
    • getName

      String getName()
      Get the name of this agent.
      返回:
      Agent name
    • getDescription

      default String getDescription()
      Get the description of this agent.
      返回:
      Agent description
    • interrupt

      void interrupt()
      Interrupt the current agent execution. This method sets an interrupt flag that will be checked by the agent at appropriate checkpoints during execution. The interruption is cooperative and may not take effect immediately.
    • interrupt

      void interrupt(Msg msg)
      Interrupt the current agent execution with a user message. This method sets an interrupt flag and associates a user message with the interruption. The interruption is cooperative and may not take effect immediately.
      参数:
      msg - User message associated with the interruption
    • getAgentState

      default AgentState getAgentState()
      Returns the agent's runtime AgentState, or null if this agent type does not maintain one.

      This is the canonical access point used by tool methods declared with @Tool(stateInjected=true): the framework binds the live state to the AgentState parameter at invocation time.

    • getToolkit

      default Toolkit getToolkit()
      Returns the agent's live Toolkit, or null if this agent type does not maintain one.

      This is the runtime toolkit — the same instance the agent uses when listing available tools for the model and dispatching tool calls. Middleware that needs to register tools dynamically (e.g., skill loaders) must use this accessor rather than any toolkit reference captured at build time, because agents may deep-copy the toolkit during construction.