Skip to content

Conversation

@jerm-dro
Copy link
Contributor

Stacked on #3006 because of when I discovered this gap.

Summary

  • Fix issue where composite tool steps could not access nested fields from backend tool responses
  • Backend HTTP client now checks for StructuredContent before falling back to Content array processing (legacy behavior)
  • Add integration tests for structured content access and nested defaultResults
  • Document step output format and numeric comparison behavior
  • I slightly deviated from the solution proposed in 2994, because I felt namespacing all data behind structuredContent would be verbose/clunky. It also does not match much of the existing documentation.

Fixes #2994

Changes

Core Fix (pkg/vmcp/client/client.go):

  • Check result.StructuredContent before processing result.Content array
  • If StructuredContent is an object (map[string]any), use it directly as step output
  • Fall back to existing Content processing for text/image content

Test Helpers (test/integration/vmcp/helpers/backend.go):

  • Add StructuredHandler field to BackendTool for structured content responses
  • Add NewBackendToolWithStructuredResponse() constructor
  • Update CreateBackendServer to use mcp.NewToolResultStructuredOnly() when appropriate

Integration Tests (test/integration/vmcp/vmcp_integration_test.go):

  • TestVMCPServer_StructuredContent: Tests nested field access via {{.steps.X.output.field.nested}}
  • TestVMCPServer_DefaultResults_NestedStructure: Tests nested defaultResults fallback

Documentation:

  • docs/operator/virtualmcpcompositetooldefinition-guide.md: Added "Step Output Format" and "Numeric Values in Templates" sections
  • docs/operator/advanced-workflow-patterns.md: Added "Step Output Format" and "Numeric Comparisons" sections
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Dec 12, 2025
@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.29%. Comparing base (cbf413d) to head (53bcb9d).

Files with missing lines Patch % Lines
test/integration/vmcp/helpers/backend.go 0.00% 12 Missing ⚠️
pkg/vmcp/client/client.go 0.00% 6 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## jerm/composite-tools-default-results #3009 +/- ## ======================================================================== - Coverage 56.31% 56.29% -0.03%  ======================================================================== Files 332 332 Lines 32641 32659 +18 ======================================================================== + Hits 18383 18385 +2  - Misses 12696 12712 +16  Partials 1562 1562 

☔ 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

2 participants