Skip to main content
Glama
marerem

longmem

enrich_solution

Add new context to a saved solution to refine it with reusable insights. Use after follow-up clarifications to improve reusability across projects.

Instructions

Append new context to an already-saved solution.

Call this when a conversation reveals additional details AFTER a solution was already saved — for example, a follow-up clarification that makes the solution more reusable across projects.

This is NOT for failures (use add_edge_case for those). This is for enrichment: new facts, patterns, or context that improve the answer.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entry_idYesThe id returned by save_solution, confirm_solution, or search_similar.
contextYesNew information that refines or extends the saved solution. Write as a reusable insight: state the general pattern first, then give specific details. E.g.: 'Port 4181 is used when 4180 is already taken by another auth proxy in the same stack.'

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for enrich_solution. Receives entry_id and context, delegates to store.enrich_solution(), returns JSON with updated status or error.
    @mcp.tool()
    async def enrich_solution(
        entry_id: Annotated[
            str,
            Field(description="The id returned by save_solution, confirm_solution, or search_similar."),
        ],
        context: Annotated[
            str,
            Field(
                description=(
                    "New information that refines or extends the saved solution. "
                    "Write as a reusable insight: state the general pattern first, "
                    "then give specific details. E.g.: 'Port 4181 is used when 4180 "
                    "is already taken by another auth proxy in the same stack.'"
                )
            ),
        ],
    ) -> str:
        """
        Append new context to an already-saved solution.
    
        Call this when a conversation reveals additional details AFTER a solution
        was already saved — for example, a follow-up clarification that makes the
        solution more reusable across projects.
    
        This is NOT for failures (use add_edge_case for those). This is for
        enrichment: new facts, patterns, or context that improve the answer.
        """
        try:
            store, *_ = await _get_deps()
            try:
                await store.enrich_solution(entry_id, context)
            except ValueError as exc:
                return json.dumps({"updated": False, "error": str(exc)}, indent=2)
            return json.dumps({
                "updated": True,
                "id": entry_id,
                "message": "Solution enriched. Future retrievals will include the new context.",
            }, indent=2)
        except Exception as exc:
            return _db_error(exc)
  • Registration of enrich_solution as an MCP tool via @mcp.tool() decorator on FastMCP instance.
    # ── tool: enrich_solution ────────────────────────────────────────────────────
    @mcp.tool()
  • Input schema for enrich_solution: entry_id (str) and context (str) with Pydantic Field descriptions.
    entry_id: Annotated[
        str,
        Field(description="The id returned by save_solution, confirm_solution, or search_similar."),
    ],
    context: Annotated[
        str,
        Field(
            description=(
                "New information that refines or extends the saved solution. "
                "Write as a reusable insight: state the general pattern first, "
                "then give specific details. E.g.: 'Port 4181 is used when 4180 "
                "is already taken by another auth proxy in the same stack.'"
            )
        ),
    ],
  • Storage-layer implementation: fetches the entry by ID, appends additional_context (separated by '---'), updates the LanceDB table, and re-syncs the FTS index.
    async def enrich_solution(self, entry_id: str, additional_context: str) -> None:
        """Append new context to an existing solution's text (not a failure — a refinement)."""
        sid = self._safe_id(entry_id)
        rows = await (
            self._table.query()
            .where(f"id = '{sid}'")
            .limit(1)
            .to_list()
        )
        if not rows:
            raise ValueError(f"Entry {entry_id!r} not found")
    
        current_solution: str = rows[0].get("solution") or ""
        updated_solution = current_solution + "\n\n---\n" + additional_context
    
        await self._table.update(
            updates={"solution": updated_solution, "updated_at": _now()},
            where=f"id = '{sid}'",
        )
        if self._fts:
            await self._fts_resync(entry_id)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions 'append' which implies modification, and describes the purpose as enrichment. However, it does not disclose whether the operation is reversible, side effects, or authorization requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is concise with 4 sentences, front-loaded with the primary purpose. Every sentence adds value, and there is no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema, the description does not need to explain return values. It covers purpose, usage distinction, and basic behavior. Could mention what happens if entry_id does not exist, but overall complete for a straightforward append tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description does not add new information beyond what the input schema already provides for parameters like entry_id and context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Append new context to an already-saved solution' with a clear verb and resource. It also distinguishes from sibling 'add_edge_case' by mentioning 'This is NOT for failures (use add_edge_case for those).'

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to call: 'when a conversation reveals additional details AFTER a solution was already saved'. Also states when not to: 'This is NOT for failures (use add_edge_case for those).'

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/marerem/longmem'

If you have feedback or need assistance with the MCP directory API, please join our Discord server