-
Notifications
You must be signed in to change notification settings - Fork 386
fix(177): Fix prompt listing across agents #178
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
Conversation
|
I haven't been able to figure out how to run tests successfully in this repo, but I think this is the fix. or close to it. I'll update when I figure out how to test it haha |
|
This seems to work, but it actually doesn't seem to be the desired behavior IMO.. because then when you go to execute a prompt in an agent that doesn't have the MCP server that's serving it, it fails. So I think we actually want to list prompts only from the current agent. |
|
Thank you for looking in to this - I've not had a chance to to myself yet - so if OK I'll ask here :) Because Prompts are delivered by Servers, and Servers are attached to Agents "list prompts" is intended to list the combined set available Prompts available to the current Agent. You can then apply a prompt. Is this behaviour currently not working? What you can't currently do (and would be useful) would be to see which Agents have prompts available. I was also in this area the other evening because I wanted to have a similar "List Tools" function - especially now that it supports dynamic tool lists, but stopped due to time! |
|
yes, the behavior you described is the behavior I'd expect. The actual behavior in the latest version is that the "list_prompts" function that is called from /prompts only and ever will list prompts from the mcp servers available to the first agent that is loaded into the agent app regardless of if you switch agents. Worse, if you try to execute a prompt that you know comes from an agent that you've switched to with So in effect, if you have multiple agents with different mcps each hosting their own prompts, there is no way in an interactive session to access any prompts other than those from mcp servers which the first agent loaded has access to. The core bug is in src/mcp_agent/core/agent_app.py in AgentApp.list_prompts and AgentApp.apply_prompt, (or the usage of those functions rather). The callers are passing in def _agent(self, agent_name: str | None) -> Agent:
if agent_name:
if agent_name not in self._agents:
raise ValueError(f"Agent '{agent_name}' not found")
return self._agents[agent_name]
return next(iter(self._agents.values()))Since I'm not sure I've fixed every case of this bug since I'm not sure how to add unit tests to this repo, or execute them. But this would be a good case for some unit tests. If helpful, I can generate a minimal reproducer when I get a chance. |
|
Thanks for diagnosing this and sending over the PR. I've updated it so the original intended behaviour works -- each agent lists the prompts from the Servers it is attached to. I've also started the process of unpicking some of the code. There's a lot more I'd like in that area such as:
|
Fixes #177