You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
memory_lesson_save MCP tool drops sourceIds: lessons saved over MCP can never link to their source session #1657
memory_lesson_save over MCP cannot record where a lesson came from. Every lesson saved through the MCP tool ends up with "source": "manual" and "sourceIds": [], so the viewer shows "No sources recorded. This lesson was saved by hand without sourceIds…" even when the agent saving it knows exactly which session it came from.
The underlying function and the REST endpoint already support sourceIds; only the MCP surface drops it.
Where
At c6c476d:
Schema — src/mcp/tools-registry.ts#L823-L839: memory_lesson_save declares content, context, confidence, project, tags. No sourceIds, so MCP clients never see the parameter.
Handler — src/mcp/server.ts#L1133-L1148: builds the mem::lesson-save payload from those five fields plus a hard-coded source: "manual". args.sourceIds is never forwarded, so even a client that sends it anyway loses it.
Function already supports it — src/functions/lessons.ts#L99-L154: mem::lesson-save accepts sourceIds, stores it on create, and merges it into an existing lesson on reinforcement.
REST already supports it — src/triggers/api.ts#L4010: POST /agentmemory/lessons validates sourceIds via normalizeLessonSourceIds and passes it through.
Repro
Call the memory_lesson_save MCP tool with any content.
Open the lesson in the viewer (#lessons/<id>) or read the raw record: "sourceIds": [].
There is no MCP argument that changes this. The only way to link a source is the viewer's suggested curl -X POST /agentmemory/lessons with the same content, which also counts as a reinforcement (reinforcements 0→1, confidence bumped) rather than just attaching the source.
Expected
An agent saving a lesson over MCP can pass the session (or memory / observation / crystal) ids it came from, the same as REST callers.
Suggested fix
Add sourceIds to the memory_lesson_save schema in tools-registry.ts, e.g. an array of strings (or a comma-separated string, matching how tags is handled), described as "ids of the sessions, memories, observations or crystals this lesson was learned from".
In the server.ts handler, normalise it with the same normalizeLessonSourceIds used by the REST route and forward it in the mem::lesson-save payload. Return 400 on invalid ids, like REST does.
Optionally, let source stay "manual" but have the viewer show the linked sources, so a hand-saved lesson with sourceIds no longer shows the "no sources recorded" hint.
Environment
agentmemory v0.9.31 (Claude Code plugin, marketplace rohitg00/agentmemory at c6c476d), macOS.
Activity