Skip to content
Back to skills

Agent Session Debug

ASecurity

How to inspect and recover a stuck or runaway agent session.

  • 3 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 22, 2026
developmentbashgitapi

Works with

  • api

Security analysis

A96/100
  • mediumUses curl or wget to download content

Pro shows the line behind each finding and how to fix it

Scanned September 22, 2026

npx -y skills add mattbutlerengineering/mattbutlerengineering --skill agent-session-debug --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Agent Session Debug?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Agent Session Debug
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mattbutlerengineering-agent-session-debug/badge)](https://www.skillsdirectory.com/skills/mattbutlerengineering-agent-session-debug)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Skill: agent-session-debug

How to inspect and recover a stuck or runaway agent session.

## Problem Patterns

1. Session stuck in RUNNING state indefinitely
2. Session exceeded maxBudgetUsd but didn't stop
3. Worktree left in corrupted state
4. PR created but session never completed

## Debug Workflow

### Step 1: Inspect Session State

```bash
# Get session details
curl -s http://localhost:3003/v1/sessions/<sessionId> | jq .
# Check session events
curl -s http://localhost:3003/v1/sessions/<sessionId>/events -H "Accept: text/event-stream"
```

### Step 2: Check Worktree Health

```bash
# List active worktrees
git worktree list
# Check for corrupted worktrees
ls -la /tmp/agent-worktrees/<sessionId>/ 2>&1
```

### Step 3: Kill Switch Procedure

```bash
# Cancel the session via API
curl -s -X DELETE http://localhost:3003/v1/sessions/<sessionId>
# Manually clean up worktree if needed
git worktree remove /tmp/agent-worktrees/<sessionId> --force
```

### Step 4: Langfuse Trace Correlation

```bash
# Find trace ID from session events
# Check Langfuse dashboard for trace <sessionId>
# Compare token usage and tool calls
```

## Prevention

- Monitor sessions exceeding 80% of maxBudgetUsd
- Set up alerting on RUNNING sessions > 30 minutes
- Validate worktree path exists before each turn

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.