Debug External Agent E2E Failures
Diagnose external agent bugs using captured artifacts from the E2E test suite. Artifacts are written to e2e/artifacts/ locally or downloaded from CI via GitHub Actions.
Inputs
The user provides either:
- A test run directory:
e2e/artifacts/{timestamp}/ -- triage all failures
- A specific test directory:
e2e/artifacts/{timestamp}/{TestName}-{agent}/ -- debug one test
Test Categories
This repo has two kinds of tests:
| Category |
File |
What it tests |
| Protocol tests |
e2e/kiro_test.go |
Individual agent subcommands (info, detect, get-session-id, parse-hook-event, etc.) via AgentRunner |
| Lifecycle tests |
e2e/kiro_lifecycle_test.go |
Full workflows: prompt execution → git commit → checkpoint creation, using entire CLI + agent CLI |
Protocol tests run against the agent binary directly. Lifecycle tests require both the entire CLI and the agent's underlying CLI (e.g., kiro-cli-chat).
Artifact Layout
e2e/artifacts/{timestamp}/
├── entire-version.txt # CLI version under test
└── {TestName}-{agent}/ # e.g., TestLifecycle_SinglePromptManualCommit-kiro
├── PASS or FAIL # Status marker
├── console.log # Full operation transcript
├── pane.txt # Tmux pane capture (interactive session tests only)
├── git-log.txt # git log --decorate --graph --all
├── git-tree.txt # ls-tree HEAD + entire/checkpoints/v1 branch
├── entire-logs/entire.log # CLI structured JSON logs from .entire/logs/
├── checkpoint-metadata/ # Checkpoint + session metadata
│ └── {first-2-chars}/{remaining-10-chars}/
│ ├── metadata.json # Checkpoint-level metadata
│ └── 0/
│ └── metadata.json # Session 0 metadata
└── repo -> /tmp/... # Symlink to preserved repo (E2E_KEEP_REPOS=1 only)
Preserved Repo
When the test run was executed with E2E_KEEP_REPOS=1, each test's artifact directory contains a repo symlink pointing to the preserved temporary git repository. This is the actual repo the test operated on -- you can inspect it directly.
Navigate via the symlink (e.g., {artifact-dir}/repo/) rather than resolving the /tmp/... path. The symlink lives inside the artifact directory so permissions and paths stay consistent.
The preserved repo contains:
- Full git history with all branches (main,
entire/checkpoints/v1)
- The
.entire/ directory with CLI state, config, and raw logs
- All files the agent created or modified, in their final state
This is the most powerful debugging tool -- you can run git log, git diff, git show, inspect .entire/ internals, and see exactly what the CLI left behind.
Debugging Workflow
1. Triage (if given a run directory)
List the test subdirectories and check for FAIL markers. Read the Go test output or console.log files to identify failures and their error messages.
2. Read console.log (most important)
Full transcript of every operation:
> kiro-cli-chat chat --no-interactive ... -- agent prompts with stdout/stderr
> git add/commit/... -- git commands
> send: ... -- interactive session inputs (tmux-based tests)
This tells you what happened chronologically.
3. Read test source code
Find the failing test in e2e/kiro_lifecycle_test.go (lifecycle tests) or e2e/kiro_test.go (protocol tests). Understand what the test expected vs what console.log shows actually happened.
Key test infrastructure to understand:
testutil.ForEachAgent() -- runs the test for each registered agent with timeout
testutil.SetupRepo() -- creates temp git repo, runs entire enable, sets up artifact capture
s.RunPrompt() -- sends a prompt to the agent and captures output
testutil.WaitForCheckpoint() -- polls until checkpoint branch advances
testutil.CaptureArtifacts() -- called during t.Cleanup(), writes all artifacts
4. Diagnose the issue
Cross-reference console.log (what happened) with the test (what should have happened). Determine whether the issue is in the agent, the CLI, or the test itself:
| Symptom |
Investigation |
| Agent subcommand returns wrong output |
Protocol test: check AgentRunner invocation, compare expected vs actual JSON |
| Agent prompt fails / produces wrong files |
Check console.log for agent stderr, verify agent CLI is available |
| Checkpoint not created / timeout |
Check entire-logs/entire.log for hook invocations, phase transitions, errors |
| Wrong checkpoint content |
Check git-tree.txt for checkpoint branch files, checkpoint-metadata/ for session info |
| Hooks didn't fire |
Check entire-logs/entire.log for missing hook entries (session-start, user-prompt-submit, stop, post-commit) |
| Detection fails |
Check agent detect subcommand output, verify expected files exist in repo |
| Session ID wrong |
Check get-session-id output, verify .entire/ session state |
| Attribution issues |
Check checkpoint-metadata/ for files_touched, session metadata for attribution data |
| Strategy mismatch |
Check entire-logs/entire.log for strategy field, verify auto-commit vs manual-commit behavior |
| Interactive session hangs |
Check pane.txt for tmux capture, look for agent waiting on input |
5. Deep dive files
- console.log: Chronological transcript of all operations. Most important file for understanding what happened.
- pane.txt: Tmux pane capture for interactive session tests. Shows the terminal state at artifact capture time.
- entire-logs/entire.log: Structured JSON logs -- hook lifecycle, session phases (
active -> idle -> ended), warnings, errors. Key fields: component, hook, strategy, session_id.
- git-log.txt: Commit graph showing main branch,
entire/checkpoints/v1, checkpoint initialization.
- git-tree.txt: Files at HEAD vs checkpoint branch (separated by
--- entire/checkpoints/v1 ---).
- checkpoint-metadata/:
metadata.json has checkpoint_id, strategy, files_touched, token_usage, and sessions array. Session subdirs have per-session details including agent, transcript_path, and initial_attribution.
6. Report findings
Identify whether the issue is in:
- Agent binary (protocol compliance, subcommand output, detection logic)
- Agent CLI (kiro-cli-chat behavior, prompt execution, file creation)
- Entire CLI hooks (prepare-commit-msg, commit-msg, post-commit)
- Session management (phase transitions, session tracking, session IDs)
- Checkpoint creation (branch management, metadata writing, content hash)
- Attribution (file tracking, prompt correlation, transcript capture)
- Test harness (testutil assertions, timing, environment setup)
1---2name: e2e-debug3description: Debug External Agent E2E Failures4---5# Debug External Agent E2E Failures67Diagnose external agent bugs using captured artifacts from the E2E test suite. Artifacts are written to `e2e/artifacts/` locally or downloaded from CI via GitHub Actions.89## Inputs1011The user provides either:12- **A test run directory:** `e2e/artifacts/{timestamp}/` -- triage all failures13- **A specific test directory:** `e2e/artifacts/{timestamp}/{TestName}-{agent}/` -- debug one test1415## Test Categories1617This repo has two kinds of tests:1819| Category | File | What it tests |20|----------|------|---------------|21| **Protocol tests** | `e2e/kiro_test.go` | Individual agent subcommands (`info`, `detect`, `get-session-id`, `parse-hook-event`, etc.) via `AgentRunner` |22| **Lifecycle tests** | `e2e/kiro_lifecycle_test.go` | Full workflows: prompt execution → git commit → checkpoint creation, using `entire` CLI + agent CLI |2324Protocol tests run against the agent binary directly. Lifecycle tests require both the `entire` CLI and the agent's underlying CLI (e.g., `kiro-cli-chat`).2526## Artifact Layout2728```29e2e/artifacts/{timestamp}/30├── entire-version.txt # CLI version under test31└── {TestName}-{agent}/ # e.g., TestLifecycle_SinglePromptManualCommit-kiro32 ├── PASS or FAIL # Status marker33 ├── console.log # Full operation transcript34 ├── pane.txt # Tmux pane capture (interactive session tests only)35 ├── git-log.txt # git log --decorate --graph --all36 ├── git-tree.txt # ls-tree HEAD + entire/checkpoints/v1 branch37 ├── entire-logs/entire.log # CLI structured JSON logs from .entire/logs/38 ├── checkpoint-metadata/ # Checkpoint + session metadata39 │ └── {first-2-chars}/{remaining-10-chars}/40 │ ├── metadata.json # Checkpoint-level metadata41 │ └── 0/42 │ └── metadata.json # Session 0 metadata43 └── repo -> /tmp/... # Symlink to preserved repo (E2E_KEEP_REPOS=1 only)44```4546## Preserved Repo4748When the test run was executed with `E2E_KEEP_REPOS=1`, each test's artifact directory contains a `repo` symlink pointing to the preserved temporary git repository. This is the actual repo the test operated on -- you can inspect it directly.4950**Navigate via the symlink** (e.g., `{artifact-dir}/repo/`) rather than resolving the `/tmp/...` path. The symlink lives inside the artifact directory so permissions and paths stay consistent.5152The preserved repo contains:53- Full git history with all branches (main, `entire/checkpoints/v1`)54- The `.entire/` directory with CLI state, config, and raw logs55- All files the agent created or modified, in their final state5657This is the most powerful debugging tool -- you can run `git log`, `git diff`, `git show`, inspect `.entire/` internals, and see exactly what the CLI left behind.5859## Debugging Workflow6061### 1. Triage (if given a run directory)6263List the test subdirectories and check for `FAIL` markers. Read the Go test output or `console.log` files to identify failures and their error messages.6465### 2. Read console.log (most important)6667Full transcript of every operation:68- `> kiro-cli-chat chat --no-interactive ...` -- agent prompts with stdout/stderr69- `> git add/commit/...` -- git commands70- `> send: ...` -- interactive session inputs (tmux-based tests)7172This tells you what happened chronologically.7374### 3. Read test source code7576Find the failing test in `e2e/kiro_lifecycle_test.go` (lifecycle tests) or `e2e/kiro_test.go` (protocol tests). Understand what the test expected vs what console.log shows actually happened.7778Key test infrastructure to understand:79- `testutil.ForEachAgent()` -- runs the test for each registered agent with timeout80- `testutil.SetupRepo()` -- creates temp git repo, runs `entire enable`, sets up artifact capture81- `s.RunPrompt()` -- sends a prompt to the agent and captures output82- `testutil.WaitForCheckpoint()` -- polls until checkpoint branch advances83- `testutil.CaptureArtifacts()` -- called during t.Cleanup(), writes all artifacts8485### 4. Diagnose the issue8687Cross-reference console.log (what happened) with the test (what should have happened). Determine whether the issue is in the agent, the CLI, or the test itself:8889| Symptom | Investigation |90|---------|---------------|91| Agent subcommand returns wrong output | Protocol test: check `AgentRunner` invocation, compare expected vs actual JSON |92| Agent prompt fails / produces wrong files | Check `console.log` for agent stderr, verify agent CLI is available |93| Checkpoint not created / timeout | Check `entire-logs/entire.log` for hook invocations, phase transitions, errors |94| Wrong checkpoint content | Check `git-tree.txt` for checkpoint branch files, `checkpoint-metadata/` for session info |95| Hooks didn't fire | Check `entire-logs/entire.log` for missing hook entries (session-start, user-prompt-submit, stop, post-commit) |96| Detection fails | Check agent `detect` subcommand output, verify expected files exist in repo |97| Session ID wrong | Check `get-session-id` output, verify `.entire/` session state |98| Attribution issues | Check `checkpoint-metadata/` for `files_touched`, session metadata for attribution data |99| Strategy mismatch | Check `entire-logs/entire.log` for `strategy` field, verify auto-commit vs manual-commit behavior |100| Interactive session hangs | Check `pane.txt` for tmux capture, look for agent waiting on input |101102### 5. Deep dive files103104- **console.log**: Chronological transcript of all operations. Most important file for understanding what happened.105- **pane.txt**: Tmux pane capture for interactive session tests. Shows the terminal state at artifact capture time.106- **entire-logs/entire.log**: Structured JSON logs -- hook lifecycle, session phases (`active` -> `idle` -> `ended`), warnings, errors. Key fields: `component`, `hook`, `strategy`, `session_id`.107- **git-log.txt**: Commit graph showing main branch, `entire/checkpoints/v1`, checkpoint initialization.108- **git-tree.txt**: Files at HEAD vs checkpoint branch (separated by `--- entire/checkpoints/v1 ---`).109- **checkpoint-metadata/**: `metadata.json` has `checkpoint_id`, `strategy`, `files_touched`, `token_usage`, and `sessions` array. Session subdirs have per-session details including `agent`, `transcript_path`, and `initial_attribution`.110111### 6. Report findings112113Identify whether the issue is in:114- **Agent binary** (protocol compliance, subcommand output, detection logic)115- **Agent CLI** (kiro-cli-chat behavior, prompt execution, file creation)116- **Entire CLI hooks** (prepare-commit-msg, commit-msg, post-commit)117- **Session management** (phase transitions, session tracking, session IDs)118- **Checkpoint creation** (branch management, metadata writing, content hash)119- **Attribution** (file tracking, prompt correlation, transcript capture)120- **Test harness** (testutil assertions, timing, environment setup)