?? Pre-flight Checks
?? Problem Description
Agent callers frequently pass a human-generated task name as session_id to mem_session_summary without first registering it through mem_session_start. Engram correctly returns unknown_session, but the summary call then has to be repeated without the field. This consumes an additional model turn and tool call, and the same failure pattern occurs in delegated agents because the lifecycle relationship is not machine-enforced by the MCP contract.
The current error hint is useful after failure, but prevention is cheaper than recovery. More conversational context does not help because session registration is deterministic server state.
?? Proposed Solution
Make the MCP session lifecycle agent-safe while preserving strict rejection of typos:
- Strengthen the
session_id schema description for mem_session_summary so callers are explicitly told to pass it only after a successful mem_session_start; otherwise omit it.
- Return structured recovery metadata on
unknown_session, for example an operation identifier and safe retry arguments with session_id omitted, instead of only prose.
- Consider returning an opaque registered session handle from
mem_session_start and accepting that handle in lifecycle tools so agents do not infer IDs from task names.
- Add contract tests covering primary and delegated-agent callers that attempt to summarize with an unregistered ID.
Do not silently create a session from an unknown ID by default; that could hide typos and fragment session history.
?? Affected Area
MCP Server (tools, transport)
?? Alternatives Considered
- Rely only on prompt instructions. This remains probabilistic and has already failed in primary and delegated agents.
- Automatically create every unknown session. This saves a retry but risks silent session fragmentation.
- Always omit
session_id. This prevents explicit multi-session attribution.
?? Additional Context
Observed failure:
{"error_code":"unknown_session","hint":"Start the session first, omit session_id, or retry with an existing session_id."}
The immediate retry without session_id succeeded and no data was lost. The issue is avoidable token and tool-call overhead plus repeated lifecycle misuse across agents.
?? Pre-flight Checks
status:approvedbefore a PR can be opened?? Problem Description
Agent callers frequently pass a human-generated task name as
session_idtomem_session_summarywithout first registering it throughmem_session_start. Engram correctly returnsunknown_session, but the summary call then has to be repeated without the field. This consumes an additional model turn and tool call, and the same failure pattern occurs in delegated agents because the lifecycle relationship is not machine-enforced by the MCP contract.The current error hint is useful after failure, but prevention is cheaper than recovery. More conversational context does not help because session registration is deterministic server state.
?? Proposed Solution
Make the MCP session lifecycle agent-safe while preserving strict rejection of typos:
session_idschema description formem_session_summaryso callers are explicitly told to pass it only after a successfulmem_session_start; otherwise omit it.unknown_session, for example an operation identifier and safe retry arguments withsession_idomitted, instead of only prose.mem_session_startand accepting that handle in lifecycle tools so agents do not infer IDs from task names.Do not silently create a session from an unknown ID by default; that could hide typos and fragment session history.
?? Affected Area
MCP Server (tools, transport)
?? Alternatives Considered
session_id. This prevents explicit multi-session attribution.?? Additional Context
Observed failure:
{"error_code":"unknown_session","hint":"Start the session first, omit session_id, or retry with an existing session_id."}The immediate retry without
session_idsucceeded and no data was lost. The issue is avoidable token and tool-call overhead plus repeated lifecycle misuse across agents.