Skip to content

Commit fcc2cef

Browse files
committed
fix(showcase): simplify health endpoints to local-only (no agent proxy)
All 18 integration health endpoints previously proxied to the backend agent /health with a 3s timeout, causing false reds when agents were slow but functional. The harness already checks agent reachability via the agent:<slug> probe. Health endpoints now return a simple 200 confirming the Next.js process is alive.
1 parent e50737f commit fcc2cef

19 files changed

Lines changed: 93 additions & 770 deletions

File tree

  • showcase
Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,9 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { NextResponse } from "next/server";
22

3-
const AGENT_URL = process.env.AGENT_URL || "http://localhost:8000";
4-
5-
export async function GET(req: NextRequest) {
6-
// Check agent backend reachability
7-
let agentStatus = "unknown";
8-
try {
9-
const res = await fetch(`${AGENT_URL}/health`, {
10-
signal: AbortSignal.timeout(3000),
11-
});
12-
agentStatus = res.ok ? "ok" : "error";
13-
} catch {
14-
agentStatus = "down";
15-
}
16-
17-
// Public response: safe to expose
18-
const publicResponse: Record<string, any> = {
19-
status: agentStatus === "ok" ? "ok" : "degraded",
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: "ok",
206
integration: "ag2",
21-
agent: agentStatus,
227
timestamp: new Date().toISOString(),
23-
};
24-
25-
// Extended diagnostics: only with debug token
26-
const token =
27-
req.headers.get("x-debug-token") || req.nextUrl.searchParams.get("debug");
28-
const expectedToken = process.env.SHOWCASE_DEBUG_TOKEN;
29-
30-
if (token && expectedToken && token === expectedToken) {
31-
publicResponse.diagnostics = {
32-
agent_url: AGENT_URL,
33-
env: {
34-
OPENAI_API_KEY: process.env.OPENAI_API_KEY ? "set" : "NOT SET",
35-
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY ? "set" : "NOT SET",
36-
NODE_ENV: process.env.NODE_ENV,
37-
PORT: process.env.PORT,
38-
},
39-
};
40-
}
41-
42-
const httpStatus = publicResponse.status === "ok" ? 200 : 503;
43-
return NextResponse.json(publicResponse, { status: httpStatus });
8+
});
449
}
Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,9 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { NextResponse } from "next/server";
22

3-
const AGENT_URL = process.env.AGENT_URL || "http://localhost:8000";
4-
5-
export async function GET(req: NextRequest) {
6-
// Check agent backend reachability
7-
let agentStatus = "unknown";
8-
try {
9-
const res = await fetch(`${AGENT_URL}/health`, {
10-
signal: AbortSignal.timeout(3000),
11-
});
12-
agentStatus = res.ok ? "ok" : "error";
13-
} catch {
14-
agentStatus = "down";
15-
}
16-
17-
// Public response: safe to expose
18-
const publicResponse: Record<string, any> = {
19-
status: agentStatus === "ok" ? "ok" : "degraded",
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: "ok",
206
integration: "agno",
21-
agent: agentStatus,
227
timestamp: new Date().toISOString(),
23-
};
24-
25-
// Extended diagnostics: only with debug token
26-
const token =
27-
req.headers.get("x-debug-token") || req.nextUrl.searchParams.get("debug");
28-
const expectedToken = process.env.SHOWCASE_DEBUG_TOKEN;
29-
30-
if (token && expectedToken && token === expectedToken) {
31-
publicResponse.diagnostics = {
32-
agent_url: AGENT_URL,
33-
env: {
34-
OPENAI_API_KEY: process.env.OPENAI_API_KEY ? "set" : "NOT SET",
35-
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY ? "set" : "NOT SET",
36-
NODE_ENV: process.env.NODE_ENV,
37-
PORT: process.env.PORT,
38-
},
39-
};
40-
}
41-
42-
const httpStatus = publicResponse.status === "ok" ? 200 : 503;
43-
return NextResponse.json(publicResponse, { status: httpStatus });
8+
});
449
}
Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,9 @@
1-
import type { NextRequest } from "next/server";
21
import { NextResponse } from "next/server";
32

4-
export const runtime = "nodejs";
5-
6-
// Health probe consumed by the showcase deploy verify step. Returns 200/ok
7-
// only when the agent can actually run; degrades to 503 when OPENAI_API_KEY
8-
// is missing so CI's `if [ "$HTTP_CODE" = "200" ]` gate cannot pass on a
9-
// non-functional service. Mirrors langgraph-typescript's health pattern.
10-
export function GET(req: NextRequest) {
11-
const apiKeyPresent = Boolean(process.env.OPENAI_API_KEY);
12-
const status: "ok" | "degraded" = apiKeyPresent ? "ok" : "degraded";
13-
14-
const publicResponse: Record<string, unknown> = {
15-
status,
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: "ok",
166
integration: "built-in-agent",
17-
backend: "tanstack-ai",
187
timestamp: new Date().toISOString(),
19-
};
20-
21-
// Extended diagnostics behind a debug token — exposing whether
22-
// OPENAI_API_KEY is set on an unauthenticated probe lets attackers monitor
23-
// key rotation. Ops debugging passes the token via header or query param.
24-
const token =
25-
req.headers.get("x-debug-token") || req.nextUrl.searchParams.get("debug");
26-
if (
27-
token &&
28-
process.env.HEALTH_DEBUG_TOKEN &&
29-
token === process.env.HEALTH_DEBUG_TOKEN
30-
) {
31-
publicResponse.openai_api_key = apiKeyPresent ? "set" : "NOT SET";
32-
}
33-
34-
return NextResponse.json(publicResponse, {
35-
status: apiKeyPresent ? 200 : 503,
368
});
379
}
Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,9 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { NextResponse } from "next/server";
22

3-
const AGENT_URL = process.env.AGENT_URL || "http://localhost:8000";
4-
5-
export async function GET(req: NextRequest) {
6-
// Check agent backend reachability
7-
let agentStatus = "unknown";
8-
try {
9-
const res = await fetch(`${AGENT_URL}/health`, {
10-
signal: AbortSignal.timeout(3000),
11-
});
12-
agentStatus = res.ok ? "ok" : "error";
13-
} catch {
14-
agentStatus = "down";
15-
}
16-
17-
// Public response: safe to expose
18-
const publicResponse: Record<string, any> = {
19-
status: agentStatus === "ok" ? "ok" : "degraded",
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: "ok",
206
integration: "claude-sdk-python",
21-
agent: agentStatus,
227
timestamp: new Date().toISOString(),
23-
};
24-
25-
// Extended diagnostics: only with debug token
26-
const token =
27-
req.headers.get("x-debug-token") || req.nextUrl.searchParams.get("debug");
28-
const expectedToken = process.env.SHOWCASE_DEBUG_TOKEN;
29-
30-
if (token && expectedToken && token === expectedToken) {
31-
publicResponse.diagnostics = {
32-
agent_url: AGENT_URL,
33-
env: {
34-
OPENAI_API_KEY: process.env.OPENAI_API_KEY ? "set" : "NOT SET",
35-
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY ? "set" : "NOT SET",
36-
NODE_ENV: process.env.NODE_ENV,
37-
PORT: process.env.PORT,
38-
},
39-
};
40-
}
41-
42-
const httpStatus = publicResponse.status === "ok" ? 200 : 503;
43-
return NextResponse.json(publicResponse, { status: httpStatus });
8+
});
449
}
Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,9 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { NextResponse } from "next/server";
22

3-
const AGENT_URL = process.env.AGENT_URL || "http://localhost:8000";
4-
5-
export async function GET(req: NextRequest) {
6-
// Check agent backend reachability
7-
let agentStatus = "unknown";
8-
try {
9-
const res = await fetch(`${AGENT_URL}/health`, {
10-
signal: AbortSignal.timeout(3000),
11-
});
12-
agentStatus = res.ok ? "ok" : "error";
13-
} catch {
14-
agentStatus = "down";
15-
}
16-
17-
// Public response: safe to expose
18-
const publicResponse: Record<string, any> = {
19-
status: agentStatus === "ok" ? "ok" : "degraded",
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: "ok",
206
integration: "claude-sdk-typescript",
21-
agent: agentStatus,
227
timestamp: new Date().toISOString(),
23-
};
24-
25-
// Extended diagnostics: only with debug token
26-
const token =
27-
req.headers.get("x-debug-token") || req.nextUrl.searchParams.get("debug");
28-
const expectedToken = process.env.SHOWCASE_DEBUG_TOKEN;
29-
30-
if (token && expectedToken && token === expectedToken) {
31-
publicResponse.diagnostics = {
32-
agent_url: AGENT_URL,
33-
env: {
34-
OPENAI_API_KEY: process.env.OPENAI_API_KEY ? "set" : "NOT SET",
35-
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY ? "set" : "NOT SET",
36-
NODE_ENV: process.env.NODE_ENV,
37-
PORT: process.env.PORT,
38-
},
39-
};
40-
}
41-
42-
const httpStatus = publicResponse.status === "ok" ? 200 : 503;
43-
return NextResponse.json(publicResponse, { status: httpStatus });
8+
});
449
}
Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,9 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { NextResponse } from "next/server";
22

3-
const AGENT_URL = process.env.AGENT_URL || "http://localhost:8000";
4-
5-
export async function GET(req: NextRequest) {
6-
// Check agent backend reachability
7-
let agentStatus = "unknown";
8-
try {
9-
const res = await fetch(`${AGENT_URL}/health`, {
10-
signal: AbortSignal.timeout(3000),
11-
});
12-
agentStatus = res.ok ? "ok" : "error";
13-
} catch {
14-
agentStatus = "down";
15-
}
16-
17-
// Public response: safe to expose
18-
const publicResponse: Record<string, any> = {
19-
status: agentStatus === "ok" ? "ok" : "degraded",
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: "ok",
206
integration: "crewai-crews",
21-
agent: agentStatus,
227
timestamp: new Date().toISOString(),
23-
};
24-
25-
// Extended diagnostics: only with debug token
26-
const token =
27-
req.headers.get("x-debug-token") || req.nextUrl.searchParams.get("debug");
28-
const expectedToken = process.env.SHOWCASE_DEBUG_TOKEN;
29-
30-
if (token && expectedToken && token === expectedToken) {
31-
publicResponse.diagnostics = {
32-
agent_url: AGENT_URL,
33-
env: {
34-
OPENAI_API_KEY: process.env.OPENAI_API_KEY ? "set" : "NOT SET",
35-
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY ? "set" : "NOT SET",
36-
NODE_ENV: process.env.NODE_ENV,
37-
PORT: process.env.PORT,
38-
},
39-
};
40-
}
41-
42-
const httpStatus = publicResponse.status === "ok" ? 200 : 503;
43-
return NextResponse.json(publicResponse, { status: httpStatus });
8+
});
449
}
Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,9 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { NextResponse } from "next/server";
22

3-
const AGENT_URL = process.env.AGENT_URL || "http://localhost:8000";
4-
5-
export async function GET(req: NextRequest) {
6-
// Check agent backend reachability
7-
let agentStatus = "unknown";
8-
try {
9-
const res = await fetch(`${AGENT_URL}/health`, {
10-
signal: AbortSignal.timeout(3000),
11-
});
12-
agentStatus = res.ok ? "ok" : "error";
13-
} catch {
14-
agentStatus = "down";
15-
}
16-
17-
// Public response: safe to expose
18-
const publicResponse: Record<string, any> = {
19-
status: agentStatus === "ok" ? "ok" : "degraded",
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: "ok",
206
integration: "google-adk",
21-
agent: agentStatus,
227
timestamp: new Date().toISOString(),
23-
};
24-
25-
// Extended diagnostics: only with debug token
26-
const token =
27-
req.headers.get("x-debug-token") || req.nextUrl.searchParams.get("debug");
28-
const expectedToken = process.env.SHOWCASE_DEBUG_TOKEN;
29-
30-
if (token && expectedToken && token === expectedToken) {
31-
publicResponse.diagnostics = {
32-
agent_url: AGENT_URL,
33-
env: {
34-
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY ? "set" : "NOT SET",
35-
NODE_ENV: process.env.NODE_ENV,
36-
PORT: process.env.PORT,
37-
},
38-
};
39-
}
40-
41-
const httpStatus = publicResponse.status === "ok" ? 200 : 503;
42-
return NextResponse.json(publicResponse, { status: httpStatus });
8+
});
439
}
Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { NextResponse } from "next/server";
22

3-
const AGENT_URL =
4-
process.env.AGENT_URL ||
5-
process.env.LANGGRAPH_DEPLOYMENT_URL ||
6-
"http://localhost:8123";
7-
8-
export async function GET(req: NextRequest) {
9-
// Check agent backend reachability
10-
let agentStatus = "unknown";
11-
try {
12-
const res = await fetch(`${AGENT_URL}/ok`, {
13-
signal: AbortSignal.timeout(3000),
14-
});
15-
agentStatus = res.ok ? "ok" : "error";
16-
} catch {
17-
agentStatus = "down";
18-
}
19-
20-
// Public response: safe to expose
21-
const publicResponse: Record<string, unknown> = {
22-
status: agentStatus === "ok" ? "ok" : "degraded",
3+
export async function GET() {
4+
return NextResponse.json({
5+
status: "ok",
236
integration: "langgraph-fastapi",
24-
agent: agentStatus,
257
timestamp: new Date().toISOString(),
26-
};
27-
28-
// Extended diagnostics: only with debug token
29-
const token =
30-
req.headers.get("x-debug-token") || req.nextUrl.searchParams.get("debug");
31-
const expectedToken = process.env.SHOWCASE_DEBUG_TOKEN;
32-
33-
if (token && expectedToken && token === expectedToken) {
34-
publicResponse.diagnostics = {
35-
agent_url: AGENT_URL,
36-
env: {
37-
OPENAI_API_KEY: process.env.OPENAI_API_KEY ? "set" : "NOT SET",
38-
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY ? "set" : "NOT SET",
39-
NODE_ENV: process.env.NODE_ENV,
40-
PORT: process.env.PORT,
41-
},
42-
};
43-
}
44-
45-
const httpStatus = publicResponse.status === "ok" ? 200 : 503;
46-
return NextResponse.json(publicResponse, { status: httpStatus });
8+
});
479
}

0 commit comments

Comments
 (0)