MsgContext
public record MsgContext( String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra, String userId)
io/agentscope/harness/agent/gateway/MsgContext.java:39–104承载消息上下文数据的记录类型。位于 io.agentscope.harness.agent.gateway 包。核心成员包括 channel、group、room、threadId、threadTs、extra。
Routing context for inbound turns (direct API, channel adapter, group/room/thread). Used by the gateway to map stable conversation keys to session ids.
The #userId field carries the message sender's identity for multi-tenant namespace
isolation in io.agentscope.harness.agent.HarnessAgent. It is derived from
io.agentscope.harness.agent.gateway.channel.InboundMessage#senderId() and does
not participate in #canonicalKey() computation — the same user's conversations
always map to the same session key regardless of how userId is set.
记录组件摘要Record Component Summary
| 组件Component | 类型Type | 说明Description |
|---|---|---|
channel | String | 执行渠道相关操作。 logical channel name (e.g. slack, discord, web) |
group | String | 执行组相关操作。 optional group / team / workspace id |
room | String | 执行 `room` 方法。 optional room / channel id |
threadId | String | 执行会话线程标识相关操作。 optional thread / topic id |
threadTs | String | 执行会话线程 Ts相关操作。 optional provider-specific thread timestamp or message anchor |
extra | Map<String, String> | 执行 `extra` 方法。 additional key/value pairs for adapters |
userId | String | 执行用户标识相关操作。 optional authenticated user identity for HarnessAgent namespace isolation |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public MsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra, String userId) | 初始化 `MsgContext` 实例。 Creates a new instance. |
public MsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra) | 初始化 `MsgContext` 实例。 Convenience constructor without `userId` (backwards-compatible for callsites that do
not carry user identity). |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static MsgContext defaultContext()static | 返回默认上下文。 Default single-conversation context (no channel metadata, no userId). |
public MsgContext withUserId(String userId) | 执行使用用户标识相关操作。 Returns a copy of this context with the given `userId` set. |
public String canonicalKey() | 返回规范键。 Stable key for session routing: same logical conversation maps to the same gateway session id. |
记录组件详情Record Component Detail
channel
String channel执行渠道相关操作。
logical channel name (e.g. slack, discord, web)
io/agentscope/harness/agent/gateway/MsgContext.java:39–104group
String group执行组相关操作。
optional group / team / workspace id
io/agentscope/harness/agent/gateway/MsgContext.java:39–104room
String room执行 room 方法。
optional room / channel id
io/agentscope/harness/agent/gateway/MsgContext.java:39–104threadId
String threadId执行会话线程标识相关操作。
optional thread / topic id
io/agentscope/harness/agent/gateway/MsgContext.java:39–104threadTs
String threadTs执行会话线程 Ts相关操作。
optional provider-specific thread timestamp or message anchor
io/agentscope/harness/agent/gateway/MsgContext.java:39–104extra
Map<String, String> extra执行 extra 方法。
additional key/value pairs for adapters
io/agentscope/harness/agent/gateway/MsgContext.java:39–104userId
String userId执行用户标识相关操作。
optional authenticated user identity for HarnessAgent namespace isolation
io/agentscope/harness/agent/gateway/MsgContext.java:39–104构造器详情Constructor Detail
MsgContext
public MsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra, String userId)
初始化 MsgContext 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
channel | String | 渠道(类型 `String`)。The channel. |
group | String | 组(类型 `String`)。The group. |
room | String | room(类型 `String`)。The room. |
threadId | String | 会话线程标识(类型 `String`)。The thread id. |
threadTs | String | 会话线程 Ts(类型 `String`)。The thread ts. |
extra | Map<String, String> | extra(类型 `Map`)。The extra. |
userId | String | 用户标识(类型 `String`)。The user id. |
io/agentscope/harness/agent/gateway/MsgContext.java:48–50MsgContext
public MsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra)
初始化 MsgContext 实例。
Convenience constructor without userId (backwards-compatible for callsites that do not carry user identity).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
channel | String | 渠道(类型 `String`)。The channel. |
group | String | 组(类型 `String`)。The group. |
room | String | room(类型 `String`)。The room. |
threadId | String | 会话线程标识(类型 `String`)。The thread id. |
threadTs | String | 会话线程 Ts(类型 `String`)。The thread ts. |
extra | Map<String, String> | extra(类型 `Map`)。The extra. |
io/agentscope/harness/agent/gateway/MsgContext.java:56–64方法详情Method Detail
defaultContext
public static MsgContext defaultContext()
返回默认上下文。
Default single-conversation context (no channel metadata, no userId).
MsgContextio/agentscope/harness/agent/gateway/MsgContext.java:67–69withUserId
public MsgContext withUserId(String userId)
执行使用用户标识相关操作。
Returns a copy of this context with the given userId set.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
MsgContextio/agentscope/harness/agent/gateway/MsgContext.java:72–74canonicalKey
public String canonicalKey()
返回规范键。
Stable key for session routing: same logical conversation maps to the same gateway session id.
Stringio/agentscope/harness/agent/gateway/MsgContext.java:77–103