Extract log debug

From fritzprix/libr-agent · View interactive version

Extract log debug is an AI agent skill from the GitHub repository fritzprix/libr-agent. Extract and analyze LibrAgent debug logs with pattern matching and context. Use when debugging LibrAgent issues, analyzing agent workflows, investigating tool execution problems, or extracting specific log patterns like errors, warnings, planning operations, MCP tool calls, or browser automation tra

How to use this skill

Skill file

Extract Log Debug

Extract and analyze LibrAgent debug logs for troubleshooting and analysis.

Quick Start

Extract logs using the Python script:

# Extract last 100 lines
python scripts/extract_logs.py -n 100

# Extract all errors with 5 lines of context
python scripts/extract_logs.py --pattern "[ERROR]" --context 5

# Extract planning logs
python scripts/extract_logs.py --pattern "PLANNING" -n 5000

# Save to custom file
python scripts/extract_logs.py --pattern "[WARN]" -o warnings.txt

Log File Location

LibrAgent stores logs in platform-specific directories:

(Pre-#2858 single-file libragent.log may still exist; with multiple backends,

each process has its own libragent.<pid>.log.)

The script automatically detects and uses the correct path.

Common Patterns

Error Extraction

python scripts/extract_logs.py --pattern "[ERROR]" --context 10

Component-Specific Logs

# Agent workflow logs
python scripts/extract_logs.py --pattern "agent_" -n 5000

# MCP tool execution
python scripts/extract_logs.py --pattern "MCPServiceProxy" --context 10

# Planning operations
python scripts/extract_logs.py --pattern "PLANNING" --context 5

# Browser automation
python scripts/extract_logs.py --pattern "BrowserServer" --context 10

Recent Activity

# Last 500 lines for quick check
python scripts/extract_logs.py -n 500

# Last 5000 lines for detailed analysis
python scripts/extract_logs.py -n 5000

Pattern Reference

For comprehensive list of log patterns and search strategies, see log_patterns.md.

Key pattern categories:

Debugging Workflows

1. Investigate Error

# Extract errors
python scripts/extract_logs.py --pattern "[ERROR]" --context 10 -o errors.txt

# Review errors.txt for:
# - Error message and stack trace
# - Preceding operations (context lines above)
# - Affected component (agent, MCP, builtin server)
# - Session ID for tracking

2. Analyze Agent Workflow

# Extract workflow logs
python scripts/extract_logs.py --pattern "agent_" -n 5000 -o workflow.txt

# Review workflow.txt for:
# - Session lifecycle (create, start, stop)
# - Workflow phases (Think, Act, Observe)
# - Tool execution sequences
# - Loop iterations and completion

3. Debug Tool Execution

# Extract tool logs
python scripts/extract_logs.py --pattern "call_tool" --context 10 -o tools.txt

# Review tools.txt for:
# - Tool name and arguments
# - Routing (builtin vs external)
# - Execution results or errors
# - Response structure

4. Track Session Activity

# Extract specific session logs (replace <session-id> with actual ID)
python scripts/extract_logs.py --pattern "<session-id>" --context 5 -o session.txt

# Review session.txt for:
# - Session initialization
# - Tool calls made during session
# - Workflow status changes
# - Errors specific to session

Output Format

Pattern Match Output

When using --pattern, output includes:

Example:

=== Match 1: Lines 1234-1244 ===
  1234   [DEBUG] Starting operation
  1235 > [ERROR] Failed to execute tool
  1236   Stack trace: ...
  1237   at module.rs:123

Full Line Output

Without --pattern, outputs raw log lines preserving original format.

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.