openclaw_sessions_tail
Monitor a session by polling for new messages, returning only those that appear during the tail window until the session ends or a message limit is reached.
Instructions
Watch a session by polling sessions.preview and return only the NEW messages that appeared during the tail window. Workaround for the stdio MCP not being able to stream sessions.subscribe / session.message events to Claude Code. Polls every intervalMs (default 2000ms) for up to durationMs (default 30000ms, max 300000ms), or until maxMessages new messages are collected, or until the session reaches a terminal status ('done', 'error', 'aborted', 'timeout', 'completed'). The first poll seeds the 'already-seen' set so existing messages are NOT returned — only what arrives after the tool was called.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Full session key (composite, e.g. 'agent:main:cron:<id>') from openclaw_sessions_list. | |
| instance | No | Optional OpenClaw instance to route this call to (e.g. 'default', 'work'). Falls back to the active default instance, or the OPENCLAW_GATEWAY_URL/TOKEN env vars when set. List configured instances with openclaw_setup_list. | |
| durationMs | No | Total tail duration in ms. Default 30000 (30s). Max 300000 (5min). | |
| intervalMs | No | Polling interval in ms. Default 2000 (2s). Min 500 to avoid hammering the gateway. Max 10000. | |
| maxMessages | No | Stop early once this many new messages have arrived — useful to bail out on the first agent reply. |