Record Class InboundMessage
java.lang.Object
java.lang.Record
io.agentscope.harness.agent.gateway.channel.InboundMessage
- Record Components:
channelId- identifier of the originating channel (e.g."chatui","slack")accountId- optional multi-account identifier (e.g. Slack app installation id); null for single-account channelspeer- the conversation peer (DM partner, channel, group, or thread) — used for session keysenderId- optional sender identity for user-level isolation; if null,peer's id is used as fallback in DM contextsparentPeer- optional parent peer for thread-nested messages; used forbinding.peer.parentinheritanceguild- optional guild / server / workspace id (Discord guild, Slack workspace)team- optional team id (Slack team, MS Teams team)roles- optional set of role ids the sender holds within the guild; used forbinding.guild+rolestier evaluationmessages- the actual message content to forward to the agentpreferredAgentId- optional explicit agent override evaluated byChannelRouteras a tier-0 short-circuit before any binding tier. Set this when the caller already knows which agent should handle the request (e.g. a path-mapped Web UI where the user clicked an agent card); the router still builds session and outbound context normally so bindings continue to controlsessionScopeand outbound addressing.nullfor normal binding-driven routing.runtimeContext- optional caller-suppliedRuntimeContextmerged into the agent turn;nullwhen none. Not part of routing / session identity.
public record InboundMessage(String channelId, String accountId, Peer peer, String senderId, Peer parentPeer, String guild, String team, Set<String> roles, List<io.agentscope.core.message.Msg> messages, String preferredAgentId, io.agentscope.core.agent.RuntimeContext runtimeContext)
extends Record
Normalized inbound message produced by a
Channel adapter before routing. Carries all
identity and context metadata needed by ChannelRouter to resolve an agent and build a
stable session key.
Two identity fields are deliberately separate:
peer— the conversation identifier used to construct the session key (DM user id, group chat id, channel id)senderId— the message sender's identity, used asuserIdfor HarnessAgent namespace isolation. In DM scenarios these are equal; in group/channel scenariospeer.idis the group andsenderIdis the individual author.
runtimeContext() is not used for routing and does not participate in session
key computation. It is forwarded to the Gateway as the caller merge base for the agent turn.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionInboundMessage(String channelId, String accountId, Peer peer, String senderId, Peer parentPeer, String guild, String team, Set<String> roles, List<io.agentscope.core.message.Msg> messages, String preferredAgentId, io.agentscope.core.agent.RuntimeContext runtimeContext) Creates an instance of aInboundMessagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theaccountIdrecord component.static InboundMessage.BuilderReturns a builder for constructing messages with all optional fields.static InboundMessagechannel(String channelId, String roomId, String senderId, String guild, List<io.agentscope.core.message.Msg> messages) Channel / group message with optional guild context.static InboundMessagechannel(String channelId, String roomId, String guild, List<io.agentscope.core.message.Msg> messages) Channel message with optional guild context (no explicit senderId — sender identity unknown, falls back to room peer for isolation).Returns the value of thechannelIdrecord component.static InboundMessageSingle-turn DM with no guild/team/role metadata (typical for direct chat UI use).static InboundMessagedmFor(String channelId, String peerId, String agentId, List<io.agentscope.core.message.Msg> messages) Single-turn DM with an explicitpreferredAgentId()override — the router will use the suppliedagentIdas a tier-0 short-circuit instead of evaluating bindings.final booleanIndicates whether some other object is "equal to" this one.guild()Returns the value of theguildrecord component.final inthashCode()Returns a hash code value for this object.booleanisDm()Whether this message originates from a direct / DM peer.booleanisThread()Whether this message is a thread-nested reply.List<io.agentscope.core.message.Msg>messages()Returns the value of themessagesrecord component.Returns the value of theparentPeerrecord component.peer()Returns the value of thepeerrecord component.Returns the value of thepreferredAgentIdrecord component.roles()Returns the value of therolesrecord component.io.agentscope.core.agent.RuntimeContextReturns the value of theruntimeContextrecord component.senderId()Returns the value of thesenderIdrecord component.team()Returns the value of theteamrecord component.final StringtoString()Returns a string representation of this record class.withRuntimeContext(io.agentscope.core.agent.RuntimeContext runtimeContext) Returns a copy carrying the givenRuntimeContext.
-
Constructor Details
-
InboundMessage
public InboundMessage(String channelId, String accountId, Peer peer, String senderId, Peer parentPeer, String guild, String team, Set<String> roles, List<io.agentscope.core.message.Msg> messages, String preferredAgentId, io.agentscope.core.agent.RuntimeContext runtimeContext) Creates an instance of aInboundMessagerecord class.- Parameters:
channelId- the value for thechannelIdrecord componentaccountId- the value for theaccountIdrecord componentpeer- the value for thepeerrecord componentsenderId- the value for thesenderIdrecord componentparentPeer- the value for theparentPeerrecord componentguild- the value for theguildrecord componentteam- the value for theteamrecord componentroles- the value for therolesrecord componentmessages- the value for themessagesrecord componentpreferredAgentId- the value for thepreferredAgentIdrecord componentruntimeContext- the value for theruntimeContextrecord component
-
-
Method Details
-
dm
public static InboundMessage dm(String channelId, String peerId, List<io.agentscope.core.message.Msg> messages) Single-turn DM with no guild/team/role metadata (typical for direct chat UI use).In DM context
senderIdequalspeerId— the conversation partner is also the message author. -
dmFor
public static InboundMessage dmFor(String channelId, String peerId, String agentId, List<io.agentscope.core.message.Msg> messages) Single-turn DM with an explicitpreferredAgentId()override — the router will use the suppliedagentIdas a tier-0 short-circuit instead of evaluating bindings. -
channel
public static InboundMessage channel(String channelId, String roomId, String senderId, String guild, List<io.agentscope.core.message.Msg> messages) Channel / group message with optional guild context. ThesenderIdidentifies the individual author separately from theroomIdconversation peer. -
channel
public static InboundMessage channel(String channelId, String roomId, String guild, List<io.agentscope.core.message.Msg> messages) Channel message with optional guild context (no explicit senderId — sender identity unknown, falls back to room peer for isolation). -
isDm
public boolean isDm()Whether this message originates from a direct / DM peer. -
isThread
public boolean isThread()Whether this message is a thread-nested reply. -
withRuntimeContext
Returns a copy carrying the givenRuntimeContext. -
builder
public static InboundMessage.Builder builder(String channelId, Peer peer, List<io.agentscope.core.message.Msg> messages) Returns a builder for constructing messages with all optional fields. -
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). -
channelId
Returns the value of thechannelIdrecord component.- Returns:
- the value of the
channelIdrecord component
-
accountId
Returns the value of theaccountIdrecord component.- Returns:
- the value of the
accountIdrecord component
-
peer
Returns the value of thepeerrecord component.- Returns:
- the value of the
peerrecord component
-
senderId
Returns the value of thesenderIdrecord component.- Returns:
- the value of the
senderIdrecord component
-
parentPeer
Returns the value of theparentPeerrecord component.- Returns:
- the value of the
parentPeerrecord component
-
guild
Returns the value of theguildrecord component.- Returns:
- the value of the
guildrecord component
-
team
Returns the value of theteamrecord component.- Returns:
- the value of the
teamrecord component
-
roles
Returns the value of therolesrecord component.- Returns:
- the value of the
rolesrecord component
-
messages
Returns the value of themessagesrecord component.- Returns:
- the value of the
messagesrecord component
-
preferredAgentId
Returns the value of thepreferredAgentIdrecord component.- Returns:
- the value of the
preferredAgentIdrecord component
-
runtimeContext
public io.agentscope.core.agent.RuntimeContext runtimeContext()Returns the value of theruntimeContextrecord component.- Returns:
- the value of the
runtimeContextrecord component
-