Class HarnessAgent

java.lang.Object
io.agentscope.harness.agent.HarnessAgent
All Implemented Interfaces:
io.agentscope.core.agent.Agent, io.agentscope.core.agent.CallableAgent, io.agentscope.core.agent.ObservableAgent, io.agentscope.core.agent.StreamableAgent, AutoCloseable

public class HarnessAgent extends Object implements io.agentscope.core.agent.Agent, AutoCloseable
HarnessAgent is the user-facing harness API that wraps a ReActAgent with workspace / filesystem / sandbox / subagent / skill / plan-mode / MCP orchestration.

Use builder() to configure. For plain ReAct usage without any of the above, use ReActAgent.builder() directly.

Capabilities added on top of the inner ReActAgent:

  • Workspace-based context loading (AGENTS.md, MEMORY.md, KNOWLEDGE.md)
  • Pluggable file-system backend (local, sandbox, remote/composite)
  • Subagent orchestration via task / task_output tools (sync + background)
  • Skill loading via AgentSkillRepository, including the self-learning loop
  • Memory flush + message offload before context compression
  • Workspace-managed tools.json (MCP servers + allow/deny filter)
  • Plan mode (read-only design phase) with plan_enter/plan_write/plan_exit tools
  • Context-overflow emergency compaction via CompactionMiddleware

Thread Safety: HarnessAgent is stateless between calls and safe to use as a singleton serving multiple users/sessions concurrently. Each call() uses the RuntimeContext's (userId, sessionId) to isolate state. Calls targeting the same session are serialized automatically; different sessions run in parallel.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder for HarnessAgent.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    call(io.agentscope.core.message.Msg msg, io.agentscope.core.agent.RuntimeContext ctx)
     
    reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    call(String text, io.agentscope.core.agent.RuntimeContext ctx)
    Calls the agent with a plain text input and per-call RuntimeContext.
    reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    call(List<io.agentscope.core.message.Msg> msgs)
    Deprecated.
    Use call(List, RuntimeContext) with explicit runtime context.
    reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    call(List<io.agentscope.core.message.Msg> msgs, com.fasterxml.jackson.databind.JsonNode schema)
    Deprecated.
    Use call(List, JsonNode, RuntimeContext) with explicit runtime context.
    reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    call(List<io.agentscope.core.message.Msg> msgs, com.fasterxml.jackson.databind.JsonNode schema, io.agentscope.core.agent.RuntimeContext ctx)
     
    reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    call(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
     
    reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    call(List<io.agentscope.core.message.Msg> msgs, Class<?> structuredModel)
    Deprecated.
    Use call(List, Class, RuntimeContext) with explicit runtime context.
    reactor.core.publisher.Mono<io.agentscope.core.message.Msg>
    call(List<io.agentscope.core.message.Msg> msgs, Class<?> structuredModel, io.agentscope.core.agent.RuntimeContext ctx)
     
    <T extends Channel>
    T
    channel(T channel)
    Returns a channel bound to this agent's internal gateway.
    void
    clearContext(io.agentscope.core.agent.RuntimeContext ctx)
    Clears the model-visible conversation context for the session identified by ctx.
    void
    clearContext(String userId, String sessionId)
    Clears the model-visible conversation context for one (userId, sessionId) session.
    void
    Clears all locally cached per-session state and permission engines held by the wrapped ReActAgent.
    void
    clearStateCache(io.agentscope.core.agent.RuntimeContext ctx)
    Clears the locally cached state and permission engine for the session identified by ctx.
    void
    clearStateCache(String userId, String sessionId)
    Clears the locally cached state and permission engine for one (userId, sessionId) slot.
    void
     
    void
    enterPlanMode(io.agentscope.core.agent.RuntimeContext ctx)
    Enters plan mode for the session identified by the given RuntimeContext.
    void
    enterPlanMode(String userId, String sessionId)
    Enters plan mode for the given (userId, sessionId) session, independent of which slot is currently active.
    void
    exitPlanMode(io.agentscope.core.agent.RuntimeContext ctx)
    Exits plan mode for the session identified by the given RuntimeContext.
    void
    exitPlanMode(String userId, String sessionId)
    Exits plan mode for the given (userId, sessionId) session and persists the change.
    Returns the internal gateway backing channel(T).
     
    io.agentscope.core.state.AgentState
    Deprecated.
    Use getDelegate().getAgentState(RuntimeContext) or .getAgentState(String, String) with explicit session identity.
    Returns the CompactionMiddleware instance if compaction was configured, or null.
     
    io.agentscope.core.ReActAgent
    Returns the wrapped ReActAgent.
     
    The distributed store configured on this agent, or null for local deployments.
    int
     
    io.agentscope.core.model.Model
     
     
    io.agentscope.core.permission.PermissionMode
    getPermissionMode(String userId, String sessionId)
     
    List<io.agentscope.core.skill.repository.AgentSkillRepository>
    Returns the ordered list of AgentSkillRepository instances bound to this agent (low to high priority).
    Access to the sidecar telemetry store.
    io.agentscope.core.state.AgentStateStore
     
    The internal DefaultAgentManager able to re-materialize this agent's subagents, or null when none is owned (e.g. session-mode external subagent tool).
    Background subagent TaskRepository owned by the subagent middleware, or null when subagents are not configured.
    io.agentscope.core.tool.Toolkit
     
    Returns the workspace manager bound to this agent, or null if not configured.
    void
     
    void
    interrupt(io.agentscope.core.agent.RuntimeContext ctx)
    Interrupts the in-flight call for the session identified by ctx.
    void
    interrupt(io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.message.Msg msg)
    Interrupts the in-flight call for the session identified by ctx with an associated user message.
    void
    interrupt(io.agentscope.core.message.Msg msg)
     
    void
    interrupt(String userId, String sessionId)
    Interrupts the in-flight call for a specific (userId, sessionId) session.
    void
    interrupt(String userId, String sessionId, io.agentscope.core.message.Msg msg)
    Interrupts the in-flight call for a specific (userId, sessionId) session with an associated user message.
    boolean
    isPlanModeActive(io.agentscope.core.agent.RuntimeContext ctx)
     
    boolean
    isPlanModeActive(String userId, String sessionId)
     
    reactor.core.publisher.Mono<Void>
    observe(io.agentscope.core.message.Msg msg)
     
    reactor.core.publisher.Mono<Void>
    observe(List<io.agentscope.core.message.Msg> msgs)
     
    io.agentscope.core.agent.AgentRun<io.agentscope.core.message.Msg>
    prepareCall(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
    Prepare a cancellable reply execution covering the complete harness/sandbox lifecycle.
    io.agentscope.core.agent.AgentRun<io.agentscope.core.event.AgentEvent>
    prepareRun(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
    Prepare a cancellable execution covering the complete harness/sandbox lifecycle.
    reactor.core.publisher.Mono<SkillPromoter.PromotionResult>
    promoteSkill(String name, String reviewerId, io.agentscope.core.agent.RuntimeContext ctx)
    Promote a draft skill for the explicitly supplied request context.
    Query the audit log for a given UTC day.
    reactor.core.publisher.Mono<SkillCurator.CuratorRunReport>
    Force-run the skill curator immediately, bypassing the idle-and-interval gate.
    void
    setPermissionMode(io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.permission.PermissionMode mode)
    Switches the PermissionMode for the session identified by the given RuntimeContext at runtime.
    void
    setPermissionMode(String userId, String sessionId, io.agentscope.core.permission.PermissionMode mode)
    Switches the PermissionMode for the given (userId, sessionId) session at runtime, preserving configured rules and rebuilding the cached permission engine.
    reactor.core.publisher.Flux<io.agentscope.core.agent.Event>
    stream(io.agentscope.core.message.Msg msg, io.agentscope.core.agent.RuntimeContext ctx)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 2.0.0, for removal.
    reactor.core.publisher.Flux<io.agentscope.core.agent.Event>
    stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 2.0.0, for removal.
    reactor.core.publisher.Flux<io.agentscope.core.agent.Event>
    stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 2.0.0, for removal.
    reactor.core.publisher.Flux<io.agentscope.core.agent.Event>
    stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, com.fasterxml.jackson.databind.JsonNode schema)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 2.0.0, for removal.
    reactor.core.publisher.Flux<io.agentscope.core.agent.Event>
    stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, com.fasterxml.jackson.databind.JsonNode schema, io.agentscope.core.agent.RuntimeContext ctx)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 2.0.0, for removal.
    reactor.core.publisher.Flux<io.agentscope.core.agent.Event>
    stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, io.agentscope.core.agent.RuntimeContext ctx)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 2.0.0, for removal.
    reactor.core.publisher.Flux<io.agentscope.core.agent.Event>
    stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, Class<?> structuredModel)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 2.0.0, for removal.
    reactor.core.publisher.Flux<io.agentscope.core.agent.Event>
    stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, Class<?> structuredModel, io.agentscope.core.agent.RuntimeContext ctx)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 2.0.0, for removal.
    reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>
    streamEvents(io.agentscope.core.message.Msg msg)
    Deprecated.
    Use streamEvents(Msg, RuntimeContext) with explicit runtime context.
    reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>
    streamEvents(io.agentscope.core.message.Msg msg, io.agentscope.core.agent.RuntimeContext ctx)
    Stream fine-grained AgentEvents for a single message with a caller-supplied RuntimeContext.
    reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>
    Deprecated.
    Use streamEvents(String, RuntimeContext) with explicit runtime context.
    reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>
    streamEvents(String text, io.agentscope.core.agent.RuntimeContext ctx)
    Stream fine-grained AgentEvents for a plain text input with a caller-supplied RuntimeContext.
    reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>
    streamEvents(List<io.agentscope.core.message.Msg> msgs)
    Deprecated.
    Use streamEvents(List, RuntimeContext) with explicit runtime context.
    reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent>
    streamEvents(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
    Stream fine-grained AgentEvents for a list of messages with a caller-supplied RuntimeContext.
    workspaceFor(String userId, String sessionId)
    Returns a WorkspaceManager view whose filesystem and namespace are bound to the given (userId, sessionId) for the duration of the returned view's IO.

    Methods inherited from class java.lang.Object

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

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

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

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

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

    • getWorkspaceManager

      public WorkspaceManager getWorkspaceManager()
      Returns the workspace manager bound to this agent, or null if not configured.
    • workspaceFor

      public WorkspaceManager workspaceFor(String userId, String sessionId)
      Returns a WorkspaceManager view whose filesystem and namespace are bound to the given (userId, sessionId) for the duration of the returned view's IO. Unlike getWorkspaceManager(), this does not mutate any shared state on this agent — so it is safe to call concurrently from per-request controllers without racing with active chats.
    • getCompactionHook

      public CompactionMiddleware getCompactionHook()
      Returns the CompactionMiddleware instance if compaction was configured, or null.
    • getSkillRepositories

      public List<io.agentscope.core.skill.repository.AgentSkillRepository> getSkillRepositories()
      Returns the ordered list of AgentSkillRepository instances bound to this agent (low to high priority).
    • getSkillUsageStore

      public SkillUsageStore getSkillUsageStore()
      Access to the sidecar telemetry store. Null when enableSkillManageTool was not configured.
    • queryAudit

      public List<SkillAuditLog.Entry> queryAudit(String dayUtc, Predicate<SkillAuditLog.Entry> filter)
      Query the audit log for a given UTC day. Pass null for "today". Returns an empty list when the audit log is not configured (no enableSkillManageTool call).
    • runCuratorOnce

      public reactor.core.publisher.Mono<SkillCurator.CuratorRunReport> runCuratorOnce()
      Force-run the skill curator immediately, bypassing the idle-and-interval gate. Returns a Mono that emits null when the curator is not configured.
    • promoteSkill

      public reactor.core.publisher.Mono<SkillPromoter.PromotionResult> promoteSkill(String name, String reviewerId, io.agentscope.core.agent.RuntimeContext ctx)
      Promote a draft skill for the explicitly supplied request context.

      Callers promoting skills outside an active call(...) must use this overload when the workspace is user- or session-scoped so the draft is resolved and moved within the correct namespace.

    • enterPlanMode

      public void enterPlanMode(io.agentscope.core.agent.RuntimeContext ctx)
      Enters plan mode for the session identified by the given RuntimeContext. The change is persisted so the next call on that session sees it.
    • exitPlanMode

      public void exitPlanMode(io.agentscope.core.agent.RuntimeContext ctx)
      Exits plan mode for the session identified by the given RuntimeContext.
    • isPlanModeActive

      public boolean isPlanModeActive(io.agentscope.core.agent.RuntimeContext ctx)
      Returns:
      whether plan mode is active for the session identified by the given RuntimeContext.
    • clearContext

      public void clearContext(io.agentscope.core.agent.RuntimeContext ctx)
      Clears the model-visible conversation context for the session identified by ctx.

      The session identity and non-conversation state are preserved. The next call starts with an empty conversation context. This method does not cancel an in-flight call.

      Parameters:
      ctx - runtime context identifying the session
    • clearContext

      public void clearContext(String userId, String sessionId)
      Clears the model-visible conversation context for one (userId, sessionId) session.

      The session identity and non-conversation state are preserved. The next call starts with an empty conversation context. This method does not cancel an in-flight call.

      Parameters:
      userId - user identity for the slot (null = anonymous / single-tenant)
      sessionId - session identity; null or blank uses the default session id
    • clearStateCache

      public void clearStateCache()
      Clears all locally cached per-session state and permission engines held by the wrapped ReActAgent. Persisted state in the configured AgentStateStore is preserved.
    • clearStateCache

      public void clearStateCache(io.agentscope.core.agent.RuntimeContext ctx)
      Clears the locally cached state and permission engine for the session identified by ctx. Persisted state in the configured AgentStateStore is preserved.
      Parameters:
      ctx - runtime context identifying the session
    • clearStateCache

      public void clearStateCache(String userId, String sessionId)
      Clears the locally cached state and permission engine for one (userId, sessionId) slot. Persisted state in the configured AgentStateStore is preserved.
      Parameters:
      userId - user identity for the slot (null = anonymous / single-tenant)
      sessionId - session identity; null or blank uses the default session id
    • enterPlanMode

      public void enterPlanMode(String userId, String sessionId)
      Enters plan mode for the given (userId, sessionId) session, independent of which slot is currently active. The change is persisted so the next call on that session sees it.
    • exitPlanMode

      public void exitPlanMode(String userId, String sessionId)
      Exits plan mode for the given (userId, sessionId) session and persists the change.
    • isPlanModeActive

      public boolean isPlanModeActive(String userId, String sessionId)
      Returns:
      whether plan mode is active for the given (userId, sessionId) session.
    • setPermissionMode

      public void setPermissionMode(io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.permission.PermissionMode mode)
      Switches the PermissionMode for the session identified by the given RuntimeContext at runtime. See ReActAgent.setPermissionMode(String, String, io.agentscope.core.permission.PermissionMode).
    • setPermissionMode

      public void setPermissionMode(String userId, String sessionId, io.agentscope.core.permission.PermissionMode mode)
      Switches the PermissionMode for the given (userId, sessionId) session at runtime, preserving configured rules and rebuilding the cached permission engine.
    • getPermissionMode

      public io.agentscope.core.permission.PermissionMode getPermissionMode(String userId, String sessionId)
      Returns:
      the current permission mode for the given (userId, sessionId) session.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getDelegate

      public io.agentscope.core.ReActAgent getDelegate()
      Returns the wrapped ReActAgent.
    • getModel

      public io.agentscope.core.model.Model getModel()
    • getMaxIters

      public int getMaxIters()
    • getStateStore

      public io.agentscope.core.state.AgentStateStore getStateStore()
    • getDistributedStore

      public DistributedStore getDistributedStore()
      The distributed store configured on this agent, or null for local deployments. Exposed so GatewayBootstrap can build a durable SubagentRegistry for exposed-subagent recovery.
    • getSubagentAgentManager

      public DefaultAgentManager getSubagentAgentManager()
      The internal DefaultAgentManager able to re-materialize this agent's subagents, or null when none is owned (e.g. session-mode external subagent tool). Used to wire a gateway materializer for cross-node recovery.
    • getTaskRepository

      public TaskRepository getTaskRepository()
      Background subagent TaskRepository owned by the subagent middleware, or null when subagents are not configured.
    • getDefaultSessionId

      public String getDefaultSessionId()
      See Also:
      • ReActAgent.getDefaultSessionId()
    • getAgentState

      @Deprecated public io.agentscope.core.state.AgentState getAgentState()
      Deprecated.
      Use getDelegate().getAgentState(RuntimeContext) or .getAgentState(String, String) with explicit session identity.
      Specified by:
      getAgentState in interface io.agentscope.core.agent.Agent
    • getName

      public String getName()
      Specified by:
      getName in interface io.agentscope.core.agent.Agent
    • getAgentId

      public String getAgentId()
      Specified by:
      getAgentId in interface io.agentscope.core.agent.Agent
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface io.agentscope.core.agent.Agent
    • interrupt

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

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

      public void interrupt(io.agentscope.core.agent.RuntimeContext ctx)
      Interrupts the in-flight call for the session identified by ctx.
      Parameters:
      ctx - runtime context identifying the session to interrupt
    • interrupt

      public void interrupt(io.agentscope.core.agent.RuntimeContext ctx, io.agentscope.core.message.Msg msg)
      Interrupts the in-flight call for the session identified by ctx with an associated user message.
      Parameters:
      ctx - runtime context identifying the session to interrupt
      msg - optional user message to attach to the interrupt signal
    • interrupt

      public void interrupt(String userId, String sessionId)
      Interrupts the in-flight call for a specific (userId, sessionId) session.
      Parameters:
      userId - user identity for the slot (null = anonymous / single-tenant)
      sessionId - session identity; null or blank uses the default session id
    • interrupt

      public void interrupt(String userId, String sessionId, io.agentscope.core.message.Msg msg)
      Interrupts the in-flight call for a specific (userId, sessionId) session with an associated user message.
    • channel

      public <T extends Channel> T channel(T channel)
      Returns a channel bound to this agent's internal gateway. The gateway is created lazily on the first call and this agent is registered as the sole (main) agent.

      Typical usage in a Spring controller:

      
       HarnessAgent agent = HarnessAgent.builder()...build();
       ChatUiChannel chat = agent.channel(ChatUiChannel.perPeer());
      
       // in controller
       chat.send("user-123", "hello");
       
      Type Parameters:
      T - the channel type
      Parameters:
      channel - the channel instance to bind (e.g. ChatUiChannel.perPeer())
      Returns:
      the same channel instance, now wired to this agent's gateway
    • gateway

      public HarnessGateway gateway()
      Returns the internal gateway backing channel(T). Creates it lazily if not yet initialized. Exposed for advanced usage (e.g. direct runSubagent calls).
    • call

      @Deprecated(since="2.2.0") public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> call(List<io.agentscope.core.message.Msg> msgs)
      Deprecated.
      Use call(List, RuntimeContext) with explicit runtime context.
      Specified by:
      call in interface io.agentscope.core.agent.CallableAgent
    • call

      @Deprecated(since="2.2.0") public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> call(List<io.agentscope.core.message.Msg> msgs, Class<?> structuredModel)
      Deprecated.
      Use call(List, Class, RuntimeContext) with explicit runtime context.
      Specified by:
      call in interface io.agentscope.core.agent.CallableAgent
    • call

      @Deprecated(since="2.2.0") public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> call(List<io.agentscope.core.message.Msg> msgs, com.fasterxml.jackson.databind.JsonNode schema)
      Deprecated.
      Use call(List, JsonNode, RuntimeContext) with explicit runtime context.
      Specified by:
      call in interface io.agentscope.core.agent.CallableAgent
    • call

      public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> call(io.agentscope.core.message.Msg msg, io.agentscope.core.agent.RuntimeContext ctx)
    • call

      public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> call(String text, io.agentscope.core.agent.RuntimeContext ctx)
      Calls the agent with a plain text input and per-call RuntimeContext.
      Parameters:
      text - input text (wrapped into a UserMessage)
      ctx - per-call runtime context
      Returns:
      response message
    • call

      public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> call(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
    • call

      public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> call(List<io.agentscope.core.message.Msg> msgs, Class<?> structuredModel, io.agentscope.core.agent.RuntimeContext ctx)
    • call

      public reactor.core.publisher.Mono<io.agentscope.core.message.Msg> call(List<io.agentscope.core.message.Msg> msgs, com.fasterxml.jackson.databind.JsonNode schema, io.agentscope.core.agent.RuntimeContext ctx)
    • stream

      @Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<io.agentscope.core.agent.Event> stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.0.0, for removal. Use streamEvents(List) for the fine-grained AgentEvent stream that aligns with Python 2.0's agent.reply_stream().
      Specified by:
      stream in interface io.agentscope.core.agent.StreamableAgent
    • stream

      @Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<io.agentscope.core.agent.Event> stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, Class<?> structuredModel)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.0.0, for removal. Use streamEvents(List) for the fine-grained AgentEvent stream.
      Specified by:
      stream in interface io.agentscope.core.agent.StreamableAgent
    • stream

      @Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<io.agentscope.core.agent.Event> stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, com.fasterxml.jackson.databind.JsonNode schema)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.0.0, for removal. Use streamEvents(List) for the fine-grained AgentEvent stream.
      Specified by:
      stream in interface io.agentscope.core.agent.StreamableAgent
    • stream

      @Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<io.agentscope.core.agent.Event> stream(io.agentscope.core.message.Msg msg, io.agentscope.core.agent.RuntimeContext ctx)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.0.0, for removal. Use streamEvents(Msg, RuntimeContext).
    • stream

      @Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<io.agentscope.core.agent.Event> stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.0.0, for removal. Use streamEvents(List, RuntimeContext).
    • stream

      @Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<io.agentscope.core.agent.Event> stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, io.agentscope.core.agent.RuntimeContext ctx)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.0.0, for removal. Use streamEvents(List, RuntimeContext).
      Specified by:
      stream in interface io.agentscope.core.agent.StreamableAgent
    • stream

      @Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<io.agentscope.core.agent.Event> stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, Class<?> structuredModel, io.agentscope.core.agent.RuntimeContext ctx)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.0.0, for removal. Use streamEvents(List, RuntimeContext).
    • stream

      @Deprecated(since="2.0.0", forRemoval=true) public reactor.core.publisher.Flux<io.agentscope.core.agent.Event> stream(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.StreamOptions options, com.fasterxml.jackson.databind.JsonNode schema, io.agentscope.core.agent.RuntimeContext ctx)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.0.0, for removal. Use streamEvents(List, RuntimeContext).
    • prepareRun

      public io.agentscope.core.agent.AgentRun<io.agentscope.core.event.AgentEvent> prepareRun(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
      Prepare a cancellable execution covering the complete harness/sandbox lifecycle.
    • prepareCall

      public io.agentscope.core.agent.AgentRun<io.agentscope.core.message.Msg> prepareCall(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
      Prepare a cancellable reply execution covering the complete harness/sandbox lifecycle.
    • streamEvents

      @Deprecated(since="2.2.0") public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> streamEvents(io.agentscope.core.message.Msg msg)
      Deprecated.
      Use streamEvents(Msg, RuntimeContext) with explicit runtime context.
    • streamEvents

      @Deprecated(since="2.2.0") public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> streamEvents(List<io.agentscope.core.message.Msg> msgs)
      Deprecated.
      Use streamEvents(List, RuntimeContext) with explicit runtime context.
    • streamEvents

      public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> streamEvents(io.agentscope.core.message.Msg msg, io.agentscope.core.agent.RuntimeContext ctx)
      Stream fine-grained AgentEvents for a single message with a caller-supplied RuntimeContext.
      Parameters:
      msg - input message
      ctx - runtime context to propagate into the call
      Returns:
      event stream covering the full agent invocation lifecycle
    • streamEvents

      @Deprecated(since="2.2.0") public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> streamEvents(String text)
      Deprecated.
      Use streamEvents(String, RuntimeContext) with explicit runtime context.
    • streamEvents

      public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> streamEvents(String text, io.agentscope.core.agent.RuntimeContext ctx)
      Stream fine-grained AgentEvents for a plain text input with a caller-supplied RuntimeContext.
      Parameters:
      text - input text (wrapped into a UserMessage)
      ctx - runtime context to propagate into the call
      Returns:
      event stream covering the full agent invocation lifecycle
    • streamEvents

      public reactor.core.publisher.Flux<io.agentscope.core.event.AgentEvent> streamEvents(List<io.agentscope.core.message.Msg> msgs, io.agentscope.core.agent.RuntimeContext ctx)
      Stream fine-grained AgentEvents for a list of messages with a caller-supplied RuntimeContext. The harness wraps the delegate's ReActAgent#streamEvents(List, RuntimeContext) with the same sandbox-lifecycle acquire/release semantics that the call(...) family uses, so streaming and blocking callers behave consistently with respect to sandbox warm-up.

      Synchronous subagent events spawned via agent_spawn / agent_send are forwarded into this stream in real time with a source tag identifying the originating child agent.

      Parameters:
      msgs - input messages
      ctx - runtime context to propagate into the call
      Returns:
      event stream covering the full agent invocation lifecycle
    • observe

      public reactor.core.publisher.Mono<Void> observe(io.agentscope.core.message.Msg msg)
      Specified by:
      observe in interface io.agentscope.core.agent.ObservableAgent
    • observe

      public reactor.core.publisher.Mono<Void> observe(List<io.agentscope.core.message.Msg> msgs)
      Specified by:
      observe in interface io.agentscope.core.agent.ObservableAgent
    • getToolkit

      public io.agentscope.core.tool.Toolkit getToolkit()
      Specified by:
      getToolkit in interface io.agentscope.core.agent.Agent
    • builder

      public static HarnessAgent.Builder builder()