Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/support-agent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ def run_demo(
)
order = client.get_order(DEFAULT_ORDER_ID)
user = client.get_user(order.user_id)
active_sessions = client.get_metric("active_sessions", window="1h")
active_sessions = client.get_metric("active_sessions", window="now")
response = (
f"Order {order.order_id} is {order.status}. "
f"The customer is {user.user_id} with {user.total_orders} lifetime orders "
f"and {active_sessions.value} active sessions in the last hour."
f"and {active_sessions.value} active sessions right now."
)

return {
Expand All @@ -76,7 +76,7 @@ def run_demo(
"status": order.status,
"user_id": user.user_id,
"user_total_orders": user.total_orders,
"active_sessions_1h": active_sessions.value,
"active_sessions_now": active_sessions.value,
"response": response,
"steps": [
"Fetched the live order entity",
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/test_agent_journeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ async def test_support_agent_journey(base_url: str, support_api_key: str):
user = await client.get_user(order.user_id)
assert user.user_id == "USR-10001"

metric = await client.get_metric("active_sessions", window="1h")
# active_sessions is a point-in-time gauge — its only declared window is
# "now". (audit_30_06_26.md A1: /v1/metrics now rejects undeclared windows.)
metric = await client.get_metric("active_sessions", window="now")
assert metric.value >= 0


Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_agent_query_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ async def test_get_metric_rejects_window_not_in_available_windows():
bad = await client.get("/v1/metrics/revenue?window=2h")
good = await client.get("/v1/metrics/revenue?window=1h")
bad_active = await client.get("/v1/metrics/active_sessions?window=24h")
good_active = await client.get("/v1/metrics/active_sessions?window=now")

assert bad.status_code == 422 # 2h is not a declared window for revenue
assert good.status_code == 200
assert bad_active.status_code == 422 # active_sessions only supports "now"
assert good_active.status_code == 200 # "now" is active_sessions' declared window
Loading