Record Class SendOptions

java.lang.Object
java.lang.Record
io.agentscope.harness.agent.gateway.channel.chatui.SendOptions
Record Components:
userId - the user identity (required)
sessionId - optional conversation identifier; null means one session per user
agentId - optional target agent override; null for default routing
runtimeContext - optional caller-supplied runtime context; null when none

public record SendOptions(String userId, String sessionId, String agentId, io.agentscope.core.agent.RuntimeContext runtimeContext) extends Record
Routing identity for ChatUiChannel requests. Replaces the need to understand DmScope by letting the caller express routing intent through simple business identifiers.
  • userId — identifies the user. Maps to MsgContext.userId() for HarnessAgent namespace isolation, and is used as the default session key when sessionId is null.
  • sessionId — optional explicit conversation identifier. When provided, different sessions for the same user are kept separate. When null, one session per user is the default.
  • agentId — optional target agent override for multi-agent setups. When null, the channel's default agent is used.
  • runtimeContext — optional per-call RuntimeContext merged into the agent turn (attributes, typed values, force-sync flags, …). Gateway-owned identity fields still win on conflict.

Usage


 // One session per user (most common)
 chat.send(SendOptions.userId("user-1"), "hello");

 // Same user, different sessions
 chat.send(SendOptions.of("user-1", "session-a"), "hello");
 chat.send(SendOptions.of("user-1", "session-b"), "hello");

 // Target a specific agent in multi-agent setups
 chat.send(SendOptions.userId("user-1").withAgentId("support"), "help me");

 // Pass application context into the agent turn
 chat.send(
     SendOptions.userId("user-1")
         .withAttribute("tenant", "acme")
         .withRuntimeContext(
             RuntimeContext.builder()
                 .put(AgentSpawnTool.CTX_FORCE_SYNC, true)
                 .build()),
     "hello");
 
  • Constructor Details

    • SendOptions

      public SendOptions(String userId, String sessionId, String agentId, io.agentscope.core.agent.RuntimeContext runtimeContext)
      Creates an instance of a SendOptions record class.
      Parameters:
      userId - the value for the userId record component
      sessionId - the value for the sessionId record component
      agentId - the value for the agentId record component
      runtimeContext - the value for the runtimeContext record component
  • Method Details

    • userId

      public static SendOptions userId(String userId)
      One session per user — the most common case.
    • of

      public static SendOptions of(String userId, String sessionId)
      Explicit user + session — multiple conversations for the same user.
    • withAgentId

      public SendOptions withAgentId(String agentId)
      Returns a copy with the given agent id override.
    • withRuntimeContext

      public SendOptions withRuntimeContext(io.agentscope.core.agent.RuntimeContext runtimeContext)
      Returns a copy that carries the given RuntimeContext into the agent turn. Replaces any previously attached context.
    • withAttribute

      public SendOptions withAttribute(String key, Object value)
      Returns a copy with a string attribute merged into the carried RuntimeContext. Creates a new context from empty when none is present yet.
    • withAttribute

      public <T> SendOptions withAttribute(Class<T> type, T value)
      Returns a copy with a typed attribute merged into the carried RuntimeContext. Creates a new context from empty when none is present yet.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • userId

      public String userId()
      Returns the value of the userId record component.
      Returns:
      the value of the userId record component
    • sessionId

      public String sessionId()
      Returns the value of the sessionId record component.
      Returns:
      the value of the sessionId record component
    • agentId

      public String agentId()
      Returns the value of the agentId record component.
      Returns:
      the value of the agentId record component
    • runtimeContext

      public io.agentscope.core.agent.RuntimeContext runtimeContext()
      Returns the value of the runtimeContext record component.
      Returns:
      the value of the runtimeContext record component