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 useragentId- optional target agent override; null for default routingruntimeContext- 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 toMsgContext.userId()for HarnessAgent namespace isolation, and is used as the default session key whensessionIdis 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-callRuntimeContextmerged 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 Summary
ConstructorsConstructorDescriptionSendOptions(String userId, String sessionId, String agentId, io.agentscope.core.agent.RuntimeContext runtimeContext) Creates an instance of aSendOptionsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionagentId()Returns the value of theagentIdrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static SendOptionsExplicit user + session — multiple conversations for the same user.io.agentscope.core.agent.RuntimeContextReturns the value of theruntimeContextrecord component.Returns the value of thesessionIdrecord component.final StringtoString()Returns a string representation of this record class.userId()Returns the value of theuserIdrecord component.static SendOptionsOne session per user — the most common case.withAgentId(String agentId) Returns a copy with the given agent id override.<T> SendOptionswithAttribute(Class<T> type, T value) Returns a copy with a typed attribute merged into the carriedRuntimeContext.withAttribute(String key, Object value) Returns a copy with a string attribute merged into the carriedRuntimeContext.withRuntimeContext(io.agentscope.core.agent.RuntimeContext runtimeContext) Returns a copy that carries the givenRuntimeContextinto the agent turn.
-
Constructor Details
-
SendOptions
public SendOptions(String userId, String sessionId, String agentId, io.agentscope.core.agent.RuntimeContext runtimeContext) Creates an instance of aSendOptionsrecord class.- Parameters:
userId- the value for theuserIdrecord componentsessionId- the value for thesessionIdrecord componentagentId- the value for theagentIdrecord componentruntimeContext- the value for theruntimeContextrecord component
-
-
Method Details
-
userId
One session per user — the most common case. -
of
Explicit user + session — multiple conversations for the same user. -
withAgentId
Returns a copy with the given agent id override. -
withRuntimeContext
Returns a copy that carries the givenRuntimeContextinto the agent turn. Replaces any previously attached context. -
withAttribute
Returns a copy with a string attribute merged into the carriedRuntimeContext. Creates a new context from empty when none is present yet. -
withAttribute
Returns a copy with a typed attribute merged into the carriedRuntimeContext. Creates a new context from empty when none is present yet. -
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
userId
Returns the value of theuserIdrecord component.- Returns:
- the value of the
userIdrecord component
-
sessionId
Returns the value of thesessionIdrecord component.- Returns:
- the value of the
sessionIdrecord component
-
agentId
Returns the value of theagentIdrecord component.- Returns:
- the value of the
agentIdrecord component
-
runtimeContext
public io.agentscope.core.agent.RuntimeContext runtimeContext()Returns the value of theruntimeContextrecord component.- Returns:
- the value of the
runtimeContextrecord component
-