Skip to content

fix(mcp): preserve agent attribution in mempalace_checkpoint (#2023) - #2034

Merged
igorls merged 2 commits into
MemPalace:developfrom
mvalentsev:fix/2023-checkpoint-added-by
Jul 16, 2026
Merged

fix(mcp): preserve agent attribution in mempalace_checkpoint (#2023)#2034
igorls merged 2 commits into
MemPalace:developfrom
mvalentsev:fix/2023-checkpoint-added-by

Conversation

@mvalentsev

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #2023. mempalace_checkpoint hard-coded added_by="checkpoint" for every drawer it filed, so the originating agent's identity was dropped from drawer metadata (it surfaces in exports and provenance). The agent is already handed to the same call through diary.agent_name, so the information was available but discarded.

This adds an optional top-level added_by parameter to mempalace_checkpoint and resolves attribution in this order:

  1. an explicit added_by argument, otherwise
  2. the diary's agent_name (the agent filing this session), otherwise
  3. the legacy "checkpoint" label.

A blank, whitespace-only, or non-string value counts as unspecified at each step, so a malformed argument defers to the next source instead of reaching sanitization. tool_add_drawer already accepts and stores added_by, so there is no storage change; the parameter is declared in the tool's input_schema, so the tools/call dispatch admits it over both the stdio and HTTP transports.

Backward compatible: calls that supply neither an explicit added_by nor a diary agent_name keep the checkpoint label. The stored value is verbatim (matching every other added_by writer); the diary index continues to lowercase agent_name separately for its case-insensitive reads.

How to test

uv run pytest tests/test_mcp_server.py -k checkpoint -v

Manual check over the MCP path:

  • Call mempalace_checkpoint with one item and diary.agent_name="DeepSeek", then inspect the filed drawer: added_by is DeepSeek (was checkpoint).
  • Call with an explicit added_by="alice": the drawer records alice regardless of the diary.
  • Call with neither: the drawer records checkpoint.

Checklist

  • Tests pass (python -m pytest tests/ -v)
  • No hardcoded paths
  • Linter passes (ruff check .)

mvalentsev and others added 2 commits July 16, 2026 17:27
…ce#2023)

mempalace_checkpoint hard-coded added_by="checkpoint" for every drawer,
dropping the filing agent's identity even though it arrives in the same
call via diary.agent_name. Add an optional top-level added_by parameter
and resolve attribution as explicit > diary agent_name > "checkpoint";
blank/whitespace/non-string values defer to the next source. The value
is declared in the tool schema so tools/call admits it on both stdio and
HTTP transports.

Fixes MemPalace#2023

Co-Authored-By: epinethrone <172391900+epinethrone@users.noreply.github.com>
The new real-Chroma checkpoint test dropped its create-time client with a
bare del, leaving the per-path SharedSystemClient's SQLite/HNSW handles
open on Windows (MemPalace#1128). Close both clients so the temp palace is released,
matching the conftest fixture's close-not-del pattern.
@mvalentsev
mvalentsev marked this pull request as ready for review July 16, 2026 13:25
@igorls
igorls merged commit 67c90c3 into MemPalace:develop Jul 16, 2026
8 checks passed
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.

mempalace_checkpoint loses drawer author attribution

2 participants