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 channels
peer - the conversation peer (DM partner, channel, group, or thread) — used for session key
senderId - optional sender identity for user-level isolation; if null, peer's id is used as fallback in DM contexts
parentPeer - optional parent peer for thread-nested messages; used for binding.peer.parent inheritance
guild - 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 for binding.guild+roles tier evaluation
messages - the actual message content to forward to the agent
preferredAgentId - optional explicit agent override evaluated by ChannelRouter as 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 control sessionScope and outbound addressing. null for normal binding-driven routing.
runtimeContext - optional caller-supplied RuntimeContext merged into the agent turn; null when 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 as userId for HarnessAgent namespace isolation. In DM scenarios these are equal; in group/channel scenarios peer.id is the group and senderId is 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.

  • 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 a InboundMessage record class.
      Parameters:
      channelId - the value for the channelId record component
      accountId - the value for the accountId record component
      peer - the value for the peer record component
      senderId - the value for the senderId record component
      parentPeer - the value for the parentPeer record component
      guild - the value for the guild record component
      team - the value for the team record component
      roles - the value for the roles record component
      messages - the value for the messages record component
      preferredAgentId - the value for the preferredAgentId record component
      runtimeContext - the value for the runtimeContext record 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 senderId equals peerId — 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 explicit preferredAgentId() override — the router will use the supplied agentId as 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. The senderId identifies the individual author separately from the roomId conversation 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

      public InboundMessage withRuntimeContext(io.agentscope.core.agent.RuntimeContext runtimeContext)
      Returns a copy carrying the given RuntimeContext.
    • 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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • channelId

      public String channelId()
      Returns the value of the channelId record component.
      Returns:
      the value of the channelId record component
    • accountId

      public String accountId()
      Returns the value of the accountId record component.
      Returns:
      the value of the accountId record component
    • peer

      public Peer peer()
      Returns the value of the peer record component.
      Returns:
      the value of the peer record component
    • senderId

      public String senderId()
      Returns the value of the senderId record component.
      Returns:
      the value of the senderId record component
    • parentPeer

      public Peer parentPeer()
      Returns the value of the parentPeer record component.
      Returns:
      the value of the parentPeer record component
    • guild

      public String guild()
      Returns the value of the guild record component.
      Returns:
      the value of the guild record component
    • team

      public String team()
      Returns the value of the team record component.
      Returns:
      the value of the team record component
    • roles

      public Set<String> roles()
      Returns the value of the roles record component.
      Returns:
      the value of the roles record component
    • messages

      public List<io.agentscope.core.message.Msg> messages()
      Returns the value of the messages record component.
      Returns:
      the value of the messages record component
    • preferredAgentId

      public String preferredAgentId()
      Returns the value of the preferredAgentId record component.
      Returns:
      the value of the preferredAgentId record component
    • runtimeContext

      public io.agentscope.core.agent.RuntimeContext runtimeContext()
      Returns the value of the runtimeContext record component.
      Returns:
      the value of the runtimeContext record component