Browse Source

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
pull/6453/head
Priyanka Punukollu 1 month ago
parent
commit
361734e8c5
  1. 26
      agent/main.py

26
agent/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") @app.get("/costs")
async def costs(): async def costs():
total = sum(c["estimated_cost_usd"] for c in cost_log) total = sum(c["estimated_cost_usd"] for c in cost_log)

Loading…
Cancel
Save