Skip to content

Commit 63bd102

Browse files
committed
refactor(models/up): remove health check exclusions
1 parent 332dfbe commit 63bd102

1 file changed

Lines changed: 6 additions & 25 deletions

File tree

‎apps/web/src/app/api/models/up/route.ts‎

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ const MIN_UNIQUE_USERS_FOR_ALERT = 20;
4747
// open (report healthy) since a timeout is not evidence of a model being down.
4848
const QUERY_TIMEOUT_MS = 10_000;
4949

50-
// Models excluded from the top-level health status. They still get their
51-
// per-model health evaluated and returned, but can't trigger 503 responses.
52-
// Useful for preview models with inconsistent traffic that cause false alerts,
53-
// or third-party models that can be retracted without notice.
54-
const HEALTH_CHECK_EXCLUSIONS = new Set([
55-
'google/gemini-3.1-pro-preview',
56-
// We don't control when this model may be retracted by OpenRouter.
57-
'openrouter/elephant-alpha',
58-
'openai/gpt-5.4',
59-
'openai/gpt-5.5',
60-
]);
61-
6250
const MINUTE_MS = 60 * 1000;
6351
const CURRENT_WINDOW_MS = 15 * MINUTE_MS;
6452
const PREVIOUS_WINDOW_MS = 30 * MINUTE_MS;
@@ -162,7 +150,7 @@ async function queryModelStats(
162150
return statsByModel;
163151
}
164152

165-
function evaluateModelHealth(stats: ModelStats, monitored: boolean): ModelHealthMetrics {
153+
function evaluateModelHealth(stats: ModelStats): ModelHealthMetrics {
166154
const currentRequests = Math.round(stats.current.requests);
167155
const previousRequests = Math.round(stats.previous.requests);
168156
const baselineRequests = Math.round(stats.baseline.requests / BASELINE_WINDOW_COUNT);
@@ -176,8 +164,6 @@ function evaluateModelHealth(stats: ModelStats, monitored: boolean): ModelHealth
176164

177165
// Per-model health: unhealthy when the baseline had enough distinct organic
178166
// users AND the model shows a significant traffic drop.
179-
// Non-monitored models still get their real health status — they just
180-
// don't affect the top-level healthy flag or trigger 503.
181167
const healthy = !(
182168
uniqueUsersBaseline >= MIN_UNIQUE_USERS_FOR_ALERT &&
183169
((baselineRequests > HIGH_BASELINE && percentChange < -90) ||
@@ -189,7 +175,7 @@ function evaluateModelHealth(stats: ModelStats, monitored: boolean): ModelHealth
189175

190176
return {
191177
healthy,
192-
monitored,
178+
monitored: true,
193179
currentRequests,
194180
previousRequests,
195181
baselineRequests,
@@ -226,9 +212,6 @@ export async function GET(
226212
anchorTime = parsed;
227213
}
228214

229-
const alertingModels = monitoredModels.filter(m => !HEALTH_CHECK_EXCLUSIONS.has(m));
230-
const excludedModels = monitoredModels.filter(m => HEALTH_CHECK_EXCLUSIONS.has(m));
231-
232215
try {
233216
const queryStartTime = Date.now();
234217
const anchor = anchorTime ?? new Date(queryStartTime);
@@ -241,19 +224,17 @@ export async function GET(
241224
const models: Record<string, ModelHealthMetrics> = {};
242225
for (const model of monitoredModels) {
243226
models[model] = evaluateModelHealth(
244-
statsByModel.get(toAnalyticsEngineModelId(model)) ?? emptyModelStats(),
245-
!HEALTH_CHECK_EXCLUSIONS.has(model)
227+
statsByModel.get(toAnalyticsEngineModelId(model)) ?? emptyModelStats()
246228
);
247229
}
248230

249231
const queryExecutionTimeMs = Date.now() - queryStartTime;
250-
// Only monitored models affect the top-level health status
251-
const hasSignificantDrop = Object.values(models).some(m => m.monitored && !m.healthy);
232+
const hasSignificantDrop = Object.values(models).some(m => !m.healthy);
252233
const status = hasSignificantDrop ? 503 : 200;
253234

254235
if (hasSignificantDrop) {
255236
const unhealthy = Object.entries(models)
256-
.filter(([, m]) => m.monitored && !m.healthy)
237+
.filter(([, m]) => !m.healthy)
257238
.map(([model, m]) => ({
258239
model,
259240
currentRequests: m.currentRequests,
@@ -282,7 +263,7 @@ export async function GET(
282263
} catch (error) {
283264
captureException(error, {
284265
tags: { endpoint: 'models/up', source: 'model_health_check' },
285-
extra: { monitoredModels: alertingModels, nonMonitoredModels: excludedModels },
266+
extra: { monitoredModels },
286267
});
287268

288269
// Fail open: a query timeout or Analytics Engine error is not evidence of a model being down.

0 commit comments

Comments
 (0)