SendOptions
public record SendOptions( String userId, String sessionId, String agentId, RuntimeContext runtimeContext)
io/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:69–122承载发送选项数据的记录类型。位于 io.agentscope.harness.agent.gateway.channel.chatui 包。核心成员包括 userId、sessionId、agentId、runtimeContext、of、withAgentId。
Routing identity for ChatUiChannel requests. Replaces the need to understand
io.agentscope.harness.agent.gateway.channel.DmScope by letting the caller express
routing intent through simple business identifiers.
-
userId— identifies the user. Maps toio.agentscope.harness.agent.gateway.MsgContext#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");
`
记录组件摘要Record Component Summary
| 组件Component | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户身份(必填)。 the user identity (required) |
sessionId | String | 执行会话标识相关操作。 optional conversation identifier; null means one session per user |
agentId | String | 执行智能体标识相关操作。 optional target agent override; null for default routing |
runtimeContext | RuntimeContext | 执行运行时上下文相关操作。 optional caller-supplied runtime context; null when none |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public SendOptions(String userId, String sessionId, String agentId, RuntimeContext runtimeContext) | 初始化 `SendOptions` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static SendOptions userId(String userId)static | 设置用户标识。 One session per user — the most common case. |
public static SendOptions of(String userId, String sessionId)static | 创建并返回实例。 Explicit user + session — multiple conversations for the same user. |
public SendOptions withAgentId(String agentId) | 执行使用智能体标识相关操作。 Returns a copy with the given agent id override. |
public SendOptions withRuntimeContext(RuntimeContext runtimeContext) | 执行使用运行时上下文相关操作。 Returns a copy that carries the given `RuntimeContext` into the agent turn. |
public SendOptions withAttribute(String key, Object value) | 执行使用属性相关操作。 Returns a copy with a string attribute merged into the carried `RuntimeContext`. |
public T SendOptions withAttribute(Class<T> type, T value) | 执行使用属性相关操作。 Returns a copy with a typed attribute merged into the carried `RuntimeContext`. |
记录组件详情Record Component Detail
userId
String userId用户身份(必填)。
the user identity (required)
io/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:69–122sessionId
String sessionId执行会话标识相关操作。
optional conversation identifier; null means one session per user
io/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:69–122agentId
String agentId执行智能体标识相关操作。
optional target agent override; null for default routing
io/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:69–122runtimeContext
RuntimeContext runtimeContext执行运行时上下文相关操作。
optional caller-supplied runtime context; null when none
io/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:69–122构造器详情Constructor Detail
SendOptions
public SendOptions(String userId, String sessionId, String agentId, RuntimeContext runtimeContext)
初始化 SendOptions 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
agentId | String | 智能体标识(类型 `String`)。The agent id. |
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
io/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:72–74方法详情Method Detail
userId
public static SendOptions userId(String userId)
设置用户标识。
One session per user — the most common case.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
SendOptionsio/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:77–79of
public static SendOptions of(String userId, String sessionId)
创建并返回实例。
Explicit user + session — multiple conversations for the same user.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
SendOptionsio/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:82–85withAgentId
public SendOptions withAgentId(String agentId)
执行使用智能体标识相关操作。
Returns a copy with the given agent id override.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentId | String | 智能体标识(类型 `String`)。The agent id. |
SendOptionsio/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:88–90withRuntimeContext
public SendOptions withRuntimeContext(RuntimeContext runtimeContext)
执行使用运行时上下文相关操作。
Returns a copy that carries the given RuntimeContext into the agent turn.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
SendOptionsio/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:96–98withAttribute
public SendOptions withAttribute(String key, Object value)
执行使用属性相关操作。
Returns a copy with a string attribute merged into the carried RuntimeContext.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
value | Object | 值(类型 `Object`)。The value. |
SendOptionsio/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:104–107withAttribute
public T SendOptions withAttribute(Class<T> type, T value)
执行使用属性相关操作。
Returns a copy with a typed attribute merged into the carried RuntimeContext.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
type | Class<T> | 类型(类型 `Class`)。The type. |
value | T | 值(类型 `T`)。The value. |
SendOptionsio/agentscope/harness/agent/gateway/channel/chatui/SendOptions.java:113–116