Skip to main content
Glama

Configure Memory Optimization

configure_memory_optimization

Configure auto-optimization settings for memory management, including size, entry, and time thresholds to control optimization behavior.

Instructions

Configure memory optimization settings for auto-optimization behavior.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_fileNo
auto_optimizeNo
size_thresholdNo
entry_thresholdNo
time_threshold_daysNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that executes the tool logic: reads the memory file's frontmatter, updates the specified optimization settings (auto_optimize, size_threshold, entry_threshold, time_threshold_days), writes back with backup, and returns confirmation.
    def configure_memory_optimization(
        memory_file: Annotated[Optional[str], "Path to memory file to configure"] = None,
        auto_optimize: Annotated[Optional[bool], "Enable/disable auto-optimization"] = None,
        size_threshold: Annotated[Optional[int], "Size threshold in bytes"] = None,
        entry_threshold: Annotated[Optional[int], "Entry count threshold"] = None,
        time_threshold_days: Annotated[Optional[int], "Time threshold in days"] = None,
    ) -> str:
        """Configure memory optimization settings."""
        if read_only:
            return "Error: Server is running in read-only mode"
    
        try:
            # Determine which file to configure
            if memory_file:
                file_path = Path(memory_file)
                if not file_path.exists():
                    return f"Error: Memory file not found: {memory_file}"
            else:
                # Use default user memory file
                user_memory_path = instruction_manager.get_memory_file_path()
                if not user_memory_path.exists():
                    return "Error: No user memory file found to configure"
                file_path = user_memory_path
    
            # Read current frontmatter
            from ..simple_file_ops import parse_frontmatter_file, write_frontmatter_file
    
            frontmatter, content = parse_frontmatter_file(file_path)
    
            # Update settings
            updated_settings = []
            if auto_optimize is not None:
                frontmatter["autoOptimize"] = auto_optimize
                updated_settings.append(f"auto_optimize: {auto_optimize}")
    
            if size_threshold is not None:
                frontmatter["sizeThreshold"] = size_threshold
                updated_settings.append(f"size_threshold: {size_threshold:,} bytes")
    
            if entry_threshold is not None:
                frontmatter["entryThreshold"] = entry_threshold
                updated_settings.append(f"entry_threshold: {entry_threshold}")
    
            if time_threshold_days is not None:
                frontmatter["timeThreshold"] = time_threshold_days
                updated_settings.append(f"time_threshold: {time_threshold_days} days")
    
            if not updated_settings:
                return "No settings provided to update. Available options: auto_optimize, size_threshold, entry_threshold, time_threshold_days"
    
            # Write updated frontmatter
            success = write_frontmatter_file(file_path, frontmatter, content, create_backup=True)
    
            if success:
                message = "✅ Memory optimization settings updated:\n"
                for setting in updated_settings:
                    message += f"• {setting}\n"
                message += f"\n💾 Backup created for safety"
                return message
            else:
                return "❌ Failed to update memory optimization settings"
    
        except Exception as e:
            return f"Error configuring memory optimization: {str(e)}"
  • Registers the 'configure_memory_optimization' tool with the FastMCP app inside the register_memory_tools function, defining name, description, parameters schema, and metadata.
    @app.tool(
        name="configure_memory_optimization",
        description="Configure memory optimization settings for auto-optimization behavior.",
        tags={"public", "memory"},
        annotations={
            "idempotentHint": False,
            "readOnlyHint": False,
            "title": "Configure Memory Optimization",
            "parameters": {
                "memory_file": "Optional path to specific memory file. If not provided, will configure the user's main memory file.",
                "auto_optimize": "Enable or disable automatic optimization. True/False.",
                "size_threshold": "File size threshold in bytes for triggering optimization.",
                "entry_threshold": "Number of new entries to trigger optimization.",
                "time_threshold_days": "Number of days between optimizations.",
            },
            "returns": "Returns confirmation of updated settings.",
        },
        meta={
            "category": "memory",
        },
    )
  • Defines the input parameters schema and return description for the tool in the @app.tool annotations.
    annotations={
        "idempotentHint": False,
        "readOnlyHint": False,
        "title": "Configure Memory Optimization",
        "parameters": {
            "memory_file": "Optional path to specific memory file. If not provided, will configure the user's main memory file.",
            "auto_optimize": "Enable or disable automatic optimization. True/False.",
            "size_threshold": "File size threshold in bytes for triggering optimization.",
            "entry_threshold": "Number of new entries to trigger optimization.",
            "time_threshold_days": "Number of days between optimizations.",
        },
        "returns": "Returns confirmation of updated settings.",
    },
Behavior2/5

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

Annotations indicate this is not read-only (readOnlyHint=false) and not idempotent (idempotentHint=false), implying it's a mutable operation. The description confirms it's a configuration action but adds no behavioral context beyond this—no information about permissions needed, side effects, rate limits, or what 'configure' entails operationally. With annotations providing basic safety hints, the description carries some burden but adds minimal value.

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?

The description is a single, efficient sentence that front-loads the core purpose. There's no wasted verbiage or redundancy—it directly states what the tool does without unnecessary elaboration.

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

Completeness3/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 (which reduces need to describe returns), 5 parameters with 0% schema coverage, and annotations covering basic mutability hints, the description is minimally adequate. However, it lacks parameter explanations and usage context, leaving gaps in understanding how to effectively invoke this configuration tool.

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

Parameters2/5

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

Schema description coverage is 0%, so parameters are undocumented in the schema. The description mentions 'auto-optimization behavior' but doesn't explain any of the 5 parameters (e.g., what 'memory_file', 'size_threshold', or 'time_threshold_days' mean). This leaves the agent guessing about parameter purposes and interactions, failing to compensate for the schema gap.

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

Purpose4/5

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

The description clearly states the action ('configure') and resource ('memory optimization settings'), specifying it's for 'auto-optimization behavior'. This distinguishes it from sibling tools like 'optimize_memory' (which likely performs optimization) and 'memory_stats' (which likely reports statistics). However, it doesn't explicitly contrast with these siblings in the description text itself.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'optimize_memory' or 'memory_stats'. It doesn't mention prerequisites, typical use cases, or exclusions. The agent must infer usage from the tool name and parameters alone.

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/NiclasOlofsson/mode-manager-mcp'

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