Skip to content

feat(mcp): thread session_id through tool_checkpoint and declare it in the input schemas #408

Description

@jphein

The mempalace-side half of the #360 deferral, flagged while implementing mempalace checkpoint in #406. techempower-org/palace-daemon#240 asks for the indexed query; this is the part that has to exist first, because today there is nothing to index.

session_id is a write-only dead slot

Every reference to it in mempalace/mcp_server.py, exhaustively:

5024:    session_id: str = "",              # tool_diary_write parameter
5125:        if session_id:                 # the only write
5126:            base_metadata["session_id"] = session_id

That is the whole surface. Which means:

  • Nothing can set it through MCP. Neither mempalace_diary_write nor mempalace_checkpoint declares session_id in its input_schema, so no MCP client can pass it. Only a direct Python call reaches the parameter.

  • Nothing reads it. mempalace/searcher.py and mempalace/cli.py contain zero references, and no tool filters on it.

  • tool_checkpoint drops it even where it could. It writes its diary entry via

    out["diary"] = tool_diary_write(
        agent_name=diary.get("agent_name", "cursor-ide"),
        entry=entry,
        topic=diary.get("topic", "session-checkpoint"),
        wing=diary.get("wing", ""),
    )

    — stopping one argument short of the session_id that tool_diary_write is already able to store. The default topic is literally "session-checkpoint", so the call site knows it is filing a session; it just has no way to say which.

The drawers tool_checkpoint files through tool_add_drawer carry no session metadata at all, so even a fully-threaded diary entry would leave the batch it summarizes unlinked.

Ask

  1. Accept session_id on tool_checkpoint and pass it to tool_diary_write.
  2. Attach it to the drawers filed in the same call, so a session's diary entry and its drawers can be recovered together rather than the summary alone.
  3. Declare it in the mempalace_checkpoint and mempalace_diary_write input schemas, so MCP clients — the actual writers in practice — can set it.

With those, mempalace checkpoint --session <id> becomes a real flag rather than one with nothing behind it, and techempower-org/palace-daemon#240 gets a populated key to index.

Worth a maintainer decision, not an assumption

Whether session_id should be free-form or validated. Every other name-shaped field on this path goes through sanitize_name/sanitize_kg_value; session_id currently goes through neither, because nothing reachable ever populated it. If it becomes an indexed key it becomes a query surface, and an unvalidated one is worth deciding on deliberately rather than inheriting by default. Happy to implement whichever way it should go.

Also unresolved: whether existing diary drawers should be backfilled. Hook-written entries have never carried the field, so a --session query would silently return nothing for any session predating this change — arguably fine, but it should be a choice rather than a surprise.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions