Skip to content

Coerce types for non-advertised backend tools in composite workflows#4671

Open
yrobla wants to merge 1 commit intomainfrom
issue-4287
Open

Coerce types for non-advertised backend tools in composite workflows#4671
yrobla wants to merge 1 commit intomainfrom
issue-4287

Conversation

@yrobla
Copy link
Copy Markdown
Contributor

@yrobla yrobla commented Apr 8, 2026

Summary

When backend tools are excluded from advertising via excludeAll or filter, the workflow engine could not find their InputSchema for argument type coercion. This caused string arguments (e.g. "42") to be forwarded to the backend as-is instead of being coerced to the correct type (e.g. float64(42)), resulting in backend rejection.

Root cause: ProcessPreQueriedCapabilities only returned the advertised tool list. Sessions stored only those tools, and the workflow engine used sess.Tools() for schema lookup — so hidden tools were invisible to it.

Fix:

  • ProcessPreQueriedCapabilities now returns both advertisedTools (filtered, for MCP clients) and allResolvedTools (every resolved tool regardless of filter, for internal schema lookup).
  • MultiSession gains AllTools() []vmcp.Tool, backed by the new allTools field on defaultMultiSession.
  • The per-session workflow engine is built from sess.AllTools() so it can coerce arguments for any backend tool, whether advertised or not.

Fixes #4287

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Changes

File Change

Does this introduce a user-facing change?

Special notes for reviewers

@yrobla yrobla requested a review from Copilot April 8, 2026 13:16
@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes composite workflow argument type coercion for backend tools that are not advertised to MCP clients (excluded via excludeAll / filter) by ensuring the workflow engine can still access those tools’ InputSchema.

Changes:

  • Split aggregator pre-queried capability processing into advertisedTools (client-visible) and allResolvedTools (internal schema lookup).
  • Extended MultiSession with AllTools() and stored both advertised vs all-resolved tool lists on the session.
  • Built the per-session composite workflow engine using sess.AllTools() so schema-based coercion works even for hidden tools.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/vmcp/session/types/session.go Adds AllTools() to the MultiSession interface and clarifies Tools() semantics.
pkg/vmcp/session/types/mocks/mock_session.go Updates GoMock session mock to implement AllTools().
pkg/vmcp/session/factory.go Propagates both advertised and all-resolved tool lists into constructed sessions.
pkg/vmcp/session/default_session.go Stores and exposes allTools via new AllTools() snapshot accessor.
pkg/vmcp/server/sessionmanager/factory.go Builds per-session workflow composer using sess.AllTools() for schema lookup.
pkg/vmcp/server/telemetry_integration_test.go Updates test session stub to satisfy the extended interface.
pkg/vmcp/server/session_management_integration_test.go Updates session mocks/expectations for the new method.
pkg/vmcp/aggregator/aggregator.go Updates the Aggregator interface to return both advertised and all-resolved tools.
pkg/vmcp/aggregator/default_aggregator.go Returns advertisedTools + allResolvedTools while keeping routing table complete.
pkg/vmcp/aggregator/mocks/mock_interfaces.go Updates GoMock aggregator mock for the new signature.
pkg/vmcp/aggregator/default_aggregator_test.go Adjusts tests for the updated return signature (currently ignoring new value).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 91.17647% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.90%. Comparing base (27e21d0) to head (2df1431).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/aggregator/default_aggregator.go 92.30% 1 Missing ⚠️
pkg/vmcp/server/sessionmanager/factory.go 50.00% 0 Missing and 1 partial ⚠️
pkg/vmcp/session/factory.go 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4671      +/-   ##
==========================================
+ Coverage   68.85%   68.90%   +0.05%     
==========================================
  Files         508      508              
  Lines       52604    52676      +72     
==========================================
+ Hits        36220    36299      +79     
+ Misses      13586    13574      -12     
- Partials     2798     2803       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Apr 8, 2026
When backend tools are excluded from advertising via `excludeAll` or
`filter`, the workflow engine could not find their `InputSchema` for
argument type coercion. This caused string arguments (e.g. "42") to be
forwarded to the backend as-is instead of being coerced to the correct
type (e.g. float64(42)), resulting in backend rejection.

Root cause: `ProcessPreQueriedCapabilities` only returned the advertised
tool list. Sessions stored only those tools, and the workflow engine
used `sess.Tools()` for schema lookup — so hidden tools were invisible
to it.

Fix:
- `ProcessPreQueriedCapabilities` now returns both `advertisedTools`
  (filtered, for MCP clients) and `allResolvedTools` (every resolved
  tool regardless of filter, for internal schema lookup).
- `MultiSession` gains `AllTools() []vmcp.Tool`, backed by the new
  `allTools` field on `defaultMultiSession`.
- The per-session workflow engine is built from `sess.AllTools()` so it
  can coerce arguments for any backend tool, whether advertised or not.

Fixes #4287
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Composite tool type coercion fails for non-advertised backend tools

4 participants