Skip to content

feat: add an AI Gateway data retention endpoint - #32659

Merged
ssncferreira merged 1 commit into
mainfrom
ssncf/ai-gateway-retention-endpoint
Nov 24, 2026
Merged

ssncferreira merged 1 commit into
mainfrom
ssncf/ai-gateway-retention-endpoint

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Pages that read raw AI Gateway data and have a date picker don't handle data retention consistently. AI Sessions allows start dates whose data is already purged. AI spend only learns the retention after a request.

The new AI spend page reads aggregated data, which is never purged, in some views and raw data in others. For consistency, the Overview and Detailed report tabs should accept the same date range, so both are limited to the retention.

The retention is in the deployment config, but only Owners can read it. This adds an experimental endpoint that returns only the retention, so these pages can offer only retained dates.

Changes

  • Add GET /api/experimental/ai-gateway/retention, returning retention_ms. Zero means data is never purged.
  • Any authenticated user with the AI Gateway feature can read it, since it holds no usage data.
  • Add codersdk.AIGatewayRetention and the ExperimentalClient.AIGatewayRetention method.

Note

Generated by Coder Agents on behalf of @ssncferreira.

@ssncferreira
ssncferreira force-pushed the ssncf/ai-gateway-retention-endpoint branch from c3a7da7 to 18bd931 Compare November 24, 2026 15:34
@ssncferreira
ssncferreira marked this pull request as ready for review November 24, 2026 17:05

@mollymaefraser mollymaefraser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 only a few non-blocking nits

Comment thread enterprise/coderd/aibridge_test.go Resolved
Comment thread enterprise/coderd/aibridge.go Resolved
@ssncferreira
ssncferreira merged commit dfe6402 into main Nov 24, 2026
41 checks passed
@ssncferreira
ssncferreira deleted the ssncf/ai-gateway-retention-endpoint branch November 24, 2026 18:07
ssncferreira added a commit that referenced this pull request Nov 24, 2026
…32660)

## Description

The AI Sessions date picker allows picking times before the AI Gateway
data retention, which always return no sessions. It now disables them.

## Changes

- Add `getAIGatewayRetention` and the `aiGatewayRetention` query. The AI
spend page will reuse them.
- Pass `minDate`, now minus the retention, to the Sessions date picker.
Days and quick ranges before it can't be picked.
- Add the `DatePickerOpenWithRetention` story.

Depends on #32659.

> [!NOTE]
> Generated by Coder Agents on behalf of @ssncferreira.
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026

This branch had an error being deployed

1 failed deployment
docs-preview — 18bd9317 Deployed Nov 24, 2026 by ssncferreira via cleanup #440
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants