feat(agent): add durable event subscriptions#1405
Open
devRickyyy wants to merge 1 commit into
Open
Conversation
Signed-off-by: Test <test@example.com>
jomeswang
force-pushed
the
agent/event-subscriptions
branch
from
July 19, 2026 02:28
05ff7b6 to
42a780c
Compare
devRickyyy
marked this pull request as ready for review
July 19, 2026 02:35
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_bf64f56f-f69d-48fe-90aa-fc96b816d8cf) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Architecture
V1 supports
agent.turn.completed,agent.turn.failed,agent.turn.canceled, andagent.turn.interrupted. The storage schema is source-generic (source_kind,source_id,source_subject_id) so future app sources can reuse the delivery machinery after defining canonical facts and catalog entries.Terminal settlement and delivery preparation share a SQLite transaction participant. Runtime delivery is at-least-once;
event-delivery:<delivery_id>is the stable client submit ID that makes retry after a crash idempotent. Subscriptions are one-shot, self-subscription is rejected, and soft-deleted source/subscriber sessions cannot poison future dispatch.CLI
When invoked inside an Agent session,
subscriptions createdefaults the subscriber to the invoking session. Outside that context, pass--session-id <subscriber>.Verification
golangci-linton changed daemon packages: pass (0 issues)go test ./...inpackages/agent/host: passgo test ./...inpackages/agent/store-sqlite: passdata/workspace,service/agent, Agent-context CLI): passgo build ./...inservices/tuttid: passgit diff --check: passAfter rebasing onto the latest
main,go test ./...for the whole daemon wasalso attempted. Feature-adjacent packages passed; unrelated builtin-app and
black-box cases could not start because the worktree does not contain
generated/tutti-onboarding/tutti-onboarding-0.1.0.zip. The repository'sgenerate:builtin-appscommand was attempted but did not return in thisenvironment.
go build ./...and every package changed by this PR pass.pnpm check:changedwas also attempted. Its generated Go lint lanes currently pass.together with explicit packages and fail withno go files to analyze; its builtin-app precheck also did not return. Equivalent package-scoped checks above were run directly.Documentation
docs/architecture/agent-event-subscriptions.mdScope / follow-ups
Research references
workflow_run: https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_runNote
Medium Risk
Touches core Host recovery ordering, turn submission semantics, and transactional turn settlement; mistakes could duplicate continuations or drop durable orchestration after crashes, though idempotent submit IDs and conformance tests mitigate that.
Overview
Introduces durable Agent event subscriptions so one session can resume when another session’s turn reaches a terminal outcome (
completed,failed,canceled,interrupted). Subscriptions are one-shot, replay-safe via caller-owned IDs, and distinct from the business WebSocket stream.Storage and matching: New SQLite tables and migration, a closed v1 event catalog in
store-sqlite/canonical, andEventSubscriptionParticipantthat atomically marks subscriptions matched and enqueues prepared deliveries in the same transaction as terminal turn settlement. Session delete cancels active subscriptions or fails in-flight deliveries to avoid poison retries.Host orchestration:
EventSubscriptionStoreport, create/list/cancel APIs, a leased delivery worker (backoff, startup requeue) wired intoHost.RunandRecover(after goal inbox, before stale-turn settlement). Deliveries callSendInputwithSubmissionKindEventContinuation, structured event JSON, and deterministicevent-delivery:<id>client submit IDs so at-least-once delivery yields one logical continuation turn.Integration:
tuttidwires the participant on the writer store, delegates subscription CRUD through the agent service, and exposes Agent-context CLI (event-types,subscriptions create/list/cancel). Conformance adds an additiveEventSubscriptionScenariosdriver (crash-window idempotency). Architecture docs describe the contract and clarify separation from the business event stream.Reviewed by Cursor Bugbot for commit 42a780c. Bugbot is set up for automated code reviews on this repo. Configure here.