Skip to content

fix(agent-runtime): drop tool results orphaned by skipped delegate assistants - #1937

Merged
vastsa merged 2 commits into
vastsa:mainfrom
xpeng5278-web:fix/delegate-orphan-result
Oct 28, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
xpeng5278-web:fix/delegate-orphan-result

Conversation

@xpeng5278-web

Copy link
Copy Markdown
Contributor

Fixes #1936

What

After assembling the suffix, degradedDelegateMessages now runs it through pruneOrphanToolResults (exported from compaction-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 unmodified main), and a retained assistant keeps its tool call when the result is cut.
  • packages/agent-runtime: full vitest 106 files / 1494 tests pass; tsc --noEmit clean; pnpm lint:biome and scripts/check-architecture.mjs pass.

Scope

subagent-context.ts (one call), compaction-tail.ts (export only), and the test. No behavior change for normal paired calls and results.

xpeng5278-web and others added 2 commits October 27, 2026 09:33
…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.
@vastsa
vastsa merged commit c0b3c2b into vastsa:main Oct 28, 2026
6 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 42ff19c3 Deployed Oct 28, 2026 by vercel[bot]
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.

[Bug] Degraded delegate context keeps a tool result whose call was on a skipped (error/aborted) assistant

2 participants