Skip to content

fix(subagents): trust successful terminal results - #4635

Open
letta-integration[bot] wants to merge 2 commits into
mainfrom
bob/fix-subagent-terminal-result
Open

letta-integration[bot] wants to merge 2 commits into
mainfrom
bob/fix-subagent-terminal-result

Conversation

@letta-integration

@letta-integration letta-integration Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Summary

A subagent can recover after an intermediate stream error and still emit a successful terminal result. The parent currently keeps the earlier error, marks the task failed, and hides the completed report even though the child finished successfully.

This change makes the terminal result authoritative: a successful result clears an earlier stream error, while a failed terminal result replaces it with the terminal error. Nonzero exits, missing results, failed results, and queued receipts retain their existing behavior.

Verification

The red-first regression starts with the same parser sequence as the incident: a stream error followed by a successful terminal result whose is_error field is omitted. Before the fix, the parser retained finalError; after the fix it retains the recovered report and clears the superseded error.

The same real parser path verifies the failure boundaries without mocks: a failed terminal result replaces an earlier error, while an error with no terminal result remains a failure. Existing queued-receipt coverage remains unchanged. The full repository check also passed locally.

Breadcrumbs

AI Disclosure

AI-assisted implementation at Sarah Wooders' request; maintainer review is pending. No human-review attestation is made by the agent.

  • This pull request was written entirely by a human
  • This pull request was written with AI assistance and reviewed and edited by a human
  • I have read the AI Policy and agree to its terms

AI Tool(s) Used

Letta Code for incident investigation, repository history research, implementation, regression tests, validation, and pull-request preparation.

Human Verification

Pending maintainer review.

intent(subagent-results): recovered workers that deliver a successful terminal result must not fail because of an earlier stream error
constraint(subagent-results): terminal failures and streams without a terminal result keep their existing failure semantics

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
Comment thread src/agent/subagents/subagent-stream.ts Outdated
decision(subagent-results): classify subtype error as terminal failure because stream-json ResultMessage does not carry is_error

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants