Repository navigation
ref(conversations): Save a child's Location when it is created - #2865
Conversation
Add resolveRunPlacement, which reads the config Location, depth, and visibility of a root or child Conversation from its root. Agent runs and Agent invocations use it in place of their own lineage reads. Move the supersede of open mailbox Turns into its own module. No behavior change. Co-Authored-By: David Cramer <[email protected]>
…e rules Return the raw root visibility from readLineageRoot. Only executeAgentRun resolves it, so the defaulted-visibility warning fires once per Run. Test the Run privacy and every supersede rule. Co-Authored-By: David Cramer <[email protected]>
Drive the supersede scenario through createConversationTurnWorker with a stale yield Turn, an auth-parked Turn with a web sign-in, and a kept retry Turn. Keep only the stop case as a direct component test, because a worker has no seam to stop between two abandon writes. Fix the readLineageRoot JSDoc and use the shared requireConversationTurn fixture. Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Why isnt the agent context just written (inferred basically) when its spawned? It shouldn't be that complicated. I'm not really sure what's going on. Every conversation has its various behaviors/context. Those get bound when the conversation is created. Each turn has actor context assigned to it (as it has a source/origin). Subagents if they need config - say like not having certain tools or whatever - that is either implicit based on its kind, or its defined when the spawnAgent call is made. Let's stop overcomplicatings thing. |
|
6 screenshot changes — 6 changed · 0 added · 0 removed Review screenshots in Frameshift |
A child agent no longer reads its parent or root after it is created. createChild copies the root Location, visibility and depth into spawn_json, and child Runs read only that copy. Migration 0085 backfills existing children. Co-Authored-By: David Cramer <[email protected]>
Resolve conflicts with the shared archive (#2900) and agent tree kinds. Renumber the child spawn migration to 0087 and regenerate its snapshot. Keep `kind` in the lineage entry for the agent tree, and drop its Location and visibility: child Runs read the copy bound at spawn. Drop the supersede refactor (supersede-turns.ts) and its tests. The bind-at-spawn design does not need it.
|
this PR is full of jargon |
|
i dont think it needs to know how deep it is, does it? |
|
Only for one thing. Depth feeds So there are two ways to go:
I'd drop it. Nothing uses it, and it's the only reason depth exists. I'll do it in this PR if you agree. |
|
The depth check can happen at spawnAgent runtime, because by hardcoding depth within a conversation means we cant move its depth/parent later... |
A child now saves only the root's Location when it is created. - Each Run reads the root's current visibility through root_conversation_id, the same source as the access checks. A root that becomes private also makes its open children private. - The worker counts the child's parents when its Run starts, so a moved child gets its new depth. A chain that does not end at a root cannot start agents. - The spawn_json schema is strict and holds only `location`.
|
you keep fucking this up:
|
A child now saves what its root has: the Location and the visibility. Only depth is still counted when a Run starts. - createChild saves both for every child. It reads the root's visibility with a lock on the root Destination, so a change that runs at the same time also updates the new child. - When the Destination upsert changes visibility, every child of every root on that Destination saves the new value in the same transaction, in both directions. - When a root gets its first Location (Continue in Slack) or its first thread, its children save the new Location. - A child Run reads only its own row. A root Run reads its own Destination, as before. - The 0087 backfill also saves visibility: "public" only when the root Destination is public. Co-Authored-By: David Cramer <[email protected]>
…cation A child stores the root's destination_id and Location when it is created, so its Runs read visibility and Location from their own row, the same as a root. Visibility stays current because the child reads the shared Destination row. Nothing copies visibility onto a child. Remove spawn_json and the code that rewrote it on each child. The spawnAgent tool now counts parents when it is called and refuses past limits.maxAgentDepth, or when the chain does not end at a root. Migration 0087 fills destination_id and location_json for existing children.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 33aa920. Configure here.
A write that gives a root its first Location, its thread, or a Continue in Slack move now gives every descendant the same Location and Destination row in the same transaction. Before, children kept the old values, so after Continue in Slack they could still read public when the root's channel went private. createChild holds a share lock on the parent while it copies it. spawnAgent now marks a child that is too deep to start child agents. Its Runs, and later invocations of the same child, do not offer spawnAgent. The spawn-time depth check still guards.
A child keeps its root's Location for provider config and Slack read tools. The Turn worker now requires a root before it posts an Event reply there, instead of relying on a child having no Location. Co-Authored-By: David Cramer <[email protected]>
Co-Authored-By: David Cramer <[email protected]>
…very Depth policy is config only: with maxAgentDepth 0 (the default) no child Run offers spawnAgent. With a higher limit, spawnAgent checks the depth when it is called. Migration 0087 is data only again. Document in TERMINOLOGY.md and at the Turn worker guard that only a root Conversation delivers to its Location. Co-Authored-By: David Cramer <[email protected]>
…and root Delivery Remove the descendant Location sync, the dashboard record guard and the routing guard. A child copies its parent's Destination row and Location when it is created. Existing children keep the old Location after a root's Location changes; that gap is accepted for now. Co-Authored-By: David Cramer <[email protected]>
Since #2865 a child stores a copy of its parent's Destination row and Location. A person's Turn in a Thread now reads them from the Thread instead of walking the chain to the root each Turn. Remove the agent-invocations lineage helper. The run consistency check reads the stored kind, not the root id. Only a root delivers to its Location, so a Thread's copy is not posted to. Move the person's Turn supersede into thread-turn.ts to keep work.ts under the file length limit.
PR 3a of #2792 (Thread input path). Stop and the Thread restart rule come in #2845. Nobody can create a Thread until PR 6, so roots and Tasks keep today's behavior. Every check reads the stored Conversation row (`kind`, Destination). None parse ids. **Input.** `acceptsWebMessages` is the one check. A child accepts web input only when `kind === "thread"`. The dashboard, ACP and review-desk replies all use it. A Task still gets 409. **Router.** For a Thread, a web batch goes to the mailbox worker. A resume wake goes to a person's Turn only when it names that Turn. Everything else goes to the invocation worker. **A person's Turn in a Thread:** - Destination: from the Thread's own row. Reads no longer hide the Destination a child copied at creation (#2865). Delivery stays root-only. - Run consistency: `assertRunConsistency` gets `kind` from the row `executeAgentRun` already reads. For a Thread, it skips the source/destination id match. - Visibility: the Thread's. Private when missing. - `subagents` is disabled. Memory tasks are skipped. - New input supersedes open mailbox Turns. The code is shared with roots in `supersede-turns.ts`. **Child work keeps no Destination.** `wakePausedTurn` and `recordWebConversationActivity` pass none for a non-root row, so the invocation worker's guard still holds. Deviation: invocation input does not queue behind a person's Turn that is paused for sign-in. Tests store a Thread by spawning a child and setting `kind = 'thread'` in SQL. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A96e1fbed00be27afa889991eed5d625a --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A96e1fbed00be27afa889991eed5d625a) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A96e1fbed00be27afa889991eed5d625a/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>

Part of #2792.
Every Conversation stores the same Location attributes. When a child is created, it copies its parent's
destination_idand Location. Child Runs read visibility and Location from their own row and do not walk the parent chain. Visibility is "public" only when that Destination row is public. Else it is private.Location changes: when a root's
location_jsonordestination_idchanges (its first Location, a new thread, or Continue in Slack), every descendant gets the same values in the same transaction. Descendants are found by followingparent_conversation_id. This runs only when a Location changes, never per Turn.createChildholds a share lock on the parent row while it copies it, so a child created during a change also gets the new values.Delivery rule: only a root delivers to its Location. The Turn worker enforces this with a root check, marked TODO until each Run gets explicit Delivery. A child keeps its root's Location for provider config and Slack read tools, but it never posts an Event reply there.
Depth is checked once, at spawn. A child at the limit is saved with
subagentsdisabled, so it never seesspawnAgent. Later invocations of the same child keep this. The spawn-time check stays as the guard. A chain that does not end at a root, such as a cycle, cannot start agents.Access checks still read the root and do not change.
Migration 0087 adds
child_agents_disabledto agent invocations. It also gives each existing child the Destination row and Location of its root. A child whose chain is broken or has a cycle gets nothing, so its Runs are private. Nothing is dropped.Tests:
continue-in-slackandlocation-thread: a root with a child and a grandchild gets a first Location, a thread, or a Continue in Slack move. Both descendants then have the new Location anddestination_id. After the move and a private channel, both read private.agent-invocation-work: a child Run reads visibility and Location from its own row.agent-invocation-spawn: past the depth limit,spawnAgentfails. A child spawned at the limit is saved withsubagentsdisabled.agent-invocation-concurrencyandagent-invocation-nested: a message and a result keep that setting.conversation-turn-delivery: an Event Turn on a child with a copied Location saves the reply and posts nothing.via @dcramer.
--
View Session [Sentry]