Skip to main content
Glama

agentbay_memory_compact

Run memory compaction to purge expired, stale, and duplicate entries. Use dry-run mode to preview changes before applying.

Instructions

Run memory compaction: TTL expiration, stale archival, duplicate merge. Supports dry-run mode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID
dryRunNoPreview without making changes (default: false)
staleDaysNoDays without verification to consider stale (default: 60)

Implementation Reference

  • The handler function for the 'agentbay_memory_compact' tool. It accepts projectId, dryRun, and staleDays parameters, POSTs to /api/v1/projects/{projectId}/memory/compact, and returns compaction results including TTL expired, stale archived, duplicates merged, and tokens saved.
    // Tool 24: Memory Compact
    server.tool(
      'agentbay_memory_compact',
      'Run memory compaction: TTL expiration, stale archival, duplicate merge. Supports dry-run mode.',
      {
        projectId: z.string().describe('Project ID'),
        dryRun: z.boolean().optional().describe('Preview without making changes (default: false)'),
        staleDays: z.number().optional().describe('Days without verification to consider stale (default: 60)'),
      },
      async ({ projectId, dryRun, staleDays }) => {
        const data = await apiPost(`/api/v1/projects/${projectId}/memory/compact`, { dryRun, staleDays });
        if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] };
    
        const lines = [
          data.dryRun ? 'Dry run — no changes made:' : 'Compaction complete:',
          `TTL expired: ${data.ttlExpired || 0}`,
          `Stale archived: ${data.archived || 0}`,
          `Duplicates merged: ${data.merged || 0}`,
          `Tokens saved: ${data.tokensSaved?.toLocaleString() || 0}`,
        ];
        return { content: [{ type: 'text' as const, text: lines.join('\n') }] };
      }
    );
  • The schema/input validation for agentbay_memory_compact, defined with zod: projectId (string), dryRun (optional boolean), staleDays (optional number).
    // Tool 24: Memory Compact
    server.tool(
      'agentbay_memory_compact',
      'Run memory compaction: TTL expiration, stale archival, duplicate merge. Supports dry-run mode.',
      {
        projectId: z.string().describe('Project ID'),
        dryRun: z.boolean().optional().describe('Preview without making changes (default: false)'),
        staleDays: z.number().optional().describe('Days without verification to consider stale (default: 60)'),
      },
      async ({ projectId, dryRun, staleDays }) => {
  • src/index.ts:753-755 (registration)
    Registration of the 'agentbay_memory_compact' tool via server.tool() call.
    // Tool 24: Memory Compact
    server.tool(
      'agentbay_memory_compact',
Behavior3/5

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

Describes core actions (TTL expiration, stale archival, duplicate merge) and dry-run support, but no annotations exist and description does not cover side effects, permissions, or reversibility. Adequate but not detailed.

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?

Single sentence, front-loaded with core purpose, efficient and easy to parse. No extraneous information.

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?

No output schema, so description could have explained return values (e.g., summary of actions). It covers the essential purpose but omits expected output and fails to contextualize among many siblings.

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 coverage is 100% so params are already well-described. Description only adds that dry-run is supported, which schema already states. No additional semantic value beyond schema.

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?

Description states specific verb 'Run memory compaction' and lists concrete operations: TTL expiration, stale archival, duplicate merge. Clearly distinguishes from sibling memory tools like store, recall, forget, etc.

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

Usage Guidelines3/5

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

Implies usage for maintenance tasks but no explicit guidance on when to use this tool versus alternatives like memory_forget. Mentions dry-run mode, but lacks context on prerequisites or when compaction is appropriate.

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/thomasjumper/agentbay-mcp'

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