From cfb3c22cef517b224be4b0ec6fd5fba5f904e6b5 Mon Sep 17 00:00:00 2001 From: Priyanka Punukollu Date: Wed, 25 Feb 2026 20:49:11 -0600 Subject: [PATCH] feat(real-estate): expose GET /real-estate/log observability endpoint - main.py: add GET /real-estate/log endpoint (feature-flag gated). Returns total_invocations, success_count, failure_count, and last 50 log entries from real_estate._invocation_log. Returns 404 when ENABLE_REAL_ESTATE is not true. Made-with: Cursor --- main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.py b/main.py index 5f6a01bec..8007b1cc0 100644 --- a/main.py +++ b/main.py @@ -549,6 +549,32 @@ async def feedback_summary(): } +@app.get("/real-estate/log") +async def real_estate_log(): + """ + Returns the in-memory real estate tool invocation log. + Only available when ENABLE_REAL_ESTATE=true. + Each entry: timestamp, function, query (truncated), duration_ms, success. + """ + from tools.real_estate import is_real_estate_enabled, get_invocation_log + + if not is_real_estate_enabled(): + return JSONResponse( + status_code=404, + content={"error": "Real estate feature is not enabled."}, + ) + + log = get_invocation_log() + total = len(log) + successes = sum(1 for e in log if e["success"]) + return { + "total_invocations": total, + "success_count": successes, + "failure_count": total - successes, + "entries": log[-50:], # last 50 only + } + + @app.get("/costs") async def costs(): total = sum(c["estimated_cost_usd"] for c in cost_log)