Skip to content

Conversation

ribelo
Copy link

@ribelo ribelo commented Sep 12, 2025

#2554

Prior behavior dropped all assistant messages with any error flag, so Ctrl+C (AbortError) removed crucial context like read files and patches. This caused the model to ‘forget’ work after an interruption.

Change: when building provider messages, filter out assistant messages only if error exists and it is not MessageAbortedError. Aborted messages now remain in context; genuine failures (auth/output length/unknown) are still excluded. Also ensure summaries with errors are not treated as lastSummary anchors.

Includes: adjust lastSummary lookups to ignore errored summaries.

Edge cases considered: multiple interrupts, partial tool calls are marked error on parts but message retained; stopWhen short-circuits on permission rejects; compatibility with MessageV2.AbortedError schema.

It seems to help, but I don’t know if it breaks something else.

@NaikSoftware
Copy link

NaikSoftware commented Sep 12, 2025

This solution is a partial. We have a case with subagents. After interruption inside child conversation, it just finished and the main agent always thinking a delegated task was done. But for fixing this problem will need major refactoring I think

ribelo added a commit to ribelo/opencode that referenced this pull request Sep 12, 2025
When a subagent is interrupted (Ctrl+C), the Task tool was returning a successful result instead of propagating the error. This caused parent agents to incorrectly believe delegated tasks completed successfully.

Changes:
- Check result.info.error after subagent execution
- Throw an error when subagent was interrupted or errored
- Include partial output from interrupted subagents in error message
- Distinguish between AbortedError and other errors

This ensures parent agents correctly detect when delegated tasks are interrupted, fixing the edge case identified by NaikSoftware in PR sst#2563.
@ribelo
Copy link
Author

ribelo commented Sep 12, 2025

@NaikSoftware done

@rekram1-node rekram1-node requested a review from thdxr September 12, 2025 15:38
…ption state

This commit addresses two critical interruption handling issues:

1. Context preservation after interruption (fixes sst#2554):
   - Messages with AbortedError are preserved in context (already in prompt.ts)
   - filterSummarized() ignores errored summaries (message-v2.ts)
   - prune() ignores errored summaries when checking compaction (index.ts)

2. Subagent interruption propagation:
   - Task tool now checks result.info.error after subagent execution
   - Throws error when subagent was interrupted or errored
   - Includes partial output from interrupted subagents in error message
   - Parent agents correctly detect when delegated tasks are interrupted

This ensures the model remembers work done before interruption and parent agents properly handle interrupted subagent tasks.
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.

4 participants