Wait for next fmsg message
wait_for_messageBlock 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
| Name | Required | Description | Default |
|---|---|---|---|
| from | No | only accept messages from this address or short name | |
| after_id | No | only 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_of | No | only accept messages in this message's thread | |
| include_thread | No | include the assembled thread context of the newest message | |
| settle_seconds | No | after the first message, keep collecting same-thread messages for this long | |
| timeout_seconds | No | longest this call blocks |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| next | No | what to do with this result | |
| note | Yes | ||
| status | Yes | one of "message", "timeout", "interrupted"; interrupted: the server is restarting; call again with after_id. More values may be added | |
| skipped | Yes | messages deliberately passed over; after_id has advanced past them | |
| after_id | Yes | pass this as after_id on the next call | |
| messages | Yes | ||
| transport | Yes | one of "websocket", "poll". More values may be added | |
| pending_ids | No | ids of pending_other_threads, oldest first: read these before waiting again | |
| thread_topic | No | the thread root's topic (replies carry none); null when unknown | |
| unclassified | Yes | messages whose thread could not be determined; after_id is held before them, call again to retry | |
| thread_root_id | Yes | ||
| reply_target_id | Yes | newest message of the batch; reply to this one | |
| pending_other_threads | Yes | 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 | |
| untrusted_content_notice | No |