Skip to content

ref(todos): Settle child To-dos from what the parent received - #4040

Merged
dcramer merged 7 commits into
mainfrom
fix/child-agent-todos-on-result
Nov 24, 2026
Merged

dcramer merged 7 commits into
mainfrom
fix/child-agent-todos-on-result

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Only the To-dos feature (chat/todos/) changes To-dos. Result delivery, stops, the agent loop, and the Agent invocation path no longer write them. Before, those core paths closed a child's To-dos themselves, which tied them to one tool's state.

A To-do assigned to a child agent closes as done when a reply or completed result from that child reached the parent after the To-do last changed, and as dropped on a stopped result.

The To-dos store reads each child result's stored status (metadata.event.status) to tell done from dropped. No new state and no loop hooks.

via @dcramer.

--

View Session [Sentry]

…vocation

A completed reply from a child with no Agent invocation is its result, so
it closes the child's open To-dos done, as the row path does. Only the
first send closes them, so a retry leaves later To-dos open.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 23, 2026 10:48pm UTC

Request Review

@dcramer dcramer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really love that this whole thing is baked into the core of the harness when it's actually completely disconnected from the core and it's connected to a specific tool call

@sentry-junior

sentry-junior Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Re your review: agreed, it's in the wrong place. Today the result path (agent-invocations/result.ts) writes the To-do status for both the row path and this PR. Two ways to fix it:

  1. Derive it in the To-dos feature (recommended). Nothing in the result path writes To-dos. When chat/todos builds a parent's To-dos (snapshot, prompt and updateTodos output), a To-do assigned to a child whose final result already reached the parent counts as done (completed) or dropped (stopped). The next updateTodos stores that. The harness stays out of it. The rule "a child's result closes its To-dos" holds for both paths, and the retry guard goes away because a read can't be applied twice.
  2. Keep the write, move the code. closeTodosForResult moves to chat/todos/, and the result path calls it at one place. That's smaller, but it's still the harness doing To-do work.

Should I do 1 in this PR, replacing the current change and the row path's close? I'll hold #4040 until you answer.

The To-dos store now closes a parent's open To-dos of a child agent when it
reads them: done when the child completed, dropped when it stopped, and
only when that work ended after the To-do's last change. Result delivery
and the Agent invocation path no longer write To-dos.

Co-Authored-By: David Cramer <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/junior/src/chat/todos/store.ts Resolved
Comment thread packages/junior/src/chat/todos/store.ts Resolved
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

4 screenshot changes — 4 changed · 0 added · 0 removed

Review screenshots in Frameshift

Code Mine · Mobile
Code Mine · Mobile
Changed
Conversation Event Log · Mobile
Conversation Event Log · Mobile
Changed
System Cache Health Stale · Desktop
System Cache Health Stale · Desktop
Changed
System Cache Warming Refill · Desktop
System Cache Warming Refill · Desktop
Changed

The thread-input harness can now end a run on a model message after its
input, so the Turn saves its completed checkpoint as production does. A
child with no Agent invocation then reads as completed, and the test shows
that its parent's open To-dos close as done.

Co-Authored-By: David Cramer <[email protected]>
@blacksmith-sh

This comment has been minimized.

A child's result now stores how its work ended next to its sender. The
To-dos store closes a child's open To-do when a completed or stopped
result from that child waits in the parent's mailbox and is newer than
the To-do's last change. A person's Turn in a Thread and late bookkeeping
writes no longer close To-dos, because neither sends a result.

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior

sentry-junior Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Reworked in 7052dd0f4. Only chat/todos/ changes To-dos now:

  • listTodos closes a child's open To-dos based on the results that reached the parent: done for a reply or completed result newer than the To-do's last change, dropped for a stopped result.
  • Result delivery, stops, the agent loop, and the Agent invocation path no longer write To-dos. closeTodosForResult and closeOpenTodosOfChild are removed.
  • A child's result stores how its work ended next to its sender, so the store reads a stored field instead of text or ids.
  • No new columns or tables, and no loop hooks.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/junior/src/chat/todos/store.ts Resolved
@sentry-junior sentry-junior Bot changed the title fix(agents): Close a child's To-dos on its result without an Agent invocation ref(todos): Settle child To-dos from what the parent received Nov 22, 2026
…-on-result

Co-Authored-By: David Cramer <[email protected]>

# Conflicts:
#	packages/junior/src/chat/agent-invocations/child-message.ts
#	packages/junior/src/chat/agent-invocations/result.ts
#	packages/junior/tests/fixtures/thread-input.ts
#	packages/junior/tests/integration/agent-invocation-work.test.ts
#	packages/junior/tests/integration/update-todos.test.ts
…-on-result

# Conflicts:
#	packages/junior/src/chat/agent-invocations/result.ts
#	packages/junior/src/chat/todos/store.ts
#	packages/junior/tests/fixtures/thread-input.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e3edcba. Configure here.

]
: [];
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To-do settlement relies on short-lived mailbox state

Medium Severity

readReceivedChildResults only looks at execution.pendingMessages. A child's result counts only if some listTodos call happens while that message is still in the mailbox. If the message is removed first, the To-do stays open for good. For example, completeConversationStop filters out the stopped run's pending messages, and with them any child completed/stopped results waiting there.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e3edcba. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declining this one. The example doesn't hold: stopConversationWork puts only person input (isPersonInput: web or slack) into the stop request, and completeConversationStop removes only those ids. A child's completed or stopped result is agent input, so a stop never removes it from the mailbox.

The general concern is the same as the earlier thread (#4040 (comment)). Every parent Turn reads its To-dos in loadPromptTurnContext before it acks its input, so it settles them while the result is still pending. A result that the parent never takes in leaves its To-dos open on purpose, because the parent never received it.

Main now stores a child result's status as metadata.event.status, so the
To-dos store reads it there and the separate metadata.result copy goes.

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer merged commit 9ba4647 into main Nov 24, 2026
57 checks passed
@dcramer
dcramer deleted the fix/child-agent-todos-on-result branch November 24, 2026 02:14

This branch was successfully deployed

1 active deployment
Preview – junior-docs — e8bbe76c Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant