Skip to main content
Glama

agent_state_load_log

Retrieve recent log entries from agent state files to review progress and maintain continuity when resuming interrupted AI agent sessions.

Instructions

Load the last num_chars characters from the log file.

Args: directory: Absolute path to the GitHub worktree or repository directory where the log file is located num_chars: The number of characters to retrieve from the end of the log

Returns: The last num_chars characters from the log, or the entire log if it's shorter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYes
num_charsYes

Implementation Reference

  • main.py:127-146 (handler)
    The agent_state_load_log tool implementation which reads the content of the .agent-log.txt file and returns the last num_chars characters.
    @mcp.tool()
    def agent_state_load_log(directory: str, num_chars: int) -> str:
        """Load the last num_chars characters from the log file.
    
        Args:
            directory: Absolute path to the GitHub worktree or repository directory
                       where the log file is located
            num_chars: The number of characters to retrieve from the end of the log
    
        Returns:
            The last num_chars characters from the log, or the entire log if it's shorter
    
        """
        log_file = get_log_file(directory)
        if not log_file.exists():
            return ""
        content = log_file.read_text(encoding="utf-8")
        if len(content) <= num_chars:
            return content
        return content[-num_chars:]

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