Skip to main content
Glama

should_reset_context

Determines when to reset Claude's conversation context by analyzing context usage, task completion, git status, and session duration to maintain effective AI assistance.

Instructions

Get intelligent recommendation on whether to reset context. Analyzes context usage, todo completion, git state, and session duration.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
working_directoryNoWorking directory for git operations. Defaults to current directory.

Implementation Reference

  • The handler logic for 'should_reset_context' which analyzes context budget, todos, and git status to recommend a reset.
    async def _should_reset_context(arguments: dict[str, Any]) -> dict:
        """Get intelligent reset recommendation."""
        working_dir = arguments.get("working_directory") or _get_working_directory()
    
        # Get context budget
        transcript_parser = TranscriptParser()
        budget = transcript_parser.get_context_budget()
        session_start = transcript_parser.get_session_start_time()
    
        # Get todos
        session_id = None
        if transcript_parser.transcript_path:
            todo_parser = TodoParser()
            session_id = todo_parser.extract_session_id_from_transcript_path(
                transcript_parser.transcript_path
            )
    
        todos = TodoParser().get_latest_todos()
        if session_id:
            todos = TodoParser().get_todos_for_session(session_id)
    
        # Get git state
        git = GitUtils(working_dir)
        git_state = git.get_state()
    
        # Calculate session duration
        duration_minutes = None
        if session_start:
            delta = datetime.now(session_start.tzinfo) - session_start
            duration_minutes = int(delta.total_seconds() / 60)
    
        # Build reasoning
        reasoning = []
        blockers = []
    
        # Context usage analysis
        if budget.status == "critical":
            reasoning.append(f"Context {budget.percentage_used}% full (critical threshold)")
        elif budget.status == "low":
            reasoning.append(f"Context {budget.percentage_used}% full (low threshold)")
        else:
            reasoning.append(f"Context {budget.percentage_used}% full (sufficient)")
    
        # Todo analysis
        all_done = len(todos.in_progress) == 0 and len(todos.pending) == 0
        if all_done and todos.total_count > 0:
            reasoning.append("All todos completed")
        elif len(todos.in_progress) > 0:
            reasoning.append(f"{len(todos.in_progress)} todos still in progress")
        if len(todos.pending) > 0:
            reasoning.append(f"{len(todos.pending)} todos pending")
    
        # Git state analysis
        if git_state.has_uncommitted_changes:
            blockers.append(f"{git_state.uncommitted_file_count} uncommitted files")
            reasoning.append(f"Uncommitted changes: {git_state.uncommitted_file_count} files")
        else:
            reasoning.append("Clean git state (no uncommitted changes)")
    
        # Duration analysis
        if duration_minutes:
            hours = duration_minutes // 60
            mins = duration_minutes % 60
            reasoning.append(f"Session duration: {hours}h {mins}m")
    
        # Decision logic
        safe_to_reset = not git_state.has_uncommitted_changes
        should_reset = False
        confidence = "low"
    
        if budget.status == "critical" and safe_to_reset:
            should_reset = True
            confidence = "high"
        elif budget.status == "low" and all_done and safe_to_reset:
            should_reset = True
            confidence = "high"
        elif budget.status == "low" and safe_to_reset:
            should_reset = True
            confidence = "medium"
        elif all_done and safe_to_reset and duration_minutes and duration_minutes > 60:
            should_reset = True
            confidence = "medium"
    
        # Generate suggested summary
        completed = [t.content for t in todos.completed]
        if completed:
            summary_items = completed[:3]
            if len(completed) > 3:
                summary_items.append(f"...and {len(completed) - 3} more")
            suggested_summary = "Completed: " + ", ".join(summary_items)
        else:
            suggested_summary = "Session work in progress"
    
        return {
            "should_reset": should_reset,
            "confidence": confidence,
            "reasoning": reasoning,
            "safe_to_reset": safe_to_reset,
            "blockers": blockers,
            "suggested_summary": suggested_summary,
        }
  • Registration and invocation point of 'should_reset_context' within the MCP server's request handling loop.
    elif name == "should_reset_context":
        result = await _should_reset_context(arguments)
Behavior2/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 of behavioral disclosure. It states the tool 'analyzes' and provides a 'recommendation', implying a read-only, non-destructive operation, but doesn't clarify output format, potential side effects, or error handling. For a tool with zero annotation coverage, this is insufficient to inform the agent adequately about its behavior.

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

Conciseness4/5

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

The description is concise and front-loaded, stating the core purpose in the first sentence. It efficiently lists analysis criteria without unnecessary elaboration. However, it could be slightly more structured by explicitly separating the recommendation output from the analysis inputs, but overall, it avoids waste and is appropriately sized.

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

Completeness2/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 multiple analysis factors) and the absence of annotations and output schema, the description is incomplete. It doesn't explain what the recommendation output looks like (e.g., boolean, score, rationale), how the analysis is performed, or any limitations. For a tool with no structured output information, this leaves significant gaps for the agent.

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 input schema has 100% description coverage, with one optional parameter ('working_directory') well-documented in the schema. The description adds no parameter-specific information beyond what the schema provides, such as how 'working_directory' influences the analysis. Given the high schema coverage, a baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 tool's purpose: 'Get intelligent recommendation on whether to reset context.' It specifies the verb ('get recommendation') and the resource ('reset context'), and mentions the analysis criteria (context usage, todo completion, git state, session duration). However, it doesn't explicitly differentiate from sibling tools like 'check_context_budget' or 'get_session_state', which might overlap in monitoring context-related metrics.

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. It mentions what the tool analyzes but doesn't specify scenarios for invocation, prerequisites, or comparisons to siblings like 'check_context_budget' or 'get_session_history'. This lack of contextual usage information leaves the agent without clear direction.

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/TimEvans/ccsession'

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