Uh oh!
There was an error while loading. Please reload this page.
fix(opencode): fail task when child turn ends with an orphaned interrupted tool - #18
Closed
PierrotAWB wants to merge 1 commit into
Closed
fix(opencode): fail task when child turn ends with an orphaned interrupted tool#18PierrotAWB wants to merge 1 commit into
PierrotAWB wants to merge 1 commit into
Conversation
…upted tool Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
The following comment was made by an LLM, it may be inaccurate: |
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes REPL-30868 (Linear — GitHub issues are disabled on this fork, so no
#issue exists to link; flagging per the bot's "let a maintainer know" instruction).Type of change
What does this PR do?
When a subagent's LLM stream dies exactly as it opens a tool call (
finish=unknown, zero input deltas),cleanup()marks the orphanedtool_useaserror+metadata.interruptedand the run loop exits cleanly (upstream anomalyco#26178 behavior, loggingWARN "loop exit with orphaned interrupted tool"). The task tool then packaged the dead child asstate="completed"with its last mid-work narration as thetask_result, so the parent agent treated truncated work as successful.Real-world impact (replohq/andytown REPL-30868): a
write-business-mdsubagent's stream was severed as it began its finalwritecall; the task returned completed with "…Let me compose the BUSINESS.md briefing.", the parent told the user brand extraction succeeded, and the file never existed — the extracted brand was invisible in Brand Studio.Fix:
runTaskinpackages/opencode/src/tool/task.tsnow inspects the child's final assistant message; if it carries an orphaned interrupted tool part (the exact predicate the run loop's WARN uses), the task fails with an error naming the severed tool and including the partial text. This works because both consumption paths already handle task failure honestly — foreground surfaces a tool error to the parent model, background injectsstate="error"— so the parent sees a real error and can re-run the task. Detection is scoped to the final message only, so a mid-turn stream retry that recovered (leaving an orphan on an earlier message) does not false-positive.How did you verify your code works?
packages/opencode/test/tool/task.test.ts: a stubbed child turn ending with an orphaned interruptedwritetool part makesexecutefail, with the error naming the tool and carrying the partial output.bun test test/tool/task.test.ts: 19 pass, 0 fail.bun run typecheck(tsgo) clean inpackages/opencode.Truncate > cleanup > deletes files older than 7 daystest intest/tool/truncation.test.tsalso fails on a clean checkout ofdev(verified locally) — pre-existing, unrelated to this change.Checklist
🤖 Generated with Claude Code