fix: prompt Message wrapping + add detail_level=minimal to get_architecture_overview#483
Open
selika wants to merge 1 commit into
Open
fix: prompt Message wrapping + add detail_level=minimal to get_architecture_overview#483selika wants to merge 1 commit into
selika wants to merge 1 commit into
Conversation
…ecture_overview
Two independent fixes bundled because both surfaced from the same MCP
slash-command failure ('/code-review-graph:architecture_map').
1. fastmcp >=3.2 rejects raw dicts in prompt return values:
"messages[0] must be Message or str, got dict". Wrap all five prompt
templates via fastmcp.prompts.prompt.Message so the slash commands
render again. Tests updated to assert attribute access
(msg.role / msg.content.text).
2. get_architecture_overview gains detail_level="minimal". Default
"standard" output embeds every community's member list plus every
individual cross-community edge — measured at 655KB on a 2,878-node
repo (ebm-copilot), exceeding the MCP tool output token cap and
forcing fallback-to-file. Minimal mode drops member lists and
aggregates edges to one row per (source_community, target_community)
with edge_count + top edge kinds; same repo: 5.4KB (120x reduction)
while keeping the data needed to spot coupling smells.
Quality:
- 1233 tests pass; the 6 remaining failures are pre-existing
pytest-asyncio plugin issues in tests/test_main.py (unrelated).
- ruff: All checks passed.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Two independent fixes, both surfaced from the same MCP slash-command failure (
/code-review-graph:architecture_map):1. fastmcp ≥3.2 prompt Message wrapping (regression fix)
fastmcp 3.2.4 stopped accepting raw
dictmessages in prompt return values:This breaks all 5 MCP prompt templates (
review_changes,architecture_map,debug_issue,onboard_developer,pre_merge_check) since they returnlist[dict].Fix: wrap each message via
fastmcp.prompts.prompt.Messageso role is explicit and future multi-turn prompts compose naturally. Added a tiny_user()helper to keep the five templates uniform.2.
get_architecture_overviewdetail_level="minimal"(token-efficiency)The default output embeds every community's full
memberslist and every individual cross-community edge. On a 2,878-node repo (ebm-copilot— TS/Python/Bash/R, 390 files) this measured 655KB — over the MCP tool output token cap, forcing fallback-to-file and defeating the whole point of the token-efficient API.The token-efficiency preamble already tells the LLM to call
get_architecture_overview(detail_level="minimal")first, butminimalwasn't actually a supported value — so this PR finally makes the prompt's own contract work.minimalmode:{id, name, size, cohesion, dominant_language}, dropmembers(source_community, target_community)pair →{source_community (name), target_community (name), edge_count, top_kinds}Measured on ebm-copilot:
Output stays useful — the top pair
v1-route ↔ services-list(318CALLSedges) immediately surfaces the hottest coupling.Test plan
uv run pytest tests/test_prompts.py— 34 passed (updated to assertmsg.role/msg.content.text)uv run pytest tests/test_tools.py— 3 new cases for minimal mode (drops members, aggregates pairs, summary label)uv run pytest tests/test_integration_v2.py— step 9 updated for Message attribute accesstests/test_main.py::TestApplyToolFilter(the test file uses@pytest.mark.asynciobutpytest-asynciois not a dev dep — out of scope here).uvx ruff checkon changed files — clean.architecture_mapprompt now renders through fastmcp's in-processClient(verified the exact MCP path the slash command uses).ebm-copilotgraph confirms the 120× reduction.🤖 Generated with Claude Code