Skip to content

Fix virtual tool grouping dropping tools - #327576

Draft
bhavyaus wants to merge 2 commits into
mainfrom
dev/bhavyau/fix-virtual-tool-grouping-324113
Draft

Fix virtual tool grouping dropping tools#327576
bhavyaus wants to merge 2 commits into
mainfrom
dev/bhavyau/fix-virtual-tool-grouping-324113

Conversation

@bhavyaus

@bhavyaus bhavyaus commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix virtual tool regrouping so registered tools remain reachable throughout long agent sessions.

  • preserve tools when embeddings are unavailable, clustering produces excess singletons, or toolsets outnumber grouping slots
  • keep grouping stable across tool reordering and re-expand previously used or pending tool calls after registry changes
  • cap novel embedding-matched tools at the request hard limit
  • report missing request-toolset calls accurately instead of attributing them to user disablement
  • add regression coverage for the reported 106-tool scenario and boundary cases

Fixes #324113

Copilot AI review requested due to automatic review settings July 27, 2026 05:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes virtual-tool regrouping so tools remain reachable during long agent sessions.

Changes:

  • Adds lossless grouping fallbacks and hard-limit handling.
  • Preserves used and pending tools across regrouping.
  • Improves missing-tool telemetry and regression coverage.
Show a summary per file
File Description
virtualToolGrouping.spec.ts Tests stable ordering and called-tool expansion.
virtualToolGrouper.spec.ts Expands grouping boundary coverage.
toolDropRepro.spec.ts Reproduces tool-loss scenarios.
virtualToolGrouper.ts Recovers omitted tools and allocates grouping slots.
toolGrouping.ts Stabilizes regrouping and preserves used tools.
toolEmbeddingsComputer.ts Adds lossless embedding fallbacks.
toolCalling.tsx Revises missing-request-tool handling and telemetry.
toolCalling.spec.ts Tests missing-tool telemetry.
defaultIntentRequestHandler.spec.ts Tests pending-tool expansion.
defaultIntentRequestHandler.ts Expands pending calls before regrouping.

Review details

  • Files reviewed: 10/10 changed files
  • Comments generated: 3
  • Review effort level: Medium

Comment on lines +263 to +265
for (const nested of item.all()) {
placed.add(nested.name);
}
outcome = ToolInvocationOutcome.DisabledByUser;
throw new Error(`Tool ${props.toolCall.name} is currently disabled by the user, and cannot be called.`);
outcome = ToolInvocationOutcome.NotInRequestToolset;
throw new Error(`Tool ${props.toolCall.name} is not part of this request's toolset, so it cannot be called. It is either disabled in Configure Tools, or grouped behind an activate_* tool that has not been called yet.`);
const result = VirtualToolGrouper.deduplicateGroups(items) as Array<VirtualTool | LanguageModelToolInformation>;
expect(result).toHaveLength(1);
expect(result[0].name).toBe(dupName);
expect(VirtualToolGrouper.deduplicateGroups(items)).toHaveLength(items.length);
@bhavyaus
bhavyaus marked this pull request as draft July 27, 2026 05:31
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.

Virtual tool grouping silently drops tools mid-session; error blames the user ("currently disabled by the user")

2 participants