Skip to content

feat(mcp): support project override in mem_session_summary#504

Open
DanielQuero wants to merge 4 commits into
Gentleman-Programming:mainfrom
DanielQuero:feat/mcp-session-summary-project-override
Open

feat(mcp): support project override in mem_session_summary#504
DanielQuero wants to merge 4 commits into
Gentleman-Programming:mainfrom
DanielQuero:feat/mcp-session-summary-project-override

Conversation

@DanielQuero

@DanielQuero DanielQuero commented Jun 15, 2026

Copy link
Copy Markdown

🔗 Linked Issue

Closes 460


🏷️ PR Type

  • type:bug — Bug fix
  • type:feature — New feature
  • type:docs — Documentation only
  • type:refactor — Code refactoring (no behavior change)
  • type:chore — Maintenance, dependencies, tooling
  • type:breaking-change — Breaking change

📝 Summary

  • Adds support for project, project_choice_reason, and recovery_token optional parameters to the mem_session_summary MCP tool schema.
  • Refactors handleSessionSummary to use the robust resolveSaveWriteProjectWithProcessOverride helper instead of relying solely on the process CWD.
  • Enables session summaries to be correctly resolved via the active session_id or saved under an explicit project override, resolving compatibility issues with global MCP runs in Antigravity 2.0.

📂 Changes

File Change
path/to/file What changed
internal/mcp/mcp.go Added project override parameters to mem_session_summary schema and updated its handler to resolve projects using the full precedence chain.
internal/mcp/mcp_test.go Replaced schema-exclusion check with schema-inclusion checks and added new integration tests for explicit overrides and session-linked project resolution.

🧪 Test Plan

  • Unit tests pass locally: go test ./...
  • E2E tests pass locally: go test -tags e2e ./internal/server/...
  • Manually tested the affected functionality

Verified multi-project isolation in a live Antigravity IDE environment:

  1. Configured different project preferences in two separate workspaces.
  2. Saved session summaries using the compiled local test binary.
  3. Verified that the agent correctly resolved the project context and recalled the correct project-specific summary (recalling me as "Rodolfo" and "Gustavo" as an example without telling them where to store the context) without any memory leakage or drift.

🤖 Automated Checks

These run automatically and all must pass before merge:

Check What it verifies Status
Check Issue Reference PR body contains Closes #N / Fixes #N / Resolves #N
Check Issue Has status:approved Linked issue has status:approved label
Check PR Has type:* Label PR has exactly one type:* label
Unit Tests go test ./... passes
E2E Tests go test -tags e2e ./internal/server/... passes

✅ Contributor Checklist

  • I linked an approved issue above (Closes #N)
  • I added exactly one type:* label to this PR
  • I ran unit tests locally: go test ./...
  • I ran e2e tests locally: go test -tags e2e ./internal/server/...
  • Docs updated (if behavior changed)
  • Commits follow conventional commits format
  • No Co-Authored-By trailers in commits

💬 Notes for Reviewers

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced mem_session_summary to allow explicit project targeting, including project-choice details and an ambiguous-project recovery token.
  • Documentation

    • Updated mem_session_summary tool docs to reflect the revised project-resolution precedence and supported override fields.
  • Tests

    • Added/updated coverage for schema changes and verified storage/responses when using explicit project or resolving via session_id.
  • Bug Fixes

    • Improved request validation by rejecting empty/whitespace content before project resolution.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d508c27-c453-4a57-8b9a-32c479f70310

📥 Commits

Reviewing files that changed from the base of the PR and between 066b11f and 19a3d7c.

📒 Files selected for processing (1)
  • internal/mcp/mcp.go

📝 Walkthrough

Walkthrough

The mem_session_summary MCP tool is extended to accept explicit project selection parameters (project, project_choice_reason, recovery_token). The tool schema, handler logic (handleSessionSummary), supporting function documentation, tests, and external documentation are all updated to reflect the new project resolution path via resolveSaveWriteProjectWithProcessOverride.

Changes

mem_session_summary explicit project resolution

Layer / File(s) Summary
Tool schema, implementation, and helper docs
internal/mcp/mcp.go, internal/mcp/activity.go
Updates the mem_session_summary tool schema to include project, project_choice_reason, and recovery_token fields. Refactors handleSessionSummary to validate non-empty content, read explicit project/recovery arguments, compute recoverySessionID, validate tokens via ValidateAmbiguousProjectRecoveryToken, and resolve the write project via resolveSaveWriteProjectWithProcessOverride. Adds or updates documentation comments for IssueAmbiguousProjectRecoveryToken, ValidateAmbiguousProjectRecoveryToken, resolveSaveWriteProjectWithProcessOverride, resolveSaveWriteProject, and writeProjectErrorResult. Updates the ambiguous-project error hint to include mem_session_summary as a retry target.
Schema contract tests, behavioral tests, and external docs
internal/mcp/mcp_test.go, DOCS.md
Replaces TestMemSessionSummary_SchemaNoProjectField with TestMemSessionSummary_SchemaIncludesProjectField; adds TestMemSessionSummary_ExplicitProjectOverride and TestMemSessionSummary_ResolveViaSessionID to validate explicit project override and session-id-based project resolution. Updates DOCS.md to document that mem_session_summary now supports explicit project override while mem_session_end and mem_capture_passive remain cwd-only.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding project override support to the mem_session_summary MCP tool, which is the primary objective of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 88.24% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@DanielQuero DanielQuero force-pushed the feat/mcp-session-summary-project-override branch from da84019 to f0bae3e Compare June 15, 2026 15:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/mcp/mcp.go (1)

1886-1888: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Ambiguous-project hint is now stale for mem_session_summary retries.

Line 1887 now routes mem_session_summary through writeProjectErrorResult, but the shared ambiguous_project hint still tells clients to retry only mem_save/mem_save_prompt. This can misdirect automated retries away from the original tool.

Proposed fix
--- a/internal/mcp/mcp.go
+++ b/internal/mcp/mcp.go
@@
 	case "ambiguous_project":
-		envelope["hint"] = "Ask the user to choose one of available_projects, then retry mem_save or mem_save_prompt with project and project_choice_reason=user_selected_after_ambiguous_project; alternatively cd into the target repo or add repo .engram/config.json."
+		envelope["hint"] = "Ask the user to choose one of available_projects, then retry the same write tool (mem_save, mem_save_prompt, or mem_session_summary) with project and project_choice_reason=user_selected_after_ambiguous_project; alternatively cd into the target repo or add repo .engram/config.json."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/mcp/mcp.go` around lines 1886 - 1888, The ambiguous_project hint
currently only instructs clients to retry mem_save and mem_save_prompt, but
since mem_session_summary is now being routed through writeProjectErrorResult on
error, it can also trigger ambiguous project errors. Find where the
ambiguous_project hint is defined and update it to include mem_session_summary
as an additional tool that clients should retry when encountering this hint,
ensuring automated retries are not misdirected away from the original tool.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/mcp/mcp.go`:
- Around line 1886-1888: The ambiguous_project hint currently only instructs
clients to retry mem_save and mem_save_prompt, but since mem_session_summary is
now being routed through writeProjectErrorResult on error, it can also trigger
ambiguous project errors. Find where the ambiguous_project hint is defined and
update it to include mem_session_summary as an additional tool that clients
should retry when encountering this hint, ensuring automated retries are not
misdirected away from the original tool.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3b4b9404-8c31-469b-8ee2-e95812c9a9b4

📥 Commits

Reviewing files that changed from the base of the PR and between da84019 and f0bae3e.

📒 Files selected for processing (2)
  • internal/mcp/activity.go
  • internal/mcp/mcp.go

@DanielQuero DanielQuero force-pushed the feat/mcp-session-summary-project-override branch from f0bae3e to 066b11f Compare June 15, 2026 15:38
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.

Feat: Support project override in mem_session_summary for Antigravity 2.0 compatibility

1 participant