Repository navigation
Python: Replace MCP prompt catalog on refresh - #9121
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
Conversation
A complete prompts/list snapshot now replaces previously loaded prompt functions instead of only appending unseen names, so removed prompts are dropped, an empty snapshot clears prompts, and changed descriptions or arguments are refreshed. MCP tools and user-added functions are preserved, unchanged prompt functions are reused, and a failed page request keeps the previous catalog. Fixes microsoft#9115 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Progressive disclosure can retain load state for a different remote prompt sharing the same normalized name.
Review effort: Balanced
Findings: 1
What changed in this PR
Refreshes MCP prompts as a complete catalog while preserving unrelated functions and unchanged prompts.
Changes:
- Atomically replaces prompts after successful pagination.
- Adds coverage for replacement, clearing, and pagination failures.
| File | Description |
|---|---|
python/packages/core/agent_framework/_mcp.py |
Implements prompt catalog refresh and reuse. |
python/packages/core/tests/core/test_mcp.py |
Tests prompt refresh scenarios. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
@microsoft-github-policy-service agree |
|
Anshuman Prakash (@Anshuman-Prakash) The current refresh diff still computes removed prompts by comparing |
Track prompts reused with the same remote name during refresh and clear progressive-load state for every other previously loaded prompt, so a replacement that normalizes to the same local name (a/b -> a-b) starts unloaded. Mirrors the tool refresh logic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Eduard van Valkenburg (@eavanvalkenburg) Thanks, good catch. Fixed in 4bb3ad9: the removed-prompt cleanup now compares stable remote identity instead of normalized names. Only prompts reused with a matching remote name keep their progressive-load state, the same way the tool refresh works. I added a collision regression test for |
Track prompts that keep the same remote identity separately from prompts whose FunctionTool object is reused, so a prompt rebuilt for a changed description or arguments keeps its progressive-load state after refresh. Adds a changed-metadata regression test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Motivation & Context
MCPTool._load_prompts_lockedrefreshed prompts append-only, so after aprompts/listrefresh (list-changed notification or subscription) prompts removed by the server stayed exposed, an empty snapshot did not clear prompts, and changed descriptions/arguments stayed stale.Description & Review Guide
prompts/listfetch (all pages) is now treated as the current prompt catalog and swapped into_functionsin one step, mirroring how_load_tools_lockedrefreshes tools._is_mcp_prompt_functionhelper (has an MCP remote name and is not marked as a tool), and the reuse rule for unchanged prompts.Tests added: removed/changed/kept prompts with pagination while preserving tools and custom functions, empty snapshot clearing prompts, and failed pagination keeping the previous catalog.
Related Issue
Fixes #9115
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.🤖 Generated with Claude Code