Repository navigation
fix(agent-runtime): drop tool results orphaned by skipped delegate assistants - #1937
Merged
Merged
Conversation
…sistants Degraded delegate context skipped failed assistants but only stripped a leading prefix of tool results. A kept message in front of that result left the provider an unmatched tool result. Filter the suffix with the same orphan rule as compaction tails, and leave tool calls on retained assistants in place.
This branch was previously deployed
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 free
to 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.
Fixes #1936
What
After assembling the suffix,
degradedDelegateMessagesnow runs it throughpruneOrphanToolResults(exported fromcompaction-tail.ts, unchanged), so any tool result whose call is not on a retained assistant is dropped. The existing leading-result shift stays for the budget cut.Why
Failed, aborted, deferred, and empty assistants are skipped while the walk continues, so their tool results could remain between kept messages without the call. Providers reject such a context. The retained tail already applies this rule.
How tested
subagent-context.test.ts: a result orphaned by a skipped error assistant between kept messages is dropped (fails on unmodifiedmain), and a retained assistant keeps its tool call when the result is cut.packages/agent-runtime: full vitest 106 files / 1494 tests pass;tsc --noEmitclean;pnpm lint:biomeandscripts/check-architecture.mjspass.Scope
subagent-context.ts(one call),compaction-tail.ts(export only), and the test. No behavior change for normal paired calls and results.