---
description: "Report Setup Bug: File a sanitized bug report from a failed setup run"
agdt:
  always: true
---

## User Input

```text
$ARGUMENTS
```

You **MUST** consider the user input before proceeding (if not empty).

## Purpose

Compose and file a de-duplicated bug report from the last failed setup run.
This agent is **unattended-safe** — it requires no TTY, no interactive input,
and no user prompts. It reads available context, sanitizes sensitive content,
and files the issue automatically.

## Prerequisites

- A failed setup run has occurred (invoked by `/agdt.run-setup` on failure).
- The decision log may contain entries from the fix-loop.

## Actions

### Step 1: Read Setup Report

Read the last setup report from the structured report location
(`~/.agdt/last-setup-report.json`, honoring `AGDT_SETUP_REPORT_PATH` override).
If the structured report is unavailable, fall back to captured stdout/stderr.

### Step 2: Sanitize Content

Apply the canonical value-based sanitizer to all content before composing the
issue body. Use `agentic_devtools.cli.setup.log_sanitizer.sanitize(text)`, which:

- Redacts the exact values of `AZURE_DEV_OPS_COPILOT_PAT`, `JIRA_COPILOT_PAT`,
  and `GITHUB_TOKEN` from the environment
- Matches GitHub token prefix patterns (`ghp_`, `gho_`, `ghs_`, `github_pat_`)
  in the already-redacted text
- Replaces all matches with `[REDACTED]`

This ensures the issue report uses the same redaction contract as the rest of the
setup tooling rather than a separate ad-hoc pattern set.

### Step 3: Truncate Traces

Each stack trace or error output block must be truncated to **≤ 2000 characters**
(inclusive of the truncation marker). If a trace exceeds this limit, truncate and
append:

```text
… (truncated, full trace in setup log)
```

### Step 4: Decision Log Summary Table

Read the decision log via `agdt-setup-decision-log show`. Include up to the
**last 3 entries** as a markdown table in the issue body:

| Iteration | Error class | Remedy applied | Rationale |
|-----------|-------------|----------------|-----------|

Map fields from entry data:

- `Iteration` ← entry ID
- `Error class` ← `--step` value
- `Remedy applied` ← `--decision` value
- `Rationale` ← `--rationale` value

If the log is empty, omit the table entirely.
If fewer than 3 entries exist, include all available entries.

After the table, append:

```text
Full decision log was printed to the setup console output.
```

### Step 5: File Bug Report

Set the required structured fields, then file the report:

```bash
agdt-set issue.title "agdt-setup failed: {error_class} — {short_summary}"
agdt-set issue.steps_to_reproduce "{numbered reproduction steps from setup output}"
agdt-set issue.expected_behavior "agdt-setup completes without error"
agdt-set issue.actual_behavior "{sanitized error detail from actual output}"
agdt-create-agdt-bug-issue --dedupe
```

The `--dedupe` flag ensures that if an existing open issue matches the error
signature, the report augments/upvotes rather than creating a duplicate.

## Exit Behavior

- Exit code **0** on success (issue created or augmented).
- Non-zero exit code **only** if the `agdt-create-agdt-bug-issue` CLI command
  itself fails (network error, auth failure, etc.).

## Constraints

- **No `input()` calls** — this agent must never block on user input.
- **No TTY assumptions** — must work in CI pipelines and non-interactive shells.
- **No interactive prompts** — all decisions are automatic.

## Expected Outcome

A sanitized, de-duplicated bug report is filed (or an existing one augmented)
in the agentic-devtools repository.

## Next Step

Command is complete.
