---
id: T01
parent: S01
milestone: M007
provides: []
requires: []
affects: []
key_files: ["backend/models.py", "backend/config.py", "backend/schemas.py", "backend/routers/pipeline.py", "alembic/versions/006_debug_columns.py"]
key_decisions: ["Followed exact review_mode Redis pattern for debug_mode toggle", "Used coalesce in token aggregation to handle NULL token columns"]
patterns_established: []
drill_down_paths: []
observability_surfaces: []
duration: ""
verification_result: "Migration 006 applied successfully. Debug mode GET returns false (default), PUT toggles to true, GET reads back true. Token summary returns real per-stage aggregation for existing video data. DB columns confirmed via psql. Event listing response includes new nullable text fields."
completed_at: 2026-03-30T18:23:26.734Z
blocker_discovered: false
---

# T01: Added 3 TEXT columns to pipeline_events (system_prompt_text, user_prompt_text, response_text), Redis-backed debug mode toggle, and per-stage token summary endpoint

> Added 3 TEXT columns to pipeline_events (system_prompt_text, user_prompt_text, response_text), Redis-backed debug mode toggle, and per-stage token summary endpoint

## What Happened
---
id: T01
parent: S01
milestone: M007
key_files:
  - backend/models.py
  - backend/config.py
  - backend/schemas.py
  - backend/routers/pipeline.py
  - alembic/versions/006_debug_columns.py
key_decisions:
  - Followed exact review_mode Redis pattern for debug_mode toggle
  - Used coalesce in token aggregation to handle NULL token columns
duration: ""
verification_result: passed
completed_at: 2026-03-30T18:23:26.734Z
blocker_discovered: false
---

# T01: Added 3 TEXT columns to pipeline_events (system_prompt_text, user_prompt_text, response_text), Redis-backed debug mode toggle, and per-stage token summary endpoint

**Added 3 TEXT columns to pipeline_events (system_prompt_text, user_prompt_text, response_text), Redis-backed debug mode toggle, and per-stage token summary endpoint**

## What Happened

Added three nullable TEXT columns to PipelineEvent for full LLM I/O capture. Created Alembic migration 006. Added debug_mode config setting. Built three new endpoints: debug-mode GET/PUT (Redis-backed with config fallback, following review_mode pattern) and token-summary aggregation. Extended event listing to include new fields. All work deployed and verified on ub01.

## Verification

Migration 006 applied successfully. Debug mode GET returns false (default), PUT toggles to true, GET reads back true. Token summary returns real per-stage aggregation for existing video data. DB columns confirmed via psql. Event listing response includes new nullable text fields.

## Verification Evidence

| # | Command | Exit Code | Verdict | Duration |
|---|---------|-----------|---------|----------|
| 1 | `ssh ub01 'docker exec chrysopedia-api alembic upgrade head'` | 0 | ✅ pass | 3000ms |
| 2 | `curl -sf http://ub01:8096/api/v1/admin/pipeline/debug-mode` | 0 | ✅ pass | 500ms |
| 3 | `curl -sf -X PUT debug-mode with {debug_mode:true}` | 0 | ✅ pass | 500ms |
| 4 | `curl -sf http://ub01:8096/api/v1/admin/pipeline/token-summary/{video_id}` | 0 | ✅ pass | 500ms |
| 5 | `psql \d pipeline_events | grep system_prompt` | 0 | ✅ pass | 500ms |


## Deviations

None.

## Known Issues

None.

## Files Created/Modified

- `backend/models.py`
- `backend/config.py`
- `backend/schemas.py`
- `backend/routers/pipeline.py`
- `alembic/versions/006_debug_columns.py`


## Deviations
None.

## Known Issues
None.
