Skip to content
Development
Skill

/agent-session-forensics

Use when diagnosing agent session history, interrupted tool loops, missing tool results, timing bottlenecks, or subagent trace correlation.

From plugin
agent-powerups
8114 skills46 agents54 commands

Claude Code

$ npx -y skills add yeaight7/agent-powerups --skill agent-session-forensics --agent claude-code

SKILL.md

agent-session-forensics.SKILL.md
name: agent-session-forensics
description: Use when diagnosing agent session history, interrupted tool loops, missing tool results, timing bottlenecks, or subagent trace correlation.

Agent Session Forensics

When To Use

  • Agent session ended mid-tool-call or cannot resume.
  • Tool call appears in assistant turn but no corresponding result turn follows.
  • Need to correlate tool calls, tool results, and timing metadata.
  • Diagnosing slow LLM calls, duplicate user turns, or malformed results.
  • Debugging experimental MCP data-layer sessions.

Requirements / Checks

  • Locate session directory and history files before editing anything.
  • Prefer read-only inspection first.
  • Have `jq` or equivalent JSON tooling available.
  • Ask before modifying, truncating, or deleting any session or history file.

Workflow

1. **Inventory session files** — find metadata, current history, rotated previous history, and related subagent histories.

2. **Count and list last turns**:

   jq 'length' history.json                                      # total messages
   jq '.[-10:] | .[] | {role, stop_reason}' history.json        # last 10 turns
   jq '.[] | select(.role=="assistant") | .tool_calls[].id' history.json  # tool call IDs
   jq '.[] | select(.role=="user") | .tool_results[]?.tool_call_id' history.json  # results

3. **Correlate tool call IDs** — every `tool_call` in an assistant turn must have a matching `tool_result` in the immediately following user turn. Find the first gap.

4. **Check timing for slow calls**:

   jq '.[] | select(.timing) | {role, duration_ms: .timing.duration_ms}' history.json

5. **Identify failure pattern** — see table below.

6. **Repair (if approved)** — write a backup first (`cp history.json history.json.bak`), then make the smallest possible fix at the last valid correlation boundary.

Common Failure Patterns

| Symptom | Likely cause | Repair | |---|---|---| | Tool call with no result turn | Session interrupted mid-tool | Truncate after last matched pair | | Two consecutive user turns | Duplicate message insertion | Remove the duplicate | | `tool_result` with no prior `tool_call` | Corrupted or manually edited history | Remove orphan result | | Empty `content` on assistant turn | Model returned no text + no tools | Usually safe to truncate | | Session loops without progress | Missing result causes re-prompt | Inject minimal synthetic result |

Safety Constraints

  • Do not edit session JSON without backing up the original first.
  • Treat history files as sensitive: prompts, tool arguments, credentials, and file contents may appear.
  • Do not infer user intent from stale history when current user instructions conflict.
  • Do not repair by deleting broad ranges — find the last valid tool-call/result correlation boundary.

Validation / Done Criteria

  • Report the names of every session file inspected.
  • Every tool-call ID is accounted for (matched or flagged as unmatched).
  • Any proposed repair names the backup path and truncation boundary.
  • No session file is mutated without explicit user approval.

References

  • `references/history-diagnostics.md`
Read more
@yeaight7
Ships withagent-powerups

Curated power-ups for coding agents: skills, slash commands, MCP configs, hooks, AGENTS.md templates, and workflows for serious software engineering. Claude Code, Codex, Antigravity CLI, Cursor and more

8114 skills46 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
8
Star history of yeaight7/agent-powerups on GitHub, a chart by star-history.com

Other skills on agent-powerups.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills10d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc11d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react1d252k
@facebook@facebookInstall Skill

Questions about agent-session-forensics.

Which coding agents can use agent-session-forensics?
agent-session-forensics installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.