Skip to content

Conversation

@quaff
Copy link
Contributor

@quaff quaff commented Oct 30, 2025

I think febf86c introduced unnecessary complexity, this commit make the code more simple and readable.

Did I miss something? @Kehrlann

@Kehrlann
Copy link
Contributor

Kehrlann commented Oct 30, 2025

@quaff your current architecture introduces a dependency cycle, specifically in the case of sampling:

McpClient -> methods annotated with @McpSampling -> ChatClient (to do the sampling) -> ToolCallingManager -> ToolCallingResolver -> McpToolCallbackProvider -> McpClient

But since the "methods annotated with @McpSampling" do not have a declared dependency in the container (but work with some temporal coupling), sampling will fail.

Please run StreamableMcpAnnotationsWithLLMIT and observe the problem. These tests are not run in the PRs checks I think, because they need an Anthropic API key. That's why I inject the ToolCallbackResolver in the test rather than an object provider.

Note that this area is currently in flux, and this complicated code might go away (or at least be moved out)

…guration

See spring-projectsGH-4751

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
@quaff
Copy link
Contributor Author

quaff commented Oct 30, 2025

@quaff your current architecture introduces a dependency cycle, specifically in the case of sampling:

McpClient -> methods annotated with @McpSampling -> ChatClient (to do the sampling) -> ToolCallingManager -> ToolCallingResolver -> McpToolCallbackProvider -> McpClient

I force pushed commit to use ObjectProvider.stream(Predicate<Class<?>> customFilter) for breaking the dependency cycle.

Please run StreamableMcpAnnotationsWithLLMIT and observe the problem. These tests are not run in the PRs checks I think, because they need an Anthropic API key. That's why I inject the ToolCallbackResolver in the test rather than an object provider.

Sorry I can't access Anthropic in my area, could you run it to verify? @Kehrlann

@Kehrlann
Copy link
Contributor

I force pushed commit to use ObjectProvider.stream(Predicate<Class<?>> customFilter) for breaking the dependency cycle.

Yes, that's much better 👏
We're reworking tool handling and the cyclic dependency should not be a problem anymore. Let's keep this PR open until the other work has landed, and see if we still need this.

Sorry I can't access Anthropic in my area, could you run it to verify? @Kehrlann

Ah, good point. Feel free to update the test locally to use whatever model suits you best, as long as it supports tool calling.

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.

2 participants