get_agent_next_message
Retrieve the next unprocessed message from a chat to continue your agent's reasoning loop. Handles crash recovery by returning stuck messages.
Instructions
Get the next message that needs processing.
Returns the single oldest message that is NOT processed, including
new, delivered, processing (stuck/crashed), and failed messages.
Returns empty result if there are no messages to process.
This is the primary endpoint for agent reasoning loops:
1. Call this tool to get the next work item
2. Call mark_agent_message_processing to claim the message
3. Process the message (reasoning, tool calls, etc.)
4. Call mark_agent_message_processed or mark_agent_message_failed
5. Loop back to step 1
Crash recovery: If the agent crashes while processing, the message stays
in "processing" state. When restarted, calling this tool returns that same
stuck message (oldest first), allowing the agent to reclaim and retry it.
Difference from list_agent_messages:
- list_agent_messages returns ALL actionable messages (batch processing)
- get_agent_next_message returns ONE message (sequential processing loops)
Args:
chat_id: The unique identifier of the chat room (required).
Returns:
JSON string containing the next message to process, or empty if none.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chat_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |