Skip to content

Commit abc9827

Browse files
committed
docs: add AI Bridge data retention documentation
Add comprehensive documentation for AI Bridge data retention, addressing the concern raised in PR #21038 that AI Bridge retention should be documented alongside other retention settings. Changes: - docs/ai-coder/ai-bridge/setup.md: Add new Data Retention section with configuration options, duration formats, examples, and what data is retained - docs/ai-coder/ai-bridge/monitoring.md: Add Data Retention section with quick reference and links to detailed documentation - docs/ai-coder/ai-bridge/index.md: Add data retention link to Next steps - docs/admin/setup/data-retention.md: Add AI Bridge to the centralized data retention documentation with settings table, examples, behavior description, and cross-references to AI Bridge docs This improves discoverability by: 1. Documenting retention in the AI Bridge setup page (primary location) 2. Adding retention info to monitoring docs (relevant context) 3. Including AI Bridge in the central data retention page 4. Cross-linking between AI Bridge and admin retention docs Refs #21038
1 parent d51c53d commit abc9827

File tree

4 files changed

+148
-3
lines changed

4 files changed

+148
-3
lines changed

docs/admin/setup/data-retention.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Data Retention
22

33
Coder supports configurable retention policies that automatically purge old
4-
Audit Logs, Connection Logs, Workspace Agent Logs, and API keys. These policies
5-
help manage database growth by removing records older than a specified duration.
4+
Audit Logs, Connection Logs, Workspace Agent Logs, API keys, and AI Bridge
5+
records. These policies help manage database growth by removing records older
6+
than a specified duration.
67

78
## Overview
89

