Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#22056·mastra

[BUG] mastracode: AI tracing spans grow mastra.db unbounded (28 GB), no in-app toggle or auto-prune — TUI hangs on startup

Author: brendengreenwoodCreated Aug 21, 2026Updated Sep 30, 2026
LabelsStoragep: highimpact:mediumeffort:mediummastracodestatus: auto-triaged

Describe the Bug

mastracode persists AI tracing spans to the local mastra.db (mastra_ai_spans, plus mastra_scorers) with no bound. Over normal use the DB grew to 28 GB (23.4 GB in mastra_ai_spans alone). Once the DB is large, the interactive TUI hangs on startup ("won't load") for the affected project/session, while a fresh session in another directory still opens and headless mode is unaffected.

There is no user-facing way to stop this:

  • observability.localTracing: false (settings.json) does not stop the storage span writer — it only controls the separate local DuckDB trace viewer.
  • MASTRA_TELEMETRY_DISABLED only gates usage analytics, not span persistence.
  • Storage retention (prune()) is opt-in ("Storage grows without bound by default"), and mastracode never configures retention or calls prune().

dbstat breakdown before cleanup:

mastra_ai_spans            23.39 GB   (206,409 rows)
mastra_scorers              2.89 GB
mastra_messages             1.23 GB
mastra_workflow_snapshot    0.71 GB
mastra_observational_memory 0.02 GB

### Steps To Reproduce

1. Install mastracode 0.35.0 and use it normally over an extended period with the
   default local libsql storage (default data dir on macOS:
   `~/Library/Application Support/mastracode/mastra.db`).
2. Periodically check the spans table and DB file size:
   ```bash
   DB="$HOME/Library/Application Support/mastracode/mastra.db"
   sqlite3 "$DB" "SELECT count(*) FROM mastra_ai_spans;"
   ls -lh "$DB"

Observe mastra_ai_spans and the file growing without bound (no cap, no TTL). 3. Attempt to disable it via observability.localTracing: false in settings.json and/or MASTRA_TELEMETRY_DISABLED=1 — note the table keeps growing regardless. 4. Once mastra.db reaches tens of GB, launch the interactive TUI in that project. The TUI hangs on startup and never reaches the prompt (headless still works).

Link to Minimal Reproducible Example

No standalone repo: this reproduces from normal mastracode use with default local storage — the growth is inherent to the default span-persistence path (no retention configured). The commands under "Steps To Reproduce" observe it directly against a mastracode-created mastra.db. Happy to provide a sanitized dbstat dump on request.

Expected Behavior

  • A supported way to fully disable span persistence for local CLI use, and/or
  • mastracode ships a sane default retention policy (e.g. observability.spans: { maxAge: '7d' }) and calls prune() on a schedule so the local DB is self-limiting without manual maintenance.

Environment Information

block
- mastracode: 0.35.0
- Storage: libsql (default local `mastra.db`)
- OS: macOS (Darwin 24.6.0)
- Node: v24.14.0

Verification

  • I have searched the existing issues to make sure this is not a duplicate
  • I have included sufficient information for the team to reproduce and understand the issue

Source: mastra-ai/mastra

View original on GitHubView discussion on GitHub