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
| Name | Required | Description | Default |
|---|---|---|---|
| directory | Yes | ||
| num_chars | Yes |
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:]