Repository navigation
feat(compression): add /api/compression/replay endpoint (PR-024) - #162
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Note
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c8397dfdd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (model) { | ||
| if (where) where += " AND request_id LIKE ?"; | ||
| else where = "WHERE request_id LIKE ?"; | ||
| params.push(`%${model}%`); |
There was a problem hiding this comment.
Use stored model data for model filtering
When model is supplied, this predicate searches request_id, but the production compression writers populate that field with skillRequestId = generateRequestId() rather than a model-prefixed value (see open-sse/handlers/chatCore.ts:917, with writes at :1632 and :1728). As a result, real requests to /api/compression/replay?model=gpt-4o return zero compression runs even when those model runs exist; the endpoint needs a real stored model field or should not apply/advertise this filter.
Useful? React with 👍 / 👎.
|



Summary
Adds GET
/api/compression/replayto surface the recent compression run history alongside the livecompression.completedevent rendered byopen-sse/services/compression/engineBreakdown.ts. Useful for forensic inspection, post-hoc engine comparisons, and tooling that needs a stable snapshot of the last N runs (vs. the ephemeral live stream).Endpoint
Response shape
{ "ok": true, "filters": { "provider": null, "model": null, "windowMs": 86400000, "limit": 100, "sinceIso": "..." }, "runs": [ { "requestId": "...", "provider": "openai", "completedAt": "...", "originalTokens": 0, "compressedTokens": 0, "compressionRatio": 0, "rulesApplied": 0, "engine": "unknown", "engines": [ { "name":"rtk","originalTokens":0,"compressedTokens":0,"compressionRatio":0 } ], "raw": { ...compression_analytics row... } } ] }Changes
src/lib/db/compressionAnalytics.tsensureCompressionAnalyticsTables(),getCompressionEngineBreakdownForRequests(),getRecentCompressionAnalyticsRuns()src/app/api/compression/replay/route.tssrc/app/api/compression/replay/__tests__/route.test.tsWhy these helpers
The existing module already exposed
getLatestCompressionAnalyticsRun,getCompressionAnalyticsSummary, andgetPerEngineAnalytics, but nothing to fetch a window of runs paired with their breakdown rows. The new helpers compose with the existing schema (no new migrations) —compression_analytics(036) +compression_engine_breakdown(037) + indexes (049).Tests
13/13 passing on the
pr-024-compression-replay-endpointbranch (based offv3.8.34):provider=openaicase-insensitive substring filtermodel=gpt-4orequest_id LIKE filterwindowMs=60000→ only rows in the last minutewindowMs=garbage→ falls back to default 24hwindowMs=999999999999→ clamps to 30dlimit=1/limit=99999→ clamps to [1,1000]Run with: