Skip to content

Delete stored traces and enforce a retention period - #359

Merged
dipeshbabu merged 1 commit into
mainfrom
feat/trace-retention
Nov 20, 2026
Merged

dipeshbabu merged 1 commit into
mainfrom
feat/trace-retention

Conversation

@dipeshbabu

Copy link
Copy Markdown
Owner

A shared AgentLoop server could store traces (prompts, tool data) but never remove them, although the production guide asks teams to have a deletion policy.

Store (SQLite + Postgres): `delete_trace(run_id, project_id)` deletes the trace and everything derived from it (interventions comparing it, findings, usage events, children first, chunked, one transaction); returns per-table counts, `None` when not in that project. `purge_traces(older_than_days, project_id=None)` deletes by storage age; rejects non-positive/NaN/bool/string ages.

Access

  • `DELETE /v1/traces/{run_id}` with a project key: own project only (other project → 404, no key → 401).
  • `AgentLoopClient.delete_trace`; CLI `delete-trace`, `remote-delete-trace`, `purge-traces --older-than-days N [--project-id]` (falls back to `AGENTLOOP_RETENTION_DAYS`, no-op when unset).
  • Dashboard Traces page: Delete this trace behind a confirmation checkbox, scoped to the current/signed-in project.

Cloud stack: new `retention` service runs `agentloop purge-traces` daily with `AGENTLOOP_RETENTION_DAYS` (empty keeps traces). CI deploy-stack now deletes a trace over HTTPS (200, then report 404) and checks the retention service applied a 365-day setting.

Tests: store contract (both backends in CI) incl. cross-project refusal and interventions; API, client, CLI and dashboard tests. 234 related tests pass locally. Docs: PRODUCTION (new section), CLOUD_DEPLOY, TRACE_RETENTION pointer, API_VERSIONING, DASHBOARD, changelog.

🤖 Generated with Claude Code

A shared server could store traces but never remove them. Both stores
gain delete_trace (project-scoped, removing findings, usage records and
interventions that compare the trace) and purge_traces (by storage age,
optionally per project). They are exposed as DELETE /v1/traces/{run_id}
for a project key, AgentLoopClient.delete_trace, delete-trace,
remote-delete-trace and purge-traces CLI commands (purge reads
AGENTLOOP_RETENTION_DAYS when no age is given), and a confirmed delete
control on the dashboard Traces page. The cloud stack adds a retention
service that purges daily; CI deletes a trace over HTTPS and checks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown

AgentLoop replay self-test

This required repository check evaluates generated synthetic demo traces. It tests the replay and CI machinery; it does not show that this PR improves application performance.

AgentLoop CI Report

  • Status: passed
  • Replay: Replay passed: latency improvement 69.68%, cost improvement 78.82%, retry delta -1.
  • Merge recommendation: synthetic self-test only; assess application traces before merge
  • Findings: 1 total, 0 high severity, 1 patchable

Performance Gates

Gate Status Detail
latency_regression pass 0.00% regression <= 0.00% allowed
cost_regression pass 0.00% regression <= 0.00% allowed
latency_improvement pass 69.68% improvement >= 20.00% required
cost_improvement pass 78.82% improvement >= 5.00% required
retry_non_increase pass 0 candidate retries <= 1 baseline retries

Trace inputs

This comparison includes synthetic data. It does not establish application performance gains from a pull request.

Side Run ID Path Synthetic marker Source
baseline run_b8b774cfbd0e465f runs/research_agent_baseline.json yes agentloop_demo
candidate run_2623d224c6004a17 runs/research_agent_optimized.json yes agentloop_demo

Metric Impact

Metric Impact
Latency improvement 69.68%
Cost improvement 78.82%
Retry delta -1
Candidate schema validity not provided
Candidate quality score not provided

Top Findings

Finding Severity Type Rewrite
al_cache_context_ac56663e106e: Cache repeated prompt/context prefix medium cache_context Move stable instructions into cached prefixes, summaries, or framework-level memory instead of resending full text.

@dipeshbabu
dipeshbabu merged commit f53ef1e into main Nov 20, 2026
26 checks passed
@dipeshbabu
dipeshbabu deleted the feat/trace-retention branch November 20, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant