Incident Response

Performing an AI Agent Forensic Review with New Python Scripts

Examine new Python scripts designed for AI agent forensic review, parsing local SQLite chat history and execution traces for incident responders.

Published: Oct 8, 2026 • 3 min read • By FirstNews editorial desk
Source image via isc.sans.edu
Key Vulnerability Findings
  • • Jim Clausing released two Python scripts on October 8, 2026, to parse local AI assistant records.
  • • opencode-chat-replay.py targets local SQLite records to output readable session transcripts.
  • • hermes_forensic_extract.py gathers conversation records, API requests, and application logs.

On October 8, 2026, Jim Clausing published two new Python scripts designed to execute an AI agent forensic review by extracting and reconstructing activity logs from AI coding agents as detailed on isc.sans.edu. As engineering teams deploy code assistants across local developer stations, incident responders frequently encounter proprietary state databases that obscure prompt histories, reasoning traces, and API transactions. These utilities bridge that visibility gap by parsing raw local storage into structured review formats without requiring live execution runtimes.

Tracing OpenCode SQLite Artifacts

The opencode-chat-replay.py script targets the default SQLite database path located at ~/.local/share/opencode/opencode.db. Modern developer tools often fragment message content across multiple relational tables, but this parser handles both legacy separate message and part tables alongside newer consolidated session_message storage schemas. When consolidated records exist for a given session, the script prioritizes them to reconstruct full conversation flows.

Execution requires Python 3.10 or higher with zero external dependencies beyond the standard library. Operators can inventory available sessions without rendering full dialogs by executing the utility with the list flag. Target selection supports exact session IDs, unique ID prefixes, or human-readable slugs. If an operator provides an ambiguous session ID prefix, the script aborts immediately rather than guessing the intended target.

Rendering Transcripts and Structured Exports

By default, the replay tool outputs markdown reports featuring session metadata such as working directories, version numbers, cost metrics, token counts, and turn volumes. To prevent voluminous model reasoning blocks from drowning out human dialog, the script wraps reasoning sequences and tool invocations inside collapsible HTML detail blocks. Investigators can alter this behavior by passing suppression flags for reasoning or tool output.

For automated ingestion pipelines, structured JSON and JSONL exports capture session objects and turn arrays. This capability allows security analysts to reproduce native tool exports on isolated forensic workstations where the original assistant software is never installed. Tool input and output rendering defaults to a two-thousand-character truncation cap to balance legibility against log bloat, though investigators can disable this limit entirely via command-line switches.

Extracting Hermes Evidence and Telemetry

The companion hermes_forensic_extract.py utility addresses a different evidence footprint by gathering comprehensive application logs, model usage metrics, and raw API request dumps. While the opencode utility focuses tightly on conversational transcript reconstruction, the Hermes extraction script pulls wider environmental context from target system images or tarballs.

Both utilities accept time boundaries through start and end parameters formatted in standard date-time syntax, allowing analysts to isolate suspicious windows during an active compromise. Analysts can point the scripts to specific database files or whole home directories recovered from disk images. This capability aligns with defensive engineering efforts that underscore the necessity of auditing automated logic behavior across complex environments.

Operational Considerations for Forensics Teams

Forensic examiners must verify whether target workstations store agent data outside standard paths before running extraction routines. Because developer agents frequently cache tokens, API keys, and sensitive source code snippets within local SQLite states or flat files, analysts handling these evidence stores must enforce strict access controls on exported json and markdown transcripts to prevent secondary credential exposure.

When conducting an AI agent forensic review, investigators often confront encrypted storage constraints or missing state records caused by aggressive log rotation policies within the host operating system. To mitigate these gaps, engineers should establish baseline file integrity monitoring on developer workstations to capture SQLite write operations before local database compaction routines execute. Furthermore, organizations deploying local coding agents must update their standard operating procedures to include memory dumps and temporary file sweeps during initial triage stages, ensuring ephemeral context window data is preserved alongside persistent database artifacts for subsequent analysis.

Related coverage

Explore more on this topic

Frequently Asked Questions

What tools are covered by the new forensic scripts?

The scripts target artifacts left behind by developer tools including OpenCode and Hermes, complementing broader curriculum coverage of assistants like Claude Code, Codex, Gemini CLI, Cursor, Copilot, Warp, Windsurf, and Qwen Code.

What system requirements do the forensic scripts have?

Both opencode-chat-replay.py and hermes_forensic_extract.py require Python 3.10 or later and rely exclusively on the Python standard library.

Sources

Related Security Coverage