Problem
The Models tab (/models) exists and the ingestion pipeline is ready, but it shows no data because OpenClaw gateway does not currently emit model:used (or equivalent) events.
The index.ts hook handler was written to handle conversation:start/end and model:used events, but these are not fired by the gateway in v2026.3.x.
Goal
Populate the Models tab with real per-model token, cost, and latency data from OpenClaw sessions.
Investigation paths
Option A — OpenClaw gateway emits model usage events
Check if OpenClaw has (or plans) any event that includes model name, token counts, and cost. If a model:used or session:complete event exists or can be added, update handler.ts to capture it and POST to POST /api/v1/ingest/model_usage.
Option B — Parse session status API
OpenClaw likely exposes per-session model usage via its status/billing API. Poll that endpoint periodically and ingest the delta.
Option C — Intercept at the HTTP layer
If OpenClaw proxies LLM calls, instrument the proxy layer to capture token usage from response headers/body before forwarding.
Option D — LiteLLM callback (if applicable)
If OpenClaw routes through LiteLLM, register agentwatch as a LiteLLM callback — it already has a LiteLLMCallbackHandler.
Acceptance criteria
- Models tab shows at least model name, request count, and token totals from real OpenClaw sessions
- Data updates within a reasonable lag (ideally <1 min)
- No manual instrumentation required per-session
Related
Problem
The Models tab (
/models) exists and the ingestion pipeline is ready, but it shows no data because OpenClaw gateway does not currently emitmodel:used(or equivalent) events.The
index.tshook handler was written to handleconversation:start/endandmodel:usedevents, but these are not fired by the gateway in v2026.3.x.Goal
Populate the Models tab with real per-model token, cost, and latency data from OpenClaw sessions.
Investigation paths
Option A — OpenClaw gateway emits model usage events
Check if OpenClaw has (or plans) any event that includes model name, token counts, and cost. If a
model:usedorsession:completeevent exists or can be added, updatehandler.tsto capture it and POST toPOST /api/v1/ingest/model_usage.Option B — Parse session status API
OpenClaw likely exposes per-session model usage via its status/billing API. Poll that endpoint periodically and ingest the delta.
Option C — Intercept at the HTTP layer
If OpenClaw proxies LLM calls, instrument the proxy layer to capture token usage from response headers/body before forwarding.
Option D — LiteLLM callback (if applicable)
If OpenClaw routes through LiteLLM, register
agentwatchas a LiteLLM callback — it already has aLiteLLMCallbackHandler.Acceptance criteria
Related
examples/openclaw-hook/index.ts— forward-looking handler, ready when events existexamples/openclaw-hook/handler.ts— current active handler (does not capture model usage)