Repository navigation
Description
Summary
PgWebhookDeliverySupervisor never sends a task webhook. send_mcp stores the task's status (completed, failed, ...) in the queue's status_str column, but the worker only claims rows whose status_str is pending or retry. Every job enqueued through send_mcp with a real task status stays in the queue unsent.
Reproduction (adcp 9.0.0b4 and 9.1.0; webhook_supervisor_pg.py is identical in both)
# DATABASE_URL=postgresql://... uv run --no-project --with 'adcp[pg]==9.1.0' python repro_b1.py
import asyncio
import os
from cryptography.hazmat.primitives.asymmetric import ed25519
from psycopg_pool import AsyncConnectionPool
from adcp.webhook_sender import WebhookSender
from adcp.webhook_supervisor_pg import PgWebhookDeliverySupervisor
async def main() -> None:
pool = AsyncConnectionPool(os.environ["DATABASE_URL"], open=False)
await pool.open()
sender = WebhookSender(private_key=ed25519.Ed25519PrivateKey.generate(), key_id="k1", alg="ed25519")
supervisor = PgWebhookDeliverySupervisor(pool, sender)
await supervisor.create_schema()
await supervisor.send_mcp(
url="https://buyer.example/hook",
task_id="task_1",
status="completed",
task_type="create_media_buy",
result={"media_buy_id": "mb_1"},
operation_id="op_1",
)
async with pool.connection() as conn:
rows = await (await conn.execute("SELECT id, status_str FROM adcp_webhook_delivery_queue")).fetchall()
print("queued rows:", rows)
print("worker picked a job:", await supervisor._poll_and_process())
await pool.close()
asyncio.run(main())queued rows: [(1, 'completed')]
worker picked a job: False
Where
adcp/webhook_supervisor_pg.py,send_mcp:status_str = status if isinstance(status, str) else str(status)is written intostatus_strby_sql_enqueue._sql_poll:WHERE status_str IN ('pending', 'retry') AND scheduled_at <= now()._poll_and_process, exception-retry branch: whensent_bodyis empty it callssend_mcp(status=status_str, ...). After one reschedulestatus_stris'retry', so even a job that was claimed would be re-sent withstatus: "retry", which is not a task status.
The column is doing two jobs: the queue state and the task status. Splitting it (for example a queue_state column for pending/retry, and task_status for the payload) fixes both.
Also worth deciding
- The supervisor takes one fixed
WebhookSender, so a multi-tenant seller cannot sign per tenant.PgNotificationOutboxandPgTaskWebhookOutboxtake asender_resolver. task_webhook_owner_readyalready refuses configurations that wire a supervisor, and the module docstring says it does not meet the AdCP 3.2 retry-horizon contract. IfPgNotificationOutbox/PgTaskWebhookOutboxare the durable path, deprecatingPgWebhookDeliverySupervisor(with a pointer to them) may be better than fixing it.
Why an adopter hits this
The Embedded Sales Agent's target shape names webhook_supervisor_pg as its webhook path (scope3data/agentic-api docs/spec/sales-agents/embedded-sales-agent.md, "SDK first"). Moving onto it as shipped would silently stop every task webhook, so the ESA is moving onto PgNotificationOutbox instead.
Activity
fix(webhooks): send PgWebhookDeliverySupervisor task webhooks and del…