GH-4542: Collect all Flux elements in async MCP tool callbacks#6158
Open
suryateja-g13 wants to merge 2 commits into
Open
GH-4542: Collect all Flux elements in async MCP tool callbacks#6158suryateja-g13 wants to merge 2 commits into
suryateja-g13 wants to merge 2 commits into
Conversation
…Max APIs Adds the missing `REQUIRED` tool_choice constant that forces the model to call at least one tool without specifying which one, aligning with the OpenAI spec. Fixes: spring-projects#6120 Signed-off-by: Gorre Surya <suryateja.g13@gmail.com>
AsyncMcpToolMethodCallback and AsyncStatelessMcpToolMethodCallback previously called .next() on Flux return types, discarding all but the first emitted element. Tools returning Flux<T> now have all items collected and returned as separate CallToolResult content entries. Fixes: spring-projects#4542 Signed-off-by: Gorre Surya <suryateja.g13@gmail.com>
Contributor
Author
|
The failing "MCP transport integration tests" check is unrelated to this PR's changes. The failures are in This PR only changes files in |
Contributor
Author
|
Thank you for taking the time to migrate and build on this — really appreciate it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AbstractAsyncMcpToolMethodCallback.convertToCallToolResult()which was calling.next()onFluxreturn types, silently discarding all elements except the firstFlux<T>, all emitted elements are now collected and returned as separateCallToolResultcontent entriesAsyncMcpToolMethodCallback(stateful) andAsyncStatelessMcpToolMethodCallback(stateless) because both extendAbstractAsyncMcpToolMethodCallbackBefore:
Flux.just("a", "b", "c")→CallToolResultwith 1 content item ("a")After:
Flux.just("a", "b", "c")→CallToolResultwith 3 content items ("a","b","c")Fixes: #4542
Test plan
./mvnw -pl mcp/mcp-annotations test— all 1349 tests passtestMultipleFluxToolnow asserts 3 content items instead of 1testGetToolSpecificationsWithFluxHandlingnow asserts 3 content items in bothAsyncMcpToolProviderTestsandAsyncStatelessMcpToolProviderTeststestToolWithFluxReturnTypeinAsyncMcpToolProviderTestsnow asserts all 3 items