Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions .github/meta/commit.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
<<<<<<< Updated upstream
fix: add missing `altimate_change` markers for `experimental` block in `opencode.jsonc`

The `experimental` config added in #311 was missing upstream markers,
causing the Marker Guard CI check to fail on main.
=======
fix: add try/catch and input sanitization to TUI install/create (#341)

Root cause of silent failures: `onConfirm` async callbacks had no
try/catch, so any thrown error was swallowed and no result toast shown.

Fixes:
- Wrap all install/create logic in try/catch with error toast
- Strip trailing dots from input (textarea was appending `.`)
- Strip `.git` suffix from URLs (users paste from browser)
- Trim whitespace and validate before proceeding
- "Installing..." toast now shows 60s duration with helpful text
("This may take a moment while the repo is cloned")
- Empty input shows immediate error instead of proceeding
>>>>>>> Stashed changes
fix: viewer UX improvements from 100-trace analysis

- Collapse Files Changed after 5 entries with "Show all N files" toggle
- Rename "GENS" → "LLM Calls" in header cards
- Hide Tokens card when cost is $0 (not actionable without cost context)
- Hide Cost metric card when $0.00 (wasted space)
- Add prominent error summary banner right after header metrics
- Improved dbt outcome detection: catch [PASS], [ERROR], N of M, Compilation Error
- Outcome detection rate improved from 18% → 33% across 100 real traces
- Updated doc screenshots with cleaner samples

Tested across 100 real production traces: 0 crashes, 0 JS errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ Manifest parsing, test generation, model scaffolding, incremental model detectio
### Data Visualization
Interactive charts and dashboards from SQL results. The data-viz skill generates publication-ready visualizations with automatic chart type selection based on your data.

### Local-First Tracing
Built-in observability for AI interactions — trace tool calls, token usage, and session activity locally. No external services required. View traces with `altimate trace`.
### Local-First Recap
Built-in observability for AI interactions — recap tool calls, token usage, and session activity locally. No external services required. View recaps with `altimate recap`. Features include loop detection, post-session summary, and shareable HTML exports.

### AI Teammate Training
Teach your AI teammate project-specific patterns, naming conventions, and best practices. The training system learns from examples and applies rules automatically across sessions.
Expand Down
Binary file added docs/docs/assets/images/recap/summary-full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/assets/images/recap/summary-tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 78 additions & 52 deletions docs/docs/configure/tracing.md → docs/docs/configure/recap.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
# Tracing
# Recap

Altimate Code captures detailed traces of every headless session, including LLM generations, tool calls, token usage, cost, and timing, and saves them locally as JSON files. Traces are invaluable for debugging agent behavior, optimizing cost, and understanding how the agent solves problems.
Altimate Code captures detailed recaps of every session, including LLM generations, tool calls, token usage, cost, and timing, and saves them locally as JSON files. Recaps are invaluable for debugging agent behavior, optimizing cost, and understanding how the agent solves problems.

Tracing is **enabled by default** and requires no configuration. Traces are stored locally and never leave your machine unless you configure a remote exporter.
Recap is **enabled by default** and requires no configuration. Recaps are stored locally and never leave your machine unless you configure a remote exporter.

![Recap Summary View](../assets/images/recap/summary-tab.png)

!!! note "Renamed from Tracer"
The tracer feature has been renamed to **recap**. The `trace` command still works as a backward-compatible alias (`--no-trace` is the backward-compatible flag name). New features include loop detection, post-session summary, and shareable HTML exports.

## Quick Start

```bash
# Run a prompt (trace is saved automatically)
# Run a prompt (recap is saved automatically)
altimate-code run "optimize my most expensive queries"
# → Trace saved: ~/.local/share/altimate-code/traces/abc123.json
# → Recap saved: ~/.local/share/altimate-code/traces/abc123.json

# List recent traces
altimate-code trace list
# List recent recaps
altimate-code recap list

# View a trace in the browser
altimate-code trace view abc123
# View a recap in the browser
altimate-code recap view abc123
```

## What's Captured

Each trace records the full agent session:
Each recap records the full agent session:

| Data | Description |
|------|-------------|
Expand All @@ -31,10 +36,12 @@ Each trace records the full agent session:
| **Timing** | Start/end timestamps for every span (session, generation, tool) |
| **Errors** | Error messages and status on failed tool calls or generations |
| **Metadata** | Model, provider, agent, prompt, user ID, environment, tags |
| **Loop Detection** | Automatic detection of repeated tool call patterns |
| **Post-Session Summary** | AI-generated summary of the session's key actions and outcomes |

### Data Engineering Attributes

When using SQL and dbt tools, traces automatically capture domain-specific data:
When using SQL and dbt tools, recaps automatically capture domain-specific data:

| Category | Examples |
|----------|----------|
Expand All @@ -44,7 +51,7 @@ When using SQL and dbt tools, traces automatically capture domain-specific data:
| **Data Quality** | Row counts, null percentages, freshness, anomaly detection |
| **Cost Attribution** | LLM cost + warehouse compute cost + storage delta = total cost, per user/team/project |

These attributes are purely optional. Traces are valid without them. They're populated automatically by tools that have access to warehouse metadata.
These attributes are purely optional. Recaps are valid without them. They're populated automatically by tools that have access to warehouse metadata.

## Configuration

Expand All @@ -63,12 +70,12 @@ Add to your config file (`~/.config/altimate-code/altimate-code.json` or project

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `enabled` | `boolean` | `true` | Enable or disable tracing |
| `dir` | `string` | `~/.local/share/altimate-code/traces/` | Custom directory for trace files |
| `maxFiles` | `number` | `100` | Max trace files to keep (oldest pruned automatically). Set to `0` for unlimited |
| `enabled` | `boolean` | `true` | Enable or disable recap |
| `dir` | `string` | `~/.local/share/altimate-code/traces/` | Custom directory for recap files |
| `maxFiles` | `number` | `100` | Max recap files to keep (oldest pruned automatically). Set to `0` for unlimited |
| `exporters` | `array` | `[]` | Remote HTTP exporters (see below) |

### Disabling Tracing
### Disabling Recap

```json
{
Expand All @@ -84,15 +91,15 @@ Or per-run with the `--no-trace` flag:
altimate-code run --no-trace "quick question"
```

## Viewing Traces
## Viewing Recaps

### List Traces
### List Recaps

```bash
altimate-code trace list
altimate-code recap list
```

Shows a table of recent traces with session ID, timestamp, duration, tokens, cost, tool calls, and status.
Shows a table of recent recaps with session ID, timestamp, duration, tokens, cost, tool calls, and status.

```
SESSION WHEN DURATION TOKENS COST TOOLS STATUS PROMPT
Expand All @@ -105,19 +112,34 @@ Options:

| Flag | Description |
|------|-------------|
| `-n`, `--limit` | Number of traces to show (default: 20) |
| `-n`, `--limit` | Number of recaps to show (default: 20) |

### View a Trace
### View a Recap

```bash
altimate-code trace view <session-id>
altimate-code recap view <session-id>
```

Opens a local web server with an interactive trace viewer in your browser. The viewer shows:
Opens a local web server with an interactive recap viewer in your browser.

![Recap Full View](../assets/images/recap/summary-full.png)

The viewer has 5 tabs:

- **Summary cards** showing duration, token breakdown (input/output/reasoning/cache), cost, generations, tool calls, status
- **Timeline** with horizontal bars for each span, color-coded by type (generation, tool, error)
- **Detail panel** where you click any span to see its model info, token counts, finish reason, input/output, and domain-specific attributes (warehouse metrics, dbt results, etc.)
- **Summary** (default) — The story of the session: what was asked, files changed with diff previews, outcome (dbt/pytest/Airflow results), what happened timeline, and cost breakdown
- **Waterfall** — Gantt-style timeline bars for every span, color-coded by type
- **Tree** — Nested indentation view showing parent/child span relationships
- **Chat** — Conversation flow with user prompt and agent responses
- **Log** — Flat chronological list of all events

The Summary tab shows what matters most to data engineers:

- **What was asked** — Your prompt, truncated with expand toggle
- **Files changed** — Each file with NEW/EDIT badge and SQL diff preview
- **Outcome** — dbt build results, test results, SQL query results (clickable to jump to waterfall)
- **What happened** — Smart timeline grouping boring commands, showing meaningful actions
- **Loop warnings** — Automatic detection when the agent repeats the same tool call
- **Cost details** — Collapsible token breakdown with visual bar chart

Options:

Expand All @@ -126,31 +148,35 @@ Options:
| `--port` | Port for the viewer server (default: random) |
| `--live` | Auto-refresh every 2s for in-progress sessions |

Partial session ID matching is supported. For example, `altimate-code trace view abc` matches `abc123def456`.
Partial session ID matching is supported. For example, `altimate-code recap view abc` matches `abc123def456`.

### Live Viewing (In-Progress Sessions)

Traces are written incrementally. After every tool call and generation, a snapshot is flushed to disk. This means you can view a trace while the session is still running:
Recaps are written incrementally. After every tool call and generation, a snapshot is flushed to disk. This means you can view a recap while the session is still running:

```bash
# In terminal 1: run a long task
altimate-code run "refactor the entire pipeline"

# In terminal 2: watch the trace live
altimate-code trace view <session-id> --live
# In terminal 2: watch the recap live
altimate-code recap view <session-id> --live
```

The `--live` flag adds a green "LIVE" indicator and polls for updates every 2 seconds. The page auto-refreshes when new spans appear.

### From the TUI

Type `/trace` in the TUI to open a trace history dialog listing all recent sessions. Select any trace to open it in your browser with the interactive viewer. The current session appears at the top, and traces are grouped by date with duration and timestamp info.
Type `/recap` in the TUI to open a recap history dialog listing all recent sessions. Select any recap to open it in your browser with the interactive viewer. The current session appears at the top, and recaps are grouped by date with duration and timestamp info.

The viewer launches in live mode automatically for in-progress sessions, so you can watch spans appear as the agent works.

### Sharing Recaps

The recap viewer includes a **Share** button that exports a self-contained HTML file. This file includes all session data and can be opened in any browser without a server — perfect for sharing with teammates, attaching to tickets, or archiving sessions.

## Remote Exporters

Traces can be sent to remote backends via HTTP POST. Each exporter receives the full trace JSON on session completion.
Recaps can be sent to remote backends via HTTP POST. Each exporter receives the full recap JSON on session completion.

```json
{
Expand All @@ -171,7 +197,7 @@ Traces can be sent to remote backends via HTTP POST. Each exporter receives the
| Field | Type | Description |
|-------|------|-------------|
| `name` | `string` | Identifier for this exporter (used in logs) |
| `endpoint` | `string` | HTTP endpoint to POST trace JSON to |
| `endpoint` | `string` | HTTP endpoint to POST recap JSON to |
| `headers` | `object` | Custom headers (e.g., auth tokens) |

**How it works:**
Expand All @@ -182,9 +208,9 @@ Traces can be sent to remote backends via HTTP POST. Each exporter receives the
- Exporters have a 10-second timeout
- All export operations are best-effort and never crash the CLI

## Trace File Format
## Recap File Format

Traces are stored as JSON files in the traces directory. The schema is versioned for forward compatibility.
Recaps are stored as JSON files in the traces directory. The schema is versioned for forward compatibility.

```json
{
Expand Down Expand Up @@ -296,15 +322,15 @@ All domain-specific attributes use the `de.*` prefix and are stored in the `attr

## Crash Recovery

Traces are designed to survive process crashes:
Recaps are designed to survive process crashes:

1. **Immediate snapshot.** A trace file is written as soon as `startTrace()` is called, before any LLM interaction. Even if the process crashes immediately, a minimal trace file exists.
1. **Immediate snapshot.** A recap file is written as soon as the session starts, before any LLM interaction. Even if the process crashes immediately, a minimal recap file exists.

2. **Incremental snapshots.** After every tool call and generation completion, the trace file is updated atomically (write to temp file, then rename). The file on disk always contains a valid, complete JSON document.
2. **Incremental snapshots.** After every tool call and generation completion, the recap file is updated atomically (write to temp file, then rename). The file on disk always contains a valid, complete JSON document.

3. **Crash handlers.** The `run` command registers `SIGINT`/`SIGTERM`/`beforeExit` handlers that flush the trace synchronously with a `"crashed"` status.
3. **Crash handlers.** The `run` command registers `SIGINT`/`SIGTERM`/`beforeExit` handlers that flush the recap synchronously with a `"crashed"` status.

4. **Status indicators.** Trace status tells you exactly what happened:
4. **Status indicators.** Recap status tells you exactly what happened:

| Status | Meaning |
|--------|---------|
Expand All @@ -313,31 +339,31 @@ Traces are designed to survive process crashes:
| `running` | Session is still in progress (visible in live mode) |
| `crashed` | Process was interrupted before the session completed |

Crashed traces contain all data up to the last successful snapshot. You can view them normally with `altimate-code trace view`.
Crashed recaps contain all data up to the last successful snapshot. You can view them normally with `altimate-code recap view`.

## Historical Traces
## Historical Recaps

All traces are stored in the traces directory and persist across sessions. Use `trace list` to browse history:
All recaps are stored in the traces directory and persist across sessions. Use `recap list` to browse history:

```bash
# Show the last 50 traces
altimate-code trace list -n 50
# Show the last 50 recaps
altimate-code recap list -n 50

# View any historical trace
altimate-code trace view <session-id>
# View any historical recap
altimate-code recap view <session-id>
```

Traces are automatically pruned when `maxFiles` is exceeded (default: 100). The oldest traces are removed first. Set `maxFiles: 0` for unlimited retention.
Recaps are automatically pruned when `maxFiles` is exceeded (default: 100). The oldest recaps are removed first. Set `maxFiles: 0` for unlimited retention.

## Privacy

Traces are stored **locally only** by default. They contain:
Recaps are stored **locally only** by default. They contain:

- The prompt you sent
- Tool inputs and outputs (SQL queries, file contents, command results)
- Model responses

If you configure remote exporters, trace data is sent to those endpoints. No trace data is included in the anonymous telemetry described in [Telemetry](../reference/telemetry.md).
If you configure remote exporters, recap data is sent to those endpoints. No recap data is included in the anonymous telemetry described in [Telemetry](../reference/telemetry.md).

!!! warning "Sensitive Data"
Traces may contain SQL queries, file paths, and command outputs from your session. If you share trace files or configure remote exporters, be aware that this data will be included.
Recaps may contain SQL queries, file paths, and command outputs from your session. If you share recap files or configure remote exporters, be aware that this data will be included.
10 changes: 5 additions & 5 deletions docs/docs/data-engineering/guides/ci-headless.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ fi

---

## Tracing in Headless Mode
## Recap in Headless Mode

Tracing works in headless mode. View traces after the run:
Recap works in headless mode. View recaps after the run:

```bash
altimate trace list
altimate trace view <trace-id>
altimate recap list
altimate recap view <session-id>
```

See [Tracing](../../configure/tracing.md) for the full trace reference.
See [Recap](../../configure/recap.md) for the full recap reference.

---

Expand Down
10 changes: 5 additions & 5 deletions docs/docs/usage/ci-headless.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ fi

---

## Tracing in Headless Mode
## Recap in Headless Mode

Tracing works in headless mode. View traces after the run:
Recap works in headless mode. View recaps after the run:

```bash
altimate trace list
altimate trace view <trace-id>
altimate recap list
altimate recap view <session-id>
```

See [Tracing](../configure/tracing.md) for the full trace reference.
See [Recap](../configure/recap.md) for the full recap reference.

---

Expand Down
18 changes: 10 additions & 8 deletions docs/docs/usage/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ altimate --agent analyst
| `export` | Export session data |
| `import` | Import session data |
| `session` | Session management |
| `trace` | List and view session traces |
| `recap` | List and view session recaps (formerly `trace`) |
| `github` | GitHub integration |
| `pr` | Pull request tools |
| `upgrade` | Upgrade to latest version |
Expand Down Expand Up @@ -149,20 +149,22 @@ altimate run --model anthropic/claude-sonnet-4-6 "optimize my warehouse"
# Print logs for debugging
altimate --print-logs --log-level DEBUG run "test query"

# Disable tracing for a single run
# Disable recap for a single run (--no-trace is the backward-compatible flag name)
altimate run --no-trace "quick question"
```

For CI pipelines and headless automation, see [CI & Automation](ci-headless.md).

## Tracing
## Recap

Every `run` command automatically saves a trace file with the full session details, including generations, tool calls, tokens, cost, and timing. See [Tracing](../configure/tracing.md) for configuration options.
Every `run` command automatically saves a recap file with the full session details, including generations, tool calls, tokens, cost, and timing. See [Recap](../configure/recap.md) for configuration options.

```bash
# List recent traces
altimate trace list
# List recent recaps
altimate recap list

# View a trace in the browser
altimate trace view <session-id>
# View a recap in the browser
altimate recap view <session-id>
```

> **Note:** The `trace` command still works as a backward-compatible alias for `recap`.
Loading
Loading