Skip to content

fix(agents): List a child's last result from its newest finished Turn - #4173

Merged
dcramer merged 10 commits into
mainfrom
fix/child-agent-last-result
Nov 26, 2026
Merged

dcramer merged 10 commits into
mainfrom
fix/child-agent-last-result

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

listAgents lost last_result done and blocked when the legacy Agent invocation rows went away (#4043). Only failed came back, in #4057.

It now uses main's readTurnUpdate mapping. turn-update.ts exports TURN_OUTCOME_STATUSES, which both readTurnUpdate and listChildAgents use. So last_result uses the same words as <agent-result status>: done, blocked, or failed (it was completed before).

The listing reads the child's own Turn lifecycle Events: the newest turn_completed or turn_failed that is not a stop. turn_failed gives failed. A cancelled Turn is skipped, so a stop or a retry keeps the result from before it. conversationTurnFailedSql still decides the child's failed status. A person's Turn in a Thread counts like any other Turn. The read is a subquery in the existing listing query, so it adds no statement.

via @dcramer.

--

View Session [Sentry]

listAgents shows last_result completed and blocked again. They come from
the newest subagent_ended marker that the parent stores for each child,
read in the listing query. A failed last Turn still lists failed.

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

vercel Bot commented Nov 24, 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 26, 2026 3:42am UTC

Request Review

@dcramer

dcramer commented Nov 25, 2026

Copy link
Copy Markdown
Member

Isn't there a standard way to get the status of a conversation that we should be reading?

The child's own Turn lifecycle Events, the newest turn_completed or
turn_failed, give its last result in place of the parent's markers. A
person's Turn in a Thread now counts too.
@sentry-junior sentry-junior Bot changed the title fix(agents): List a child's last result from the parent's markers fix(agents): List a child's last result from its newest finished Turn Nov 25, 2026
@sentry-junior

sentry-junior Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Yes. conversationStatusSql (needs_input / working / done) is the shared Conversation status, but it can't tell completed from blocked, and a Task never reads needs_input. The standard record underneath it is the Conversation's Turn lifecycle Events, which conversationTurnFailedSql already reads for the failed rule.

I switched the PR to them in 9f812c4df. The child's newest turn_completed outcome or turn_failed now gives last_result, and nothing reads the parent's markers anymore. This also covers a person's Turn in a Thread, which the markers missed. A new blocked case in the person's-Turn test proves it.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

1 screenshot change — 1 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Unsent Answers · Desktop
Conversation Unsent Answers · Desktop
Changed

@dcramer
dcramer marked this pull request as ready for review November 26, 2026 02:46
@sentry-junior
sentry-junior Bot requested a review from dcramer November 26, 2026 02:46
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 26, 2026

@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.

…result

# Conflicts:
#	packages/junior/src/chat/agent-invocations/list.ts
#	packages/junior/tests/integration/agent-invocation-work.test.ts
#	packages/junior/tests/integration/child-conversation-loop.test.ts

@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.

Make sure this is aligned with the way we get results for any conversation in the system. And we're not doing something that's a one-off here for this specific thing

@blacksmith-sh

This comment has been minimized.

A cancelled Turn is a stop, not a result, so the last-outcome read skips
it. Only conversationTurnFailedSql decides failed.
…result

# Conflicts:
#	packages/junior/src/chat/conversations/sql/status.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 9454bff. Configure here.

The listing's outcome read now maps turn_failed to failed and skips
cancelled Turns, so a stopped or retried Turn after a failure still
lists failed. It is the only source of last_result.
sentry-junior Bot and others added 2 commits November 26, 2026 03:35
listAgents had its own completed/blocked/failed mapping of Turn outcomes.
It now uses TURN_OUTCOME_STATUSES, the map that readTurnUpdate uses for
every Conversation's agent update, and lists done, blocked, or failed
like <agent-result>.

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

dcramer commented Nov 26, 2026

Copy link
Copy Markdown
Member

Is the failing eval related

@sentry-junior

sentry-junior Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No, neither failing eval comes from this change.

  • integration / shard 2/2: one case failed, "when a child agent is no longer needed, stop it without a result turn". The renamed last_result enum and description in the listAgents tool schema changed the model request, so most recorded responses missed and the shard ran live. That case never calls listAgents. It timed out in its 10s progress hook after the model took a slower path to stopAgent. A rerun of only that job passed.
  • behavioral / shard 3/4: it hit the job's 30-minute limit and was cancelled. behavioral / report then failed because it found 3 of 4 result files. The evals that timed out in that shard are Lead, output, Google scheduling and PR-review watches, and none of them read last_result. The same shard was cancelled on other recent PRs, such as feat/list-spaces-tool. I'm rerunning only the failed behavioral jobs.

ci / required passes on c8a4a74.

@dcramer
dcramer merged commit 11b8f48 into main Nov 26, 2026
68 of 71 checks passed
@dcramer
dcramer deleted the fix/child-agent-last-result branch November 26, 2026 04:32

This branch was successfully deployed

1 active deployment
Preview – junior-docs — c8a4a74c Deployed Nov 26, 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