Pin down the coord messages endpoint shape after repeated mark-read failures:
{total,skip,limit,messages[]}; parse .messages[], strip control chars, read may be null.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.3 KiB
1.3 KiB
name, description, metadata
| name | description | metadata | ||
|---|---|---|---|---|
| reference-coord-messages-api-shape | Coord /messages endpoint returns a paginated object {total,skip,limit,messages[]}, NOT a bare array; parse .messages[] and strip control chars before JSON parse |
|
The coordination API messages endpoint GET http://172.16.3.30:8001/api/coord/messages?to_session=<SID> returns a paginated object, not a bare array:
{ "total": N, "skip": 0, "limit": M, "messages": [ {...}, ... ] }
How to use it reliably:
- Parse
.messages[](jq) /data["messages"](python) — iterating the top-level object yields keys (strings), which is why a bare.[]?/for m in datafails with "no match" or'str' object has no attribute 'get'. - Responses can contain unescaped control chars (U+0000-001F) that break
jqandjson.loads— strip them first (tr -d '\000-\037'orre.sub(r"[\x00-\x1f]"," ", raw)). - The per-message
readflag may benullon unread messages (notfalse); the server-side&unread_only=truefilter has missedread=nullmessages — safest to fetch without it and filter client-side. - Mark read:
PUT /api/coord/messages/<id>/read.
Caused repeated mark-read failures across a session (2026-05-27) before the shape was pinned down. See the Session Start Protocol in CLAUDE.md for the coord workflow.