Record Class MsgContext
java.lang.Object
java.lang.Record
io.agentscope.harness.agent.gateway.MsgContext
- Record Components:
channel- logical channel name (e.g. slack, discord, web)group- optional group / team / workspace idroom- optional room / channel idthreadId- optional thread / topic idthreadTs- optional provider-specific thread timestamp or message anchorextra- additional key/value pairs for adaptersuserId- optional authenticated user identity for HarnessAgent namespace isolation
public record MsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String,String> extra, String userId)
extends Record
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 HarnessAgent. It is derived from
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.
-
Constructor Summary
ConstructorsConstructorDescriptionMsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra) Convenience constructor withoutuserId(backwards-compatible for callsites that do not carry user identity).MsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra, String userId) Creates an instance of aMsgContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionStable key for session routing: same logical conversation maps to the same gateway session id.channel()Returns the value of thechannelrecord component.static MsgContextDefault single-conversation context (no channel metadata, no userId).final booleanIndicates whether some other object is "equal to" this one.extra()Returns the value of theextrarecord component.group()Returns the value of thegrouprecord component.final inthashCode()Returns a hash code value for this object.room()Returns the value of theroomrecord component.threadId()Returns the value of thethreadIdrecord component.threadTs()Returns the value of thethreadTsrecord component.final StringtoString()Returns a string representation of this record class.userId()Returns the value of theuserIdrecord component.withUserId(String userId) Returns a copy of this context with the givenuserIdset.
-
Constructor Details
-
MsgContext
public MsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra, String userId) Creates an instance of aMsgContextrecord class.- Parameters:
channel- the value for thechannelrecord componentgroup- the value for thegrouprecord componentroom- the value for theroomrecord componentthreadId- the value for thethreadIdrecord componentthreadTs- the value for thethreadTsrecord componentextra- the value for theextrarecord componentuserId- the value for theuserIdrecord component
-
MsgContext
public MsgContext(String channel, String group, String room, String threadId, String threadTs, Map<String, String> extra) Convenience constructor withoutuserId(backwards-compatible for callsites that do not carry user identity).
-
-
Method Details
-
defaultContext
Default single-conversation context (no channel metadata, no userId). -
withUserId
Returns a copy of this context with the givenuserIdset. -
canonicalKey
Stable key for session routing: same logical conversation maps to the same gateway session id. -
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). -
channel
Returns the value of thechannelrecord component.- Returns:
- the value of the
channelrecord component
-
group
Returns the value of thegrouprecord component.- Returns:
- the value of the
grouprecord component
-
room
Returns the value of theroomrecord component.- Returns:
- the value of the
roomrecord component
-
threadId
Returns the value of thethreadIdrecord component.- Returns:
- the value of the
threadIdrecord component
-
threadTs
Returns the value of thethreadTsrecord component.- Returns:
- the value of the
threadTsrecord component
-
extra
Returns the value of theextrarecord component.- Returns:
- the value of the
extrarecord component
-
userId
Returns the value of theuserIdrecord component.- Returns:
- the value of the
userIdrecord component
-