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
{{ message }}
Repository navigation
Commit 64f5e64
Browse filesBrowse the repository at this point in the historyBrowse files
hzq
committed
Capture outbound webhooks with their source checkpoints
Bind recipients and their permitted payload before commit. Recover delayed fanout and retry local storage writes without replaying the agent or spending the receiver's retry budget.
| Artifacts (files produced by runs) |`files` table + `<dataDir>/files/`| deleted with their run |
194
194
| Uploaded files, including stored image inputs |`files` table + `<dataDir>/files/`|`oaa prune` when older than the cutoff and not listed by a kept run (image inputs are listed in their run's `fileIds`); the per-caller stored-bytes quota counts these rows, so it drops after a prune |
195
-
| Webhook deliveries |`webhook_deliveries`| the last 200 finished per endpoint; at most 10,000 waiting per endpoint |
195
+
| Webhook deliveries and recoverable notifications |`webhook_deliveries`, `webhook_outbox`| at most 200 finished deliveries per endpoint; at most 10,000 waiting across both tables per endpoint |
196
196
| Session workspaces of the local worker |`<worker dataDir>/sessions/`|`oaa prune` when no run of the session remains and the folder is older than the cutoff |
197
197
| Audit events |`audit_events`| kept per owner up to a fixed count (existing) |
198
198
| Portal sessions |`platform_sessions`| expire after `platform.sessionTtlHours` (existing) |
Copy file name to clipboardExpand all lines: docs/webhooks.md
+8-13Lines changed: 8 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,15 +95,14 @@ The request body is JSON:
95
95
-`data.key_id` and `data.subject` identify the key that started the run and its caller partition
96
96
(`key:<id>`, or `acct:<id>` for a developer-platform account).
97
97
-`pending_actions` appears only on `run.requires_action`. `type` is `tool`, `native`, `reconcile` or
98
-
`client_tool` (a tool result the caller has to send back). `status` is the item's state when the
99
-
body was built (normally `pending`).
98
+
`client_tool` (a tool result the caller has to send back). `status` is its state at the source checkpoint.
100
99
-**The task input and the output text are not included** (privacy and size). An endpoint created with
101
100
`include_output: true` gets `data.output = {text, truncated, bytes}` on run events: the final output
102
101
text, cut to at most 32 KiB of UTF-8 (`truncated: true` and the full size in `bytes` when cut).
103
102
- For anything else, read the run with its ID: `GET /v1/runs/{id}`, `GET /v1/runs/{id}/output`,
104
103
`GET /v1/runs/{id}/actions`.
105
104
106
-
The body is built at the first delivery attempt and then fixed: retries send the same bytes.
105
+
New events capture their recipients and bounded run data at the source checkpoint. Pruning the run before the first POST does not destroy that snapshot. The first attempt fixes the exact body bytes for retries. Later opt-in never adds output to a past event. Withdrawing output before the first attempt redacts it; a retry whose fixed bytes contain withdrawn output fails as `subscription_changed` instead of sending them. Changing the URL or removing the matching event/agent also prevents delivery to the changed subscription. Secret rotation uses the current key.
107
106
108
107
## Signature and headers
109
108
@@ -162,7 +161,7 @@ def verify(secret: str, header: str, raw_body: bytes, tolerance: int = 300) -> b
162
161
- **At least once.** Events are queued in the gateway's SQLite database (`webhook_deliveries`) and
163
162
survive a restart; whatever was not delivered when the gateway stopped is sent after it starts
164
163
again. A receiver may see a delivery more than once; de-duplicate on `X-OAA-Delivery`.
165
-
- The approval announcement and the queued deliveries for its matching endpoints commit together. A failed queue write leaves no partial announcement, so observing the notification again can enqueue it. The delivery guarantee starts **after enqueue**; a gateway exit between the source commit and the outbound observer is not covered for every event type.
164
+
- For all six subscribed run events, the source transaction commits the fanout or durable recovery rows. A crash before the sender wakes does not lose a committed event. If the delivery-table write fails, the gateway retries the recorded fanout automatically, including after restart. If neither local write can commit, the source checkpoint fails rather than claiming success. If even the failure outcome cannot be recorded, the active execution retries only that final write, not the agent or its tools. Restart recovery uses the last committed run state.
166
165
- **Success** is any `2xx` answer within **10 seconds** (connect, send and answer together).
167
166
Redirects are not followed; a `3xx` counts as a failure. Answer fast and do the work afterwards.
168
167
- **Retries.** A failed attempt is retried after about 5 s, 30 s, 2 min, 10 min and 30 min (each ±20 %
@@ -172,15 +171,13 @@ def verify(secret: str, header: str, raw_body: bytes, tolerance: int = 300) -> b
172
171
- **Order.** Deliveries to one endpoint go out one at a time, oldest first, so a receiver sees the
173
172
events of an endpoint in order; a delivery waiting for its retry holds back the later ones of the
174
173
same endpoint. Different endpoints do not wait for each other.
175
-
- **Never in the way of a run.** Queuing an event is one small insert after the run's status is
176
-
committed, and happens only when a matching endpoint exists. Sending happens in the background; a
177
-
slow or dead receiver does not delay or block any run.
174
+
- **No network I/O in a checkpoint.** Only SQLite work is on the source commit path. Sending happens in the background; the run does not wait for the receiver.
178
175
- **Failing endpoints** are not deleted or disabled automatically. The endpoint's `status` shows
179
176
`state:"failing"`, `consecutive_failures`, the last error and how many deliveries are queued.
180
177
- A disabled endpoint (`enabled:false`) gets no new events; deliveries already queued for it wait until
181
178
it is enabled again. Deleting an endpoint deletes its queued deliveries.
182
179
- The last 200 finished deliveries per endpoint are kept.
183
-
- At most 10,000 deliveries wait per endpoint. Above that (an endpoint that keeps failing while events keep coming) the oldest waiting deliveries after the one in progress are marked `failed` with `queue_overflow` and dropped, so a broken receiver cannot grow the database without bound.
180
+
- At most 10,000 pending items per endpoint, including recovery rows. Overflow preserves the queue head; discarded items count toward `overflow_total`. Materialized overflow deliveries are marked `failed` with `queue_overflow`. A recovery row discarded before materialization has no delivery ID.
184
181
185
182
## Outbound safety
186
183
@@ -218,12 +215,12 @@ All endpoints need an owner-wide admin key; other keys get 403 `scope_denied`.
218
215
| `POST/v1/webhooks/{id}/rotate-secret` | `{id, secret}`; the old secret stops working at once |
219
216
| `POST/v1/webhooks/{id}/test` | 202 delivery; queues a `webhook.test` event |
220
217
| `GET/v1/webhooks/{id}/deliveries?limit=20` | `{data: [delivery]}`, newest first (at most 200) |
221
-
| `POST/v1/webhooks/{id}/deliveries/{delivery}/redeliver` | 202 delivery; 409 `webhook_delivery_pending` while it is still queued |
218
+
| `POST/v1/webhooks/{id}/deliveries/{delivery}/redeliver` | 202 delivery; 409 `webhook_delivery_pending` while it is still queued; 429 `queue_full` when no queue capacity remains |
222
219
223
220
An **endpoint** is `{object:"webhook_endpoint", id, url, events, agents, include_output, enabled,
224
221
description, allow_insecure_http, allow_private_network, created_at, updated_at, status}` with
last_error, pending, latest_delivery}`. Times are Unix milliseconds, as elsewhere in the management API.
223
+
last_error, pending, capture_pending, oldest_pending_at, overflow_total, latest_delivery}`. `pending` includes `capture_pending` (recorded but not yet materialized). `oldest_pending_at` is null when empty; `overflow_total` counts evictions since the upgrade. Times are Unix milliseconds, as elsewhere in the management API.
227
224
228
225
A **delivery** is `{object:"webhook_delivery", id, endpoint_id, event_id, event_type, run_id, status:
- HTTPS endpoints are verified against the certificate authorities trusted by Node.js. The automated
318
315
tests only use local plain-http receivers; delivery to a real public HTTPS endpoint goes through the
319
316
same code but is not covered by them.
320
-
- `run.interrupted` for runs interrupted while the gateway shuts down or restarts is queued either at
321
-
shutdown or when the gateway starts again (runs interrupted since the process started), and sent
322
-
once.
317
+
- Capture is installed before startup recovery and remains attached through shutdown checkpoints. Earlier pending deliveries continue using their stored body or original seed. Upgrading does not reconstruct events that an older version never recorded or replay history to new endpoints.
323
318
- Several gateway processes sharing one data directory are not supported (as for the rest of the
新事件在源任务提交时固定接收端和有界的运行摘要。首次 POST 前清理源任务不影响投递。第一次发送时固定正文,重试沿用相同字节。后来启用输出不会给旧事件增加输出;首次发送前撤回输出权限会去掉正文中的输出,已经固定的正文若包含撤回的输出,则不再发送,记为 `subscription_changed`。更改地址、移除匹配的事件或智能体也不会把旧内容发给新订阅。轮换密钥后用当前密钥签名。
88
88
89
89
## 签名与请求头
90
90
@@ -137,15 +137,15 @@ def verify(secret: str, header: str, raw_body: bytes, tolerance: int = 300) -> b
0 commit comments