Skip to content

improvement(tools): tell the model which duplicate tool instance is which - #7079

Merged
waleedlatif1 merged 1 commit into
stagingfrom
feat/duplicate-tool-disambiguation
Aug 25, 2026
Merged

improvement(tools): tell the model which duplicate tool instance is which#7079
waleedlatif1 merged 1 commit into
stagingfrom
feat/duplicate-tool-disambiguation

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • An agent can hold two entries of the same tool bound to different resources (two Gmail accounts, two knowledge bases), but they reach the provider byte-identical — user-filled params are stripped from the schema, and only id/description/parameters go on the wire. The second instance's opaque __sim_2 alias carries no meaning, so the model picks between them arbitrarily.
  • When 2+ tools collapse to the same canonical id, each description now names what that instance is bound to: the OAuth account, knowledge base, or workflow. Single-instance tools are untouched — no prompt change, no extra query.
  • Labels are all-or-nothing per duplicate group. If any sibling fails to resolve, or two resolve to the same name, none are labelled — a half-labelled pair reads to the model as "the unlabelled one is the default", and credential.display_name has no uniqueness constraint.
  • Resolvers are workspace-scoped inside the resolver itself, so a stale id from another workspace resolves to nothing. Labels are flattened and length-capped before they enter a description.
  • Removes ProviderToolConfig.name (written in four places, read by none — every provider sends tool.id) and the unreferenced createExecutionToolSchema.

Type of Change

  • Improvement

Testing

26 new unit tests covering the emission rule, partial/duplicate-label suppression, cross-workspace omission, resolver failure, label sanitization, and run-cache reuse. Verified the guards can fail by reverting them. Full suite green: 3,930 tests, tsc clean, all 33 audits pass, lint clean.

Backwards compatibility: ProviderToolConfig is internal only — no API contract, no persistence, no client type — so removing name has no wire or stored-data impact. The new ExecutionContext cache field is optional and ignored by the snapshot serializer, so resumed runs simply re-resolve. Descriptions change only for duplicate tools.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…hich

An agent can hold two entries of the same tool bound to different resources, but
they reach a provider byte-identical: user-filled params are stripped from the
schema, and only id/description/parameters go on the wire. The second instance's
opaque `__sim_2` alias carries no meaning, so the model picks between them
arbitrarily.

When two or more tools collapse to the same canonical id, each description now
names what that instance is bound to — the OAuth account, knowledge base, or
workflow. Single-instance tools are untouched and cost no extra lookup.

Also removes ProviderToolConfig.name, which no provider ever sent, and the
unreferenced createExecutionToolSchema.
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 25, 2026 8:52pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR disambiguates duplicate agent-tool instances by appending workspace-scoped resource labels to their descriptions while leaving single-instance tools unchanged.

  • Collects credential, knowledge-base, and workflow bindings during provider-tool transformation.
  • Resolves and sanitizes distinguishing labels with run-level caching and all-or-nothing duplicate-group handling.
  • Applies labels to standard Agent and local Pi tool paths before provider identity aliasing.
  • Removes the unused ProviderToolConfig.name field and obsolete execution-schema helper.

Confidence Score: 5/5

The PR appears safe to merge; no concrete changed-code defect or security-boundary failure remains.

Duplicate labeling is conservatively suppressed when labels are incomplete or non-unique, resolution remains workspace-scoped, cache lifetime stays within one execution workspace, and tool routing continues to use provider tool identities rather than the removed name field.

Important Files Changed

Filename Overview
apps/sim/executor/utils/tool-binding-labels.ts Adds duplicate grouping, workspace-scoped label resolution, sanitization, caching, and conservative description annotation.
apps/sim/providers/tool-binding.ts Introduces weakly associated resource-binding metadata and canonical duplicate grouping without widening the provider wire shape.
apps/sim/providers/utils.ts Registers resource bindings during tool transformation and removes the unused provider-tool name field.
apps/sim/executor/handlers/agent/agent-handler.ts Annotates duplicate tools after formatting and before provider identity assignment.
apps/sim/executor/handlers/pi/local/sim-tools.ts Applies the same duplicate-binding descriptions to local Pi tools before assigning wire identities.
apps/sim/lib/knowledge/service.ts Adds a narrow, workspace-scoped, non-deleted knowledge-base name lookup.
apps/sim/executor/types.ts Adds an optional run-shared binding-label cache to execution context.
apps/sim/providers/types.ts Removes the unused ProviderToolConfig.name property while retaining id-based provider identity.
apps/sim/tools/params.ts Removes the unreferenced execution-tool schema builder.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Configured agent tools] --> B[Transform to provider tools]
  B --> C[Collect bound resource metadata]
  C --> D{Duplicate canonical IDs?}
  D -- No --> G[Assign provider identities]
  D -- Yes --> E[Resolve workspace-scoped labels]
  E --> F{All labels distinct and complete?}
  F -- No --> G
  F -- Yes --> H[Append binding descriptions]
  H --> G
  G --> I[Provider or local Pi backend]
Loading

Reviews (1): Last reviewed commit: "improvement(tools): tell the model which..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 25 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 8de7ada into staging Aug 25, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/duplicate-tool-disambiguation branch August 25, 2026 21:24
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.

1 participant