Skip to main content
Glama

Wait for next fmsg message

wait_for_message
Read-only

Blocks until a new inbound message arrives, then returns it with thread context for replying in chat loops.

Instructions

Block until the next inbound message arrives and return it with its thread context, so you can answer with reply. When: the user asks you to chat, keep replying or respond to the next message. Loop: wait → reply → wait again, passing each result's after_id. On "timeout" or "interrupted" (server restart) call again with the returned after_id; nothing is replayed or lost. Same-thread messages arriving within settle_seconds come as ONE result: reply once, to reply_target_id; next says what to do. Skipped: your own messages, reactions and no-reply messages (listed in skipped). Messages on other threads are not returned: after_id moves past them and pending_ids lists them; read them with get_thread before waiting again. Limits: each call blocks at most timeout_seconds (max 230). In chat hosts each wait is a model turn: tell the user you are listening and for how long, and stop when they interrupt or their limits are reached.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "wait_for_message"
  }
}

Input Schema

NameRequiredDescriptionDefault
fromNoonly accept messages from this address or short name
after_idNoonly messages with a greater id qualify; pass the after_id from the previous result. Omit on the first call to wait for messages arriving from now on
thread_ofNoonly accept messages in this message's thread
include_threadNoinclude the assembled thread context of the newest message
settle_secondsNoafter the first message, keep collecting same-thread messages for this long
timeout_secondsNolongest this call blocks

Output Schema

