Skip to content

Dashboard Total Cost + LLM Calls miss bridge-routed models (MiniMax shows 0) #172

@arniesaha

Description

@arniesaha

Problem

Follow-up to #170 / #171. With MiniMax pricing added to the Python pricing.py, the MiniMax cost on the dashboard is still shown as $0 and the LLM Calls StatCard shows 0 even though the "LLM Calls over Time" chart correctly graphs MiniMax points.

Two independent bugs compound:

Bug 1 — bridge plugin never calls compute_cost

plugins/openclaw-agentweave-bridge/src/service.ts:385 does:

const costUsd = e.costUsd ?? 0
turn.span.setAttribute("cost.usd", costUsd)

The bridge takes the cost verbatim from OpenClaw's model.usage event. OpenClaw doesn't know MiniMax pricing and reports costUsd: 0, so the span lands in Tempo with cost.usd=0. The Python proxy's pricing table isn't in the code path at all for these calls.

Verified live on the NAS — e.g. trace 7e82c92b4016da69ba7715097549f71e:

prov.llm.model       = MiniMax-M2.7-highspeed
prov.llm.prompt_tokens    = 92
prov.llm.completion_tokens = 168
prov.llm.cache_read_tokens = 139257
cost.usd             = 0     ← should be ~ $0.005

Bug 2 — dashboard filter excludes agent_turn spans

dashboard/src/lib/queries.ts:49tempoSearchQuery filters on span.prov.activity.type = "llm_call". But the openclaw bridge emits openclaw.turn spans with prov.activity.type = "agent_turn", so these are excluded from traceRows. Both the LLM Calls count and Total Cost StatCard derive from traceRows, which is why both show 0 even though the Prometheus-backed chart (which queries traces_spanmetrics_calls_total) shows the calls.

Fix

  1. Bridge pricing fallback — add a TS pricing table (kept in sync with sdk/python/agentweave/pricing.py) and a resolveCost(upstream, model, tokens) that prefers a positive upstream value and falls back to the local table when upstream is 0, negative, or NaN. Wire it into the model.usage handler.
  2. Dashboard filter widen — include agent_turn spans that have a prov.llm.model attribute alongside llm_call spans.

Acceptance criteria

  • New MiniMax spans have cost.usd > 0 in Tempo.
  • Dashboard LLM Calls StatCard counts MiniMax calls.
  • Dashboard Total Cost StatCard sums MiniMax cost correctly.
  • Existing llm_call path (Python proxy → Anthropic/OpenAI/Google) is unaffected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions