Skip to content

mem_session_summary silently ignores explicit project β€” ambiguous_project is unrecoverable from multi-repo cwd, while mem_save honors validated explicit selectionΒ #594

Description

@uhhexe

πŸ“‹ Pre-flight Checks

πŸ“ Bug Description

mem_session_summary intentionally omits the project field from its input schema ("auto-detect only β€” REQ-308 write-tool contract", internal/mcp/mcp.go), so an explicit project: argument is silently dropped. When the server cwd is a parent directory containing multiple git repos, the tool then fails with error_code=ambiguous_project with no recovery path: passing project does nothing, and passing project_choice_reason=user_selected_after_ambiguous_project doesn't help either because the handler never reads any of the recovery fields. The handler also passes activity=nil to writeProjectErrorResult, so unlike mem_save, the ambiguous error envelope never mints a recovery_token.

This contradicts the project's own agent instructions in two places:

  1. plugin/claude-code/scripts/post-compaction.sh explicitly tells the model: "Call mem_session_summary … Use project: '%s'" β€” an argument the Go server does not accept.
  2. The Pi wrapper already accepts an explicit project fallback for mem_session_summary (unreleased changelog entry), so the TypeScript lane and the Go MCP lane now disagree on the tool contract.

Meanwhile mem_save honors a validated explicit selection via resolveSaveWriteProjectWithProcessOverride (REQ-308) and returns project_source=explicit_override. The net effect: an agent that ends a session from a multi-repo workspace root can save observations with mem_save project=X all session long, then cannot save the session summary for the same project at all.

πŸ”„ Steps to Reproduce

  1. Create a parent dir with two git repos: mkdir -p ws/repo-a ws/repo-b && git -C ws/repo-a init && git -C ws/repo-b init
  2. Seed any known project (e.g. mem_save from a repo named my-project so it exists in the store)
  3. From cd ws, call mem_session_summary with {"content": "## Goal\n…", "project": "my-project"}
  4. Observe ambiguous_project even though a known project was named explicitly (and mem_save with the identical project argument from the same cwd succeeds)

βœ… Expected Behavior

mem_session_summary accepts the same validated explicit-project selection as mem_save: a project backed by known store context (existing project, matching session, repo config, or ambiguous-recovery choice) is honored with project_source=explicit_override; unbacked names still fail loudly (no arbitrary buckets); omitted project keeps today's auto-detect + ENGRAM_PROJECT/--project behavior.

❌ Actual Behavior

{"available_projects":["repo-a","repo-b"],"error_code":"ambiguous_project",
 "message":"Cannot determine project: ambiguous project: multiple git repos found in cwd", ...}

returned regardless of any project / project_choice_reason / recovery_token argument, and (unlike mem_save) with no recovery_token minted for this tool's own error path prior to the fix.

πŸ–₯️ Environment

  • Operating System: macOS
  • Engram Version: 1.16.3 (reproduced; code path unchanged on main @ be4b613 and v1.19.0)
  • Agent / Client: Claude Code

πŸ’‘ Additional Context

Fix is implemented and ready on uhhexe/engram branch fix/session-summary-explicit-project-main: exposes project/project_choice_reason/recovery_token on the mem_session_summary schema, routes explicit selections through resolveSaveWriteProjectWithProcessOverride (identical REQ-308 validation as mem_save), leaves omitted-project behavior byte-for-byte unchanged, and passes activity so ambiguous errors mint recovery tokens. Includes tests (explicit backed project bypasses ambiguous cwd; unbacked project fails loudly with no write; omitted project still errors; schema contract). go test ./... green. Happy to open the PR once this is approved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions