peek_inbox_version
Check total_unread_count and epoch to poll for new mail without fetching messages; diff the count against your cache and call get_messages only when it changes.
Instructions
Cheap non-mutating mailbox version probe (v2.3.0 Phase 4s, ambient wake support).
When to use: low-rate polling that wants to know 'do I have new mail?' without paying a get_messages round-trip, clients diff total_unread_count against their cached value and only call get_messages on a change. Pair with the optional filesystem-marker wake (when RELAY_FILESYSTEM_MARKERS=1) for low-latency idle wake. For full mailbox content use get_messages (mutating) or get_messages_summary (preview).
Behavior: pure read. Returns { mailbox_id, epoch, last_seq, total_messages_count, total_unread_count }. WATCH total_unread_count for new-mail detection, it advances on every send_message/broadcast to this agent. last_seq is the OBSERVED axis: it advances when the recipient views mail through ANY get_messages call, including peek=true, so it says nothing about delivery or reading, and no decision may key on it. epoch rotates on backup/restore, a client whose cached epoch no longer matches MUST reset its local last_seen_seq to 0 and re-drain. Auth: any agent token.
Returns: { success: true, mailbox_id, epoch, last_seq, total_messages_count, total_unread_count }.
Errors: AUTH_FAILED, NOT_FOUND (unknown agent_name), RATE_LIMITED.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_name | Yes | The agent whose mailbox to observe | |
| agent_token | No | Your agent token (from register_agent response). Optional here — also resolvable from RELAY_AGENT_TOKEN env or X-Agent-Token header. |