@@ -32,6 +33,12 @@ a YAML configuration file.
3233
| Connection Logs | `--connection-logs-retention` | `CODER_CONNECTION_LOGS_RETENTION` | `0` (disabled) | How long to retain Connection Logs |
3334
| API Keys | `--api-keys-retention` | `CODER_API_KEYS_RETENTION` | `7d` | How long to retain expired API keys |
3435
| Workspace Agent Logs | `--workspace-agent-logs-retention` | `CODER_WORKSPACE_AGENT_LOGS_RETENTION` | `7d` | How long to retain workspace agent logs |
36+
| AI Bridge | `--aibridge-retention` | `CODER_AIBRIDGE_RETENTION` | `60d` | How long to retain AI Bridge records |
37+
38+
> [!NOTE]
39+
> AI Bridge retention is configured separately from other retention settings.
40+
> See [AI Bridge Setup](../../ai-coder/ai-bridge/setup.md#data-retention) for
41+
> detailed configuration options.
3542
3643
### Duration Format
3744

@@ -51,7 +58,8 @@ coder server \
5158
--audit-logs-retention=365d \
5259
--connection-logs-retention=90d \
5360
--api-keys-retention=7d \
54-
--workspace-agent-logs-retention=7d
61+
--workspace-agent-logs-retention=7d \
62+
--aibridge-retention=60d
5563
```
5664

5765
### Environment Variables Example
@@ -61,6 +69,7 @@ export CODER_AUDIT_LOGS_RETENTION=365d
6169
export CODER_CONNECTION_LOGS_RETENTION=90d
6270
export CODER_API_KEYS_RETENTION=7d
6371
export CODER_WORKSPACE_AGENT_LOGS_RETENTION=7d
72+
export CODER_AIBRIDGE_RETENTION=60d
6473
```
6574

6675
### YAML Configuration Example
@@ -71,6 +80,9 @@ retention:
7180
connection_logs: 90d
7281
api_keys: 7d
7382
workspace_agent_logs: 7d
83+
84+
aibridge:
85+
retention: 60d
7486
```
7587
7688
## How Retention Works
@@ -116,6 +128,21 @@ For non-latest builds, logs are deleted if the agent hasn't connected within the
116128
retention period. Setting `--workspace-agent-logs-retention=7d` deletes logs for
117129
agents that haven't connected in 7 days (excluding those from the latest build).
118130

131+
### AI Bridge Data Behavior
132+
133+
AI Bridge retention applies to interception records and all related data:
134+
135+
- **Interceptions**: Records of each proxied request with timestamps and user
136+
attribution.
137+
- **Token usage**: Input and output token counts for cost tracking.
138+
- **Prompts**: The last user prompt from each conversation turn.
139+
- **Tool invocations**: MCP tool calls and their results.
140+
141+
Setting `--aibridge-retention=60d` deletes AI Bridge records older than 60 days.
142+
The default of 60 days provides a reasonable balance between storage costs and
143+
the ability to analyze usage patterns. For compliance requirements, consider
144+
extending this to 90 days or longer.
145+
119146
## Best Practices
120147

121148
### Recommended Starting Configuration
@@ -128,6 +155,9 @@ retention:
128155
connection_logs: 90d
129156
api_keys: 7d
130157
workspace_agent_logs: 7d
158+
159+
aibridge:
160+
retention: 60d
131161
```
132162

133163
### Compliance Considerations
@@ -171,6 +201,9 @@ retention:
171201
connection_logs: 0s # Keep connection logs forever
172202
api_keys: 0s # Keep expired API keys forever
173203
workspace_agent_logs: 0s # Keep workspace agent logs forever
204+
205+
aibridge:
206+
retention: 0s # Keep AI Bridge records forever
174207
```
175208

176209
## Monitoring
@@ -185,3 +218,9 @@ containing the table name (e.g., `audit_logs`, `connection_logs`, `api_keys`).
185218
purge procedures.
186219
- [Connection Logs](../monitoring/connection-logs.md): Learn about Connection
187220
Logs and monitoring.
221+
- [AI Bridge](../../ai-coder/ai-bridge/index.md): Learn about AI Bridge for
222+
centralized LLM and MCP proxy management.
223+
- [AI Bridge Setup](../../ai-coder/ai-bridge/setup.md#data-retention): Configure
224+
AI Bridge data retention.
225+
- [AI Bridge Monitoring](../../ai-coder/ai-bridge/monitoring.md): Monitor AI
226+
Bridge usage and metrics.

docs/ai-coder/ai-bridge/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ AI Bridge is best suited for organizations facing these centralized management a
3636
- [Configure AI clients](./client-config.md) to use AI Bridge
3737
- [Configure MCP servers](./mcp.md) for tool access
3838
- [Monitor usage and metrics](./monitoring.md)
39+
- [Configure data retention](./setup.md#data-retention) for compliance and storage management
3940
- [Reference documentation](./reference.md)

docs/ai-coder/ai-bridge/monitoring.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,26 @@ AI Bridge records the last `user` prompt, token usage, and every tool invocation
99
We provide an example Grafana dashboard that you can import as a starting point for your metrics. See [the Grafana dashboard README](https://github.com/coder/coder/blob/main/examples/monitoring/dashboards/grafana/aibridge/README.md).
1010

1111
These logs and metrics can be used to determine usage patterns, track costs, and evaluate tooling adoption.
12+
13+
## Data Retention
14+
15+
AI Bridge data is retained for **60 days by default**. This includes interceptions,
16+
token usage, prompts, and tool invocations. You can configure the retention
17+
period using the `--aibridge-retention` flag or `CODER_AIBRIDGE_RETENTION`
18+
environment variable.
19+
20+
For example, to retain data for 90 days:
21+
22+
```sh
23+
coder server --aibridge-retention=90d
24+
```
25+
26+
Setting retention to `0` keeps data indefinitely, but monitor your database size
27+
as AI Bridge data can grow significantly with heavy usage.
28+
29+
For detailed configuration options, see:
30+
31+
- [AI Bridge Data Retention](./setup.md#data-retention): Configure retention for
32+
AI Bridge.
33+
- [Data Retention](../../admin/setup/data-retention.md): Overview of all data
34+
retention policies in Coder.

docs/ai-coder/ai-bridge/setup.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,85 @@ AI Bridge can relay traffic to other OpenAI- or Anthropic-compatible services or
9494

9595
> [!NOTE]
9696
> See the [Supported APIs](./reference.md#supported-apis) section below for precise endpoint coverage and interception behavior.
97+
98+
## Data Retention
99+
100+
AI Bridge records prompts, token usage, and tool invocations for auditing and
101+
monitoring purposes. By default, this data is retained for 60 days. You can
102+
configure the retention period to meet your organization's compliance and
103+
storage requirements.
104+
105+
### Configuration
106+
107+
Configure retention using a CLI flag, environment variable, or YAML:
108+
109+
| Setting | CLI Flag | Environment Variable | Default | Description |
110+
|----------------|------------------------|----------------------------|---------|--------------------------------------|
111+
| AI Bridge Data | `--aibridge-retention` | `CODER_AIBRIDGE_RETENTION` | `60d` | How long to retain AI Bridge records |
112+
113+
### Duration Format
114+
115+
Retention durations support days (`d`) and weeks (`w`) in addition to standard
116+
Go duration units (`h`, `m`, `s`):
117+
118+
- `7d` - 7 days
119+
- `2w` - 2 weeks
120+
- `30d` - 30 days
121+
- `90d` - 90 days (recommended for compliance)
122+
- `365d` - 1 year
123+
124+
### CLI Example
125+
126+
```sh
127+
coder server \
128+
--aibridge-enabled=true \
129+
--aibridge-retention=90d
130+
```
131+
132+
### Environment Variables Example
133+
134+
```sh
135+
export CODER_AIBRIDGE_ENABLED=true
136+
export CODER_AIBRIDGE_RETENTION=90d
137+
```
138+
139+
### YAML Configuration Example
140+
141+
```yaml
142+
aibridge:
143+
enabled: true
144+
retention: 90d
145+
```
146+
147+
### What Data is Retained
148+
149+
AI Bridge retention applies to:
150+
151+
- **Interceptions**: Records of each proxied request, including timestamps and
152+
user attribution.
153+
- **Token usage**: Input and output token counts for cost tracking.
154+
- **Prompts**: The last user prompt from each conversation turn.
155+
- **Tool invocations**: MCP tool calls and their results.
156+
157+
### Keeping Data Indefinitely
158+
159+
To retain AI Bridge data indefinitely, set retention to `0`:
160+
161+
```sh
162+
coder server --aibridge-retention=0
163+
```
164+
165+
> [!WARNING]
166+
> Disabling retention can lead to significant database growth over time.
167+
> Monitor your database size and consider using
168+
> [external log aggregation](../../admin/setup/data-retention.md#external-log-aggregation)
169+
> for long-term storage.
170+
171+
### How Retention Works
172+
173+
Coder runs a background purge process approximately every 10 minutes that
174+
deletes AI Bridge records older than the configured retention period. The
175+
process runs in batches to avoid database lock contention.
176+
177+
For more details on data retention across all Coder features, see the
178+
[Data Retention](../../admin/setup/data-retention.md) documentation.

0 commit comments

Comments
 (0)