Skip to content

chore: conditionally disable modal state tools #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Apr 23, 2025

Helps to keep our number of tools low.

@Skn0tt Skn0tt requested a review from pavelfeldman April 23, 2025 08:30
@Skn0tt Skn0tt self-assigned this Apr 23, 2025
@@ -42,8 +42,10 @@ export function createServerWithTools(options: Options): Server {
});

server.setRequestHandler(ListToolsRequestSchema, async () => {
const modalStates = context.modalStates().map(state => state.type);
const activeTools = tools.filter(tool => !tool.clearsModalState || modalStates.includes(tool.clearsModalState));
Copy link
Member

@pavelfeldman pavelfeldman Apr 24, 2025

Choose a reason for hiding this comment

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

I am not a firm believer that the dynamic tool list is a good idea. I think it will throw LLM off. Here is my thinking:

  • If this mechanism worked, we would only list the tools that clear currently engaged states. The client would then re-build the tool prologue for the LLM and re-compile the chat. Now LLM will be presented with a chat history where it calls non-existing tools
  • An alternative, more heavyweight approach would be inlining the messages about the tools being turned off and on dynamically

Maybe there are other ways to implement this, but none of the ways I come up with improve the quality of the prompt, only adds unnecessary noise. I think dynamic tooling is not a great idea when it comes to keeping LLM sharp.

Copy link
Member Author

@Skn0tt Skn0tt Apr 24, 2025

Choose a reason for hiding this comment

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

I'm not convinced. If dynamic tools threw off the LLM, then MCP wouldn't have been designed with explicit support for dynamic tool lists, or at least it'd allow the client to announce compatibility. My guess is they explicitly added it for this usecase, also as a measure to limit the number of tools.

I think we can do two things to figure this out:

I'll do both of that and report back.

If this mechanism worked, we would only list the tools that clear currently engaged states.

Good idea!

An alternative, more heavyweight approach would be inlining the messages about the tools being turned off and on dynamically

As far as I know, LLMs are already trained specifically with tool usage in mind, and i'd imagine that turning tools on or off is part of that training. So the tool list feels like the natural place to communicate this, not the message.

@Skn0tt Skn0tt closed this Apr 28, 2025
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