Skip to main content
Glama

Wait for next fmsg message

wait_for_message
Read-only

Block until the next inbound message arrives, then return it with thread context so you can reply. Use it to listen in chat, keep replying, and resume after timeouts.

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.

Input Schema

TableJSON 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

TableJSON 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. 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"
      +}
  2. 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"
      +]
  3. First observedv0.1.3

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only declare readOnly/openWorld/non-idempotent/non-destructive; the description adds the genuinely non-obvious traits: blocking semantics, 230s hard cap, that a server restart returns 'interrupted' with nothing replayed or lost, that same-thread messages within settle_seconds collapse into one result, and which messages are silently skipped. This is exactly the extra context annotations cannot carry.

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

Conciseness4/5

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

Front-loaded purpose followed by labeled sections (When, Loop, Skipped, Limits) makes it scannable and nearly every sentence carries operational content. It is dense and uses unexplained output-field names ('reply_target_id', 'pending_ids'), which slightly hurts readability, though the output schema presumably defines them.

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 blocking, stateful, loop-driven tool this covers the full agent decision surface: trigger, iteration protocol, aggregation, skip rules, error/interruption recovery, and time budget. With an output schema present, return-value detail is rightly delegated, so nothing material is missing.

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, but the description adds real usage semantics beyond the field docs: after_id must be threaded through each loop iteration, settle_seconds drives the one-result aggregation rule, and timeout_seconds is bounded at 230. It does not explain 'from' or 'thread_of' beyond the schema, hence 4 rather than 5.

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 first sentence gives a specific verb (block/return) and resource (next inbound message) plus the scope (with its thread context) and even the follow-on action ('so you can answer with reply'). It is clearly distinguishable from siblings like list_messages, get_message and get_thread, which are non-blocking reads.

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?

The 'When:' line states the trigger (user asks to chat / keep replying / respond to the next message), the 'Loop:' line prescribes the wait → reply → wait cycle, and the 'Skipped:' section names the alternative for out-of-thread messages ('read them with get_thread before waiting again'). Both when-to-use and when-not-to-use are covered.

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