Skip to main content
Glama
coderdeep11

Claude Infinite Context

by coderdeep11

checkpoint

Save and summarize project context to persistent memory before clearing workspace, enabling continuity across sessions by merging new information with existing state.

Instructions

Save current context to Redis before running /clear. Merges new context with existing project state using LLM-based summarization.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextYesThe current work context to checkpoint (summary of recent work, decisions, files)
token_countYesCurrent token budget usage

Implementation Reference

  • Core handler function that executes the checkpoint logic: locks state, merges new context using LLM summarizer, updates Redis state, saves async history, and returns success message.
    async checkpoint(context: string, tokenCount: number): Promise<string> {
      const sessionId = this.ensureInitialized();
      const startTime = Date.now();
    
      try {
        logger.info('Starting checkpoint', { sessionId, tokenCount });
    
        // Update state with locking
        const updatedState = await this.redis.updateStateWithLock(
          sessionId,
          async (oldState) => {
            // Merge old state with new context using LLM
            const merged = await this.merger.merge(oldState, context, tokenCount);
    
            // Update token count
            merged.meta.token_budget_used = tokenCount;
    
            // Validate and clean active files
            merged.active_context.active_files = await this.filterExistingFilesWithCache(
              merged.active_context.active_files
            );
    
            return merged;
          }
        );
    
        // Save to checkpoint history (async, non-blocking)
        const duration = Date.now() - startTime;
        const historyEntry: CheckpointHistory = {
          version: updatedState.meta.version,
          timestamp: updatedState.meta.last_checkpoint,
          merge_duration_ms: duration,
          token_count: tokenCount,
          context_ratio: tokenCount / 200000, // Assuming 200k token limit
          state: updatedState,
        };
    
        // Fire and forget - don't await
        this.redis.saveCheckpointHistory(sessionId, historyEntry).catch((error) => {
          this.historyFailureCount++;
          logger.warn('Failed to save checkpoint history (non-critical)', {
            error,
            failureCount: this.historyFailureCount
          });
    
          if (this.historyFailureCount >= this.MAX_HISTORY_FAILURES) {
            logger.error('Multiple checkpoint history failures detected. Rollback may not work correctly.');
          }
        });
    
        // Refresh session lock
        await this.redis.refreshSessionLock(sessionId);
    
        logger.info('Checkpoint completed successfully', {
          version: updatedState.meta.version,
          duration,
        });
    
        return `Checkpoint saved successfully (version ${updatedState.meta.version}, ${duration}ms)`;
      } catch (error) {
        logger.error('Checkpoint failed', { error, sessionId });
        throw new Error(`Checkpoint failed: ${error}`);
      }
    }
  • src/index.ts:57-75 (registration)
    MCP tool registration in ListTools handler: defines name 'checkpoint', description, and input schema.
    {
      name: 'checkpoint',
      description:
        'Save current context to Redis before running /clear. Merges new context with existing project state using LLM-based summarization.',
      inputSchema: {
        type: 'object',
        properties: {
          context: {
            type: 'string',
            description: 'The current work context to checkpoint (summary of recent work, decisions, files)',
          },
          token_count: {
            type: 'number',
            description: 'Current token budget usage',
          },
        },
        required: ['context', 'token_count'],
      },
    },
  • Zod schema for validating checkpoint tool input parameters (context and token_count).
    export const CheckpointInputSchema = z.object({
      context: z.string(),
      token_count: z.number().nonnegative(),
    });
  • MCP CallToolRequestSchema handler dispatch for 'checkpoint': parses input, calls ProjectBrain.checkpoint, formats response.
    case 'checkpoint': {
      const input = CheckpointInputSchema.parse(args);
      const result = await this.brain.checkpoint(
        input.context,
        input.token_count
      );
      return {
        content: [{ type: 'text', text: result }],
      };
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the action ('Save'), storage location ('Redis'), and method ('Merges new context with existing project state using LLM-based summarization'), which covers key behavioral aspects. However, it lacks details on permissions, error conditions, or what happens if the merge fails.

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, well-structured sentence that efficiently conveys the tool's purpose, usage context, and method. Every word earns its place with no redundancy or unnecessary details.

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's complexity (involving Redis storage and LLM summarization), no annotations, and no output schema, the description is adequate but has gaps. It explains what the tool does but doesn't cover return values, error handling, or dependencies, which could be important for an agent to use it correctly.

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?

The schema description coverage is 100%, so the schema already documents both parameters fully. The description adds no additional meaning about the parameters beyond what the schema provides, such as format examples or usage tips. This meets the baseline for high schema coverage.

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 clearly states the specific action ('Save current context to Redis') and resource ('context'), while distinguishing it from sibling tools by mentioning '/clear' and the summarization method. It goes beyond the tool name 'checkpoint' to explain what is being checkpointed and how.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('before running /clear'), which implies it's a preparatory step for clearing operations. However, it doesn't explicitly mention when not to use it or name alternatives among the sibling tools (resume, rollback, status).

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/coderdeep11/claude-memory-mcp'

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