mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
feat: add chat debug retention purge (#24943)
> Mux is acting on Mike's behalf. Adds configurable retention for chat debug data, including the purge query, updated_at index, site config, experimental API, SDK types, frontend lifecycle setting, and docs. The purge deletes debug runs older than the configured retention window and relies on existing cascades to delete steps. The default retention is 30 days, and setting the value to 0 disables the purge.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
# Chat Debug Data Retention
|
||||
|
||||
Coder Agents automatically cleans up old chat debug data to manage database
|
||||
growth. Debug data includes persisted debug runs and their associated debug
|
||||
steps.
|
||||
|
||||
This setting is independent from [conversation data retention](./chat-retention.md),
|
||||
which only purges archived conversations and orphaned files.
|
||||
|
||||
## How it works
|
||||
|
||||
A background process removes debug runs older than the configured retention
|
||||
period. When a debug run is deleted, its debug steps are deleted via cascade.
|
||||
|
||||
The retention clock uses the debug run's `updated_at` value, which reflects the
|
||||
last write to the debug run. It does not use the chat archive time. If a debug
|
||||
run remains in progress for an unusually long period, such as after broken
|
||||
finalization, it can still be purged once its `updated_at` value is older than
|
||||
the cutoff.
|
||||
|
||||
## Configuration
|
||||
|
||||
Navigate to the **Agents** page, open **Settings**, and select the
|
||||
**Lifecycle** tab to configure chat debug data retention. The default is 30 days.
|
||||
Set the value to `0` to disable debug data retention entirely. The maximum value
|
||||
is `3650` days.
|
||||
|
||||
Use the experimental admin API to read or update the value:
|
||||
|
||||
```text
|
||||
GET /api/experimental/chats/config/debug-retention-days
|
||||
PUT /api/experimental/chats/config/debug-retention-days
|
||||
```
|
||||
|
||||
## Interaction with conversation retention
|
||||
|
||||
Conversation retention and debug data retention are orthogonal controls:
|
||||
|
||||
| Control | What it deletes | Default |
|
||||
|------------------------|-------------------------------------------------------------|---------|
|
||||
| Conversation retention | Archived conversations and orphaned files | 30 days |
|
||||
| Debug data retention | Debug runs and debug steps, based on debug run `updated_at` | 30 days |
|
||||
|
||||
Deleting a chat still deletes its debug data immediately via cascade, regardless
|
||||
of the debug retention window. Unarchiving a chat does not restore debug data
|
||||
that was already purged.
|
||||
@@ -8,6 +8,9 @@ Conversations become eligible for purging only after they are archived. Old
|
||||
conversations can be archived manually, or automatically. See
|
||||
[Auto-Archive](./chat-auto-archive.md) for how the two controls interact.
|
||||
|
||||
Debug run and step cleanup is controlled separately. See
|
||||
[Chat Debug Data Retention](./chat-debug-retention.md).
|
||||
|
||||
## How it works
|
||||
|
||||
A background process runs approximately every 10 minutes to remove expired
|
||||
@@ -25,9 +28,12 @@ Navigate to the **Agents** page, open **Settings**, and select the **Behavior**
|
||||
tab to configure the conversation retention period. The default is 30 days. Use the toggle to
|
||||
disable retention entirely.
|
||||
|
||||
The retention period is stored as the `agents_chat_retention_days` key in the
|
||||
`site_configs` table and can also be managed via the API at
|
||||
`/api/experimental/chats/config/retention-days`.
|
||||
Use the experimental admin API to read or update the value:
|
||||
|
||||
```text
|
||||
GET /api/experimental/chats/config/retention-days
|
||||
PUT /api/experimental/chats/config/retention-days
|
||||
```
|
||||
|
||||
## What gets deleted
|
||||
|
||||
|
||||
Reference in New Issue
Block a user