feat(mcp): add compact graph context discovery - #1516
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a56d6d8da3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: phernandez <paul@basicmachines.co>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
CI follow-through: Windows lifecycle repetition 1 failed in test_concurrent_write_high_volume with QueuePool exhaustion and the test timeout. This probe does not call build_context or use compact responses. The other two Windows repetitions and all six Linux/macOS repetitions passed on the same head. Rerunning the failed job to check the intermittent failure; no source changes made. |
Why
Graph discovery currently returns note and observation bodies before an agent chooses which notes to read. Refs #686; complements compact search in #1515.
What Changed
Adds opt-in
build_context(compact=True). JSON omits content fields while preserving graph identities, observation categories, relation targets, counts and pagination. Observation labels use categories and their permalinks point to the owning file instead of repeating source prose. Text omits note bodies and the observation section. The default response remains unchanged.Implementation Details
JSON uses Pydantic serialization exclusions at the MCP boundary, keeping API models and traversal unchanged. The existing Markdown formatter accepts the same compact flag. The manual and tool-signature contract describe the new argument.
Testing
uv run pytest test-int/mcp/test_compact_context_integration.py tests/mcp/test_tool_contracts.py tests/mcp/test_tool_build_context.py -q --no-cov: 17 passed.BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest test-int/mcp/test_compact_context_integration.py -q --no-cov: 1 passed.uv run pytest tests/mcp/test_compact_context_labels.py -q --no-cov: 1 passed; primary and related observation labels preserve owner navigation without mutating the original graph.just man-regen,just fast-check,just doctor, andgit diff --check: passed.Risks / Follow-ups
This reduces MCP output, not API/database work. Titles and graph size still contribute tokens; it is not a fixed token budget. This does not implement all proposed L0/L1/L2 tiers or change defaults, so #686 remains open. CLI exposure is a separate follow-up.