Codex rollout forensics

From pwrdrvr/PwrAgent · View interactive version

Codex rollout forensics is an AI agent skill from the GitHub repository pwrdrvr/PwrAgent. Analyze Codex rollout/session JSONL files and PwrAgent/Codex profile data for expensive tool-output behavior, cached-token growth, context replay amplification, noisy commands, long-running command polling, and commands such as sbt/test/build/log output that polluted model context. Use when asked to

How to use this skill

Skill file

Codex Rollout Forensics

Core Rule

Do offline aggregation first. Do not dump raw rollout lines, large tool outputs, or full transcripts into the conversation. Report bounded summaries: commands, counts, chars, estimated tokens, warning/error density, turn ids, timestamps, exit codes, and polling patterns.

This skill is for human/operator forensics. Do not add product runtime code that depends on reading Codex-owned rollout/session files.

Workflow

  1. Identify the target:

~/.codex/profiles/<profile>/sessions and ~/.codex/profiles/<profile>/archived_sessions.

~/.codex/sessions and ~/.codex/archived_sessions.

  1. Run the bundled analyzer:

```bash

node .agents/skills/codex-rollout-forensics/scripts/analyze_rollout_tool_output.mjs \

--profile <profile-name> \

--thread-id <thread-id> \

--top 20

```

For a known file:

```bash

node .agents/skills/codex-rollout-forensics/scripts/analyze_rollout_tool_output.mjs \

/path/to/rollout.jsonl \

--top 20

```

Use --json when further local aggregation is needed. Save large JSON results to .local/rollout-forensics/ or another ignored disposable location and summarize them, instead of pasting them into chat.

Thread discovery first matches rollout filenames ending in -<thread-id>.jsonl.

If any match, it does not inspect other rollout contents. Otherwise it checks

only the first JSONL record within the first 64 KiB of each file for a matching

session_meta.payload.id or session_id. Mentions in transcript bodies do not

select a rollout. Supply an explicit path for renamed files with larger metadata

headers. Selected rollouts are read one JSONL record at a time; an individual

record still needs to fit in memory.

  1. Correlate with PwrAgent pricing rows when requested:

```bash

sqlite3 ~/.pwragent/profiles/<profile>/state/state.db \

"SELECT thread_id, usage_line_count, uncached_input_tokens, cached_input_tokens, output_tokens, reasoning_output_tokens, total_cost_micros FROM thread_pricing_summaries WHERE thread_id='<thread-id>';"

```

Use thread_usage_lines and thread_usage_turns for per-turn totals and observed context replay counts. Keep sqlite output narrow.

  1. Classify the problem:
  1. Report in operator language:

Interpretation Guidance

Steering Advice

When noisy long-running commands are found, recommend a steering message like:

For build/test/log commands, do not stream full output into the main thread. Write full stdout/stderr to a log file, then return only the command, exit code, failing test names, key error blocks, and a bounded tail. For long-running commands, use a monitor/sub-agent and have it summarize the log instead of polling with write_stdin in the main thread.

If lazy polling is already active, offer to inject the message or ask the user before doing so when the thread is still running.

Output Shape

Prefer a concise final summary:

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.