You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: integrations/shared/coordination-protocol.md
+157-2Lines changed: 157 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,143 @@ the event trail is only auditable if identities are stable.
59
59
`type=task.reply` with `status=blocked` or `failed` and verbatim
60
60
notes. Silence is the only unrecoverable failure.
61
61
62
+
## Monitoring the stream
63
+
64
+
Most coordination friction is not a protocol failure — it is a *listening*
65
+
failure. A task sits `open` because the agent it was addressed to was never
66
+
watching, and the requester cannot tell the difference between "working on
67
+
it" and "nobody is home". Pick a monitoring mode deliberately and make it
68
+
visible.
69
+
70
+
### The cursor rule
71
+
72
+
**Resume with `since_event_id`. Never resume with `since_created_at`.**
73
+
74
+
Events are ordered by *append* order (rowid), not by wall clock. Across
75
+
replicas those diverge: a peer's event created at 09:10:48Z can be ingested
76
+
*after* a local event created at 09:13:21Z, because it only arrived at sync
77
+
time. A cursor based on `since_created_at` silently skips such an event —
78
+
it is already older than your high-water mark by the time you see it, so you
79
+
never see it at all.
80
+
81
+
-`since_event_id` — the precise cursor: strictly after that event in append
82
+
order, regardless of timestamp ties. **This is what a watcher stores.**
83
+
-`since_created_at` — a time *window* for questions like "what happened
84
+
today". Inclusive (`>=`), so callers must dedup by `id`. Not a cursor.
85
+
86
+
Your entire watcher state is one string: the id of the last event you
87
+
processed.
88
+
89
+
### Four modes — pick by how long you stay alive
90
+
91
+
| Mode | Use when | How |
92
+
|---|---|---|
93
+
|**Inbox sweep**| Start of every session, and before any long task |`mempalace_event_list` with `to_agent=<you>`, `since_event_id=<last seen>`, `preview=true`|
94
+
|**Background watcher**| You want to be woken while you work |`mempalace logstream watch` as a background process — see below |
95
+
|**Long-poll**| Actively waiting on one known correlation, in-turn |`mempalace_event_wait` with `correlation_id` + `to_agent=<you>`|
96
+
|**Push (SSE)**| Persistent processes: daemons, dashboards, live viewers |`GET /logstream/stream` — same filters, same envelope, `since_event_id` resume |
97
+
|**Declared-idle**| Turn-based agents that stop existing between prompts | You cannot watch. Say so, publish your cursor, and let the requester ping you |
98
+
99
+
### The background watcher
100
+
101
+
`mempalace logstream watch` is the mode most agents want. It blocks until
102
+
something you care about arrives, prints it, and exits — so any harness that
103
+
can run a background process and react to its exit gets woken:
0 commit comments