Skip to main content
Glama

agent_state_load_state

Load saved agent state from a file to resume work after interruption, using a directory path to locate the state file.

Instructions

Load the current agent state from the state file.

Args: directory: Absolute path to the GitHub worktree or repository directory where the state file is located

Returns: The current state string, or empty string if the file doesn't exist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYes

Implementation Reference

  • main.py:94-109 (handler)
    The handler function `agent_state_load_state` registers the MCP tool and reads the agent state from the `.agent-state.txt` file in the specified directory.
    @mcp.tool()
    def agent_state_load_state(directory: str) -> str:
        """Load the current agent state from the state file.
    
        Args:
            directory: Absolute path to the GitHub worktree or repository directory
                       where the state file is located
    
        Returns:
            The current state string, or empty string if the file doesn't exist
    
        """
        state_file = get_state_file(directory)
        if not state_file.exists():
            return ""
        return state_file.read_text(encoding="utf-8")

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/tianhuil/agent-state'

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