NameRequiredDescriptionDefault
nextNowhat to do with this result
noteYes
statusYesone of "message", "timeout", "interrupted"; interrupted: the server is restarting; call again with after_id. More values may be added
skippedYesmessages deliberately passed over; after_id has advanced past them
after_idYespass this as after_id on the next call
messagesYes
transportYesone of "websocket", "poll". More values may be added
pending_idsNoids of pending_other_threads, oldest first: read these before waiting again
thread_topicNothe thread root's topic (replies carry none); null when unknown
unclassifiedYesmessages whose thread could not be determined; after_id is held before them, call again to retry
thread_root_idYes
reply_target_idYesnewest message of the batch; reply to this one
pending_other_threadsYesnew messages not returned here (other threads, or beyond the batch limit); after_id has moved past them, so read each with get_thread or get_message
untrusted_content_noticeNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.6.0
    • addedOutput schema / properties / messages / items / properties / edited
      Added value: +{
      +  "description": "ISO-8601 time its sender last edited the body, which is shown as edited; null when unedited",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • changedOutput schema / properties / skipped / items / properties / reason / description
      Previous value: -"one of \"own\", \"reaction\", \"no_reply\", \"from_mismatch\", \"other_thread\". More values may be added"New value: +"one of \"own\", \"reaction\", \"edit\", \"no_reply\", \"from_mismatch\", \"other_thread\". More values may be added"
  2. Changed29 schema fields changedv1.1.0
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / timeout_seconds / description
      Added value: +"longest this call blocks"
    • changedOutput schema / additionalProperties
      Previous value: -falseNew value: +{}
    • changedOutput schema / properties / messages / items / additionalProperties
      Previous value: -falseNew value: +{}
    • addedOutput schema / properties / messages / items / properties / attachments / description
      Added value: +"sorted by filename, the same order in every tool"
    • changedOutput schema / properties / messages / items / properties / attachments / items / additionalProperties
      Previous value: -falseNew value: +{}
    • addedOutput schema / properties / messages / items / properties / attachments / items / properties / type
      Added value: +{
      +  "description": "media type; inferred from the filename when the host records none",
      +  "type": "string"
      +}
    • addedOutput schema / properties / messages / items / properties / compressed
      Added value: +{
      +  "description": "true when the body was sent deflate-compressed on the wire (see size)",
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / messages / items / properties / preview / description
      Added value: +"start of the body; may be shorter than the full body"
    • addedOutput schema / properties / messages / items / properties / reaction
      Added value: +{
      +  "description": "the emoji when this message is itself a reaction (\"\" clears one); null otherwise",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • changedOutput schema / properties / messages / items / properties / reactions / items / additionalProperties
      Previous value: -falseNew value: +{}
    • addedOutput schema / properties / messages / items / properties / size / description
      Added value: +"body size in bytes as stored by your host: for a message you received with compressed true, the compressed wire length; your own sent messages store the uncompressed length. body_bytes, where given, is the decoded length"
    • addedOutput schema / properties / next
      Added value: +{
      +  "description": "what to do with this result",
      +  "type": "string"
      +}
    • addedOutput schema / properties / pending_ids
      Added value: +{
      +  "description": "ids of pending_other_threads, oldest first: read these before waiting again",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / pending_other_threads / description
      Added value: +"new messages not returned here (other threads, or beyond the batch limit); after_id has moved past them, so read each with get_thread or get_message"
    • changedOutput schema / properties / pending_other_threads / items / additionalProperties
      Previous value: -falseNew value: +{}
    • changedOutput schema / properties / skipped / items / additionalProperties
      Previous value: -falseNew value: +{}
    • addedOutput schema / properties / skipped / items / properties / emoji
      Added value: +{
      +  "description": "for reactions: the emoji (\"\" clears a reaction)",
      +  "type": "string"
      +}
    • addedOutput schema / properties / skipped / items / properties / from
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / skipped / items / properties / reaction_to
      Added value: +{
      +  "description": "for reactions: the message reacted to",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • addedOutput schema / properties / skipped / items / properties / reason / description
      Added value: +"one of \"own\", \"reaction\", \"no_reply\", \"from_mismatch\", \"other_thread\". More values may be added"
    • removedOutput schema / properties / skipped / items / properties / reason / enum
      Removed value: -[
      -  "own",
      -  "reaction",
      -  "no_reply",
      -  "from_mismatch",
      -  "other_thread"
      -]
    • addedOutput schema / properties / status / description
      Added value: +"one of \"message\", \"timeout\", \"interrupted\"; interrupted: the server is restarting; call again with after_id. More values may be added"
    • removedOutput schema / properties / status / enum
      Removed value: -[
      -  "message",
      -  "timeout"
      -]
    • addedOutput schema / properties / thread_topic
      Added value: +{
      +  "description": "the thread root's topic (replies carry none); null when unknown",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • addedOutput schema / properties / transport / description
      Added value: +"one of \"websocket\", \"poll\". More values may be added"
    • removedOutput schema / properties / transport / enum
      Removed value: -[
      -  "websocket",
      -  "poll"
      -]
    • changedOutput schema / properties / unclassified / items / additionalProperties
      Previous value: -falseNew value: +{}
    • addedOutput schema / properties / untrusted_content_notice
      Added value: +{
      +  "type": "string"
      +}
  3. Changed3 schema fields changedv0.1.4
    • addedOutput schema / properties / skipped
      Added value: +{
      +  "description": "messages deliberately passed over; after_id has advanced past them",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "id": {
      +        "type": "string"
      +      },
      +      "reason": {
      +        "enum": [
      +          "own",
      +          "reaction",
      +          "no_reply",
      +          "from_mismatch",
      +          "other_thread"
      +        ],
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "id",
      +      "reason"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / unclassified
      Added value: +{
      +  "description": "messages whose thread could not be determined; after_id is held before them, call again to retry",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "error": {
      +        "type": "string"
      +      },
      +      "from": {
      +        "type": "string"
      +      },
      +      "id": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "id",
      +      "from",
      +      "error"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "status",
      -  "after_id",
      -  "thread_root_id",
      -  "reply_target_id",
      -  "messages",
      -  "pending_other_threads",
      -  "transport",
      -  "note"
      -]New value: +[
      +  "status",
      +  "after_id",
      +  "thread_root_id",
      +  "reply_target_id",
      +  "messages",
      +  "pending_other_threads",
      +  "skipped",
      +  "unclassified",
      +  "transport",
      +  "note"
      +]
  4. First observedv0.1.3

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Well beyond the readOnly/idempotent annotations, it discloses the blocking ceiling, the non-replay guarantee on timeout or server restart ('nothing is replayed or lost'), and exactly what gets filtered out (own messages, reactions, no-reply messages; other-thread messages are skipped but surfaced in pending_ids). It also flags the real-world cost of each call: one model turn per wait in chat hosts.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The blocking behavior and the reply loop are front-loaded, and the remainder is organized under tight labels (When / Loop / Skipped / Limits) so an agent can scan the relevant rule. The only redundancy is restating the 230-second ceiling already in the schema, which is minor against the density of useful content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a stateful long-poll tool with six optional parameters and an output schema, the description covers everything an agent must know to call it correctly and repeatedly: first-call behavior (omit after_id), loop state carrying, coalescing, filters, and failure recovery. Return-field details are correctly left to the output schema, with only the action-relevant fields (after_id, pending_ids, reply_target_id) referenced by name.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description goes beyond it by explaining the operational meaning of after_id (carry it forward each loop iteration, it advances past skipped/other-thread messages) and of settle_seconds (same-thread messages inside the window coalesce into ONE result to be answered once at reply_target_id). It adds no detail for from or thread_of beyond their schema text.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence states a precise verb+resource+behavior: 'Block until the next inbound message arrives and return it with its thread context.' It distinguishes this from passive retrieval siblings (list_messages, get_message) by making the blocking/next-message semantics explicit, and even names the follow-up action ('so you can answer with reply').

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives an explicit when-clause ('the user asks you to chat, keep replying or respond to the next message'), a prescribed loop (wait → reply → wait passing after_id), and recovery instructions for the 'timeout'/'interrupted' cases. It also names the alternative for the case it does not cover: messages on other threads must be read with get_thread before waiting again.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.