Repository navigation
Description
Intent
A child agent (Thread or Task) and an Automation run are ordinary Conversations. They use the same worker, inbox, Turn lifecycle and agent loop as a root. Only these things can differ by Conversation kind:
- the system prompt
- the enabled tools
- the actor (a Task runs as the system actor)
- where a reply goes
- whether a Turn must explicitly reply
All other behavior is the same for every kind.
Why
- Children have their own worker, their own steering drain, their own finish paths and per-invocation delivery state (
parent_mailbox_status, outbox repairs,subagent_*markers). Each copy drifted from the root path, and each fix added a status or a repair job. - feat(agent-invocations): Gate child reports and send results first #3042 tried to add a reply gate on top of this. Four review rounds found new edge cases each time: lost reports, a stop that dropped results, stale rows sent again. The cause was the architecture, not the gate. feat(agent-invocations): Gate child reports and send results first #3042 is closed.
- Every child Run's final response goes to the parent, also for Watch work such as PR bot comments or CI events. The parent wakes up for each event and steers work that the child should own.
- Automation runs have their own answer tool (
finishAutomationRun) and reminder. Its three results are the same choices as reply,noReplyandreportBlocked.
Target design
One switch. turnBehavior({ kind, personInput }) in conversations/kind-behavior.ts returns a plain object for the behavior that differs. No other code branches on kind, a parent, parentToolCallId, declaresResult or Source. An architecture check enforces this, with a baseline of the legacy branches that goes to zero.
Kinds: root, thread, task, and automation for scheduled and event Automation runs. Plugin dispatches stay root.
Delivery and the reply gate:
- A Turn that a person opened (Source
slackorweb) always delivers its final response where that person is. It has no gate. This includes people who reply in an Automation run's Slack thread. - Root Turns are never gated.
- Every other Turn on a non-root kind must end with one of the same three answer tools. These Turns come from parent input, Watch, timers and the Automation dispatch. The Turn gets 1 re-ask.
reply:kinddecides where it goes. Forthreadandtaskit goes to the parent. Forautomationit goes to the run's Destination, then to the run's Slack thread after the first post.noReply: stay quiet.reportBlocked: forthreadandtaskit goes to the parent. Forautomationit blocks the Automation with the reason.- If the answer is still missing: a Thread or Automation run stays quiet and records telemetry. A Task's parent is told that no reply was sent.
- A final response on a non-root kind stays in its own Conversation.
messageAgentstays for messages between agents. It is not the reply path.- An Automation run ends when its Turn ends, like any Conversation. There is no separate end-run tool. If one is needed later, it stops the Conversation.
Parent controls: spawn, message and stop are plain writes.
- Spawn creates the Conversation and its binding, then adds the task to its inbox.
- Message adds one inbox message.
- Stop sets
stopped_aton the subtree. The child's worker checks it at each step boundary and ends its own Turn. - A worker never changes another worker's state. Supersede runs only in the owning worker.
No delivery state. A reply is a message in another Conversation's inbox, like a Slack message to a root. Inbox message ids remove duplicates. Status comes from the child's Turn lifecycle. The Agent invocation table and parent_mailbox_status are removed after in-flight work drains.
Failures use the root paths: failed Turns, lost workers and retry exhaustion. A Task's parent gets the failure. Other kinds store it and report it through telemetry.
Plan
Each step is a separate PR. Each PR can be deployed and rolled back safely.
- Per-kind table, with no behavior change. Prompt mode, tools, agent tools, delivery and the Automation gate read
turnBehavior. Also add the architecture check and its baseline. (ref(conversations): Route per-kind behavior through turnBehavior #3059, merged) - Kind
automation.- 2a: widen the kind constraints, and readers accept the new value. (feat(conversations): Accept automation Conversation kind #3091, merged)
- 2b: new scheduled and event Automation runs write it. Old
agent-dispatch:rows stayroot. No behavior change. (feat(automations): Store Automation runs as automation Conversations #3125)
- Shared answer tools for Automation runs. Add
reply. Automation runs usereply,noReplyandreportBlocked, and every non-person Turn onautomationis gated.remindMissingAutomationResultbecomesremindMissingAnswer. DeletefinishAutomationRunand theautomationRunflag. Oldrootrows of runs in progress at deploy keep their outcome mapping until they finish. - Children reply with
reply. It works without an open invocation row. Gate child Turns. The worker checksstopped_atat each step boundary. Carry over the child-agent evals from feat(agent-invocations): Gate child reports and send results first #3042. - Children with no open invocation run on the shared Conversation worker (
conversation-turn). Carry over and rewrite the recovery tests from feat(agent-invocations): Gate child reports and send results first #3042. - Behind a flag: spawn and
messageAgentstop writing invocation rows and markers. Turn on failure notices for children. - Remove the legacy child worker, steering drain and repair jobs. Then drop the Agent invocation table and
parent_mailbox_status. Move the dispatch worker ontoconversation-turnafter this step, as a separate change.
Known costs
- A Watch Turn on a non-root kind that ends with plain text pays 1 re-ask.
- There is no automatic "done" signal.
waiting_onreads the child's activity status. - A wrong
noReplyhides findings. - The stop check adds one SQL read per model step.
Related
- Run every agent on one Conversation execution core #2567 is the broad plan for one Conversation execution core. This issue replaces its child-agent steps (5 and 6). It does not keep a request record with its own status: authority is on the inbound message and the Turn, and delivery has no state.
- Add Threads: child conversations people can talk to #2792 (Threads), Let a conversation coordinate child conversations #2105 (child conversations), Child agent work is attributed to whoever last messaged it #2626 (child work attributed to the last sender).
- feat(agent): Replace no-reply markers with a noReply tool #3039 added
noReply. feat(agent-invocations): Gate child reports and send results first #3042 is closed and replaced by this plan.
via @dcramer.
--
Activity
feat(conversations): Accept automation Conversation kind
feat(conversations): Accept automation Conversation kind (#3091)
feat(automations): Store Automation runs as automation Conversations (#…
feat(automations): Answer Automation runs with reply, noReply and rep…
feat(agents): Answer child Turns with reply, noReply and reportBlocked (
fix(agents): Check and route parent messages for children without a row
fix(agents): Keep child result reporting as on main while rows exist
sentry-junior commentedon Nov 12, 2026
Open bugs on the legacy Agent invocation path, for steps 6–7. They come from the review of #2627. #2640 fixed them, but it is closed because it conflicts with the use of
beforeWorkStopsincreateEndStoppedChildWork(#3206).clearExpiredConversationLeasecallsbeforeWorkStops. When work stops,recordConversationRetry(an error escapes the last try) andrecordAttemptFailure(dead-lettering) drop the mailbox, but they do not end the child's open Agent invocations. So an appended follow-up stayspending, its id is still ininboundMessageIdsso it cannot be appended again, and the parent never gets a result.writeConversation, and it holds the 10s mutation lock without extending it. If the lock runs out or the heartbeat dies before the write, the work can start again with its invocations already failed.I read this from
mainat6c1cbde, and I did not run a test there. When step 7 removes the legacy worker, both bugs go away. Until then, the test in #2640 (agent-invocation-worker-crash.test.ts: "tells the parent about dropped work when a child worker fails past its last retry") reproduces the first one.feat(agents): Read child agent state without an Agent invocation row (#…
fix(agents): Drop the parent message limit for children without a row (…
fix(agents): Check spawn replays of children without Agent invocations
feat(agents): Spawn and message child agents without Agent invocations
fix(agents): Check spawn replays of children without Agent invocations
fix(agent-invocations): Close child-without-row gaps and share child-…
feat(agents): Spawn and message child agents without Agent invocations
17 remaining items
ref(agents): Mark saved parent messages with a stored field
ref(agents): Check a stopped parent and a child agent's parent edge i…
ref(agents): Name the removal condition for the legacy parent prefix …
ref(agents): Run every Conversation on one worker path
ref(agents): Remove kind-behavior leftovers from the automated-turn l…
ref(agents): Rename Agent invocation leftovers to child agent terms (#…
ref(agents): Check a stopped parent and a child agent's parent edge i…
ref(agents): Mark saved parent messages with a stored field
ref(agents): Name the removal condition for the legacy parent prefix …
ref(agents): Batch child input drop checks and trim one-hop helpers
feat(agents): Let any agent message the agents of its tree
ref(agents): Run unknown visibility as private and segment cache warm…
ref(agents): Remove kind-behavior leftovers from the automated-turn l…
ref(agents): Run unknown visibility as private and segment cache warm…
ref(agents): Use one status list for every agent (#4440)