AI agent usage logs Lista

One row per LLM call a Chatwoot/iframe/specialist agent turn made — README_AIAGENTUSAGE_TOKENS.md. `bots/engine.py::run_bot_turn` already computes `usage` (token buckets) and `cost_usd` (real cost under the provider's pricing) for every turn, but until this model existed that number only ever reached a `logger.info` line ("bots.cost: ...") and was discarded — there was no way to answer "how much did agent X spend last week" without grepping raw server logs with no `agent_key` in the line. Written best-effort right after each `run_bot_turn` call (see `bots/usage_tracking.py::record`) — a failure saving this row must never break the reply the customer is waiting for.

Campo Descrição
Agente de IA Null only for a turn where bot_config carried no agent_id — should not happen on the DB-backed path, kept nullable defensively so a bad turn never loses the whole row.
Empresa
Conversa Channel-qualified conversation id, e.g. chatwoot:536 — empty for synthetic test turns with no real conversation behind them.
Canal Opções:
  • Chatwoot
  • Iframe (test channel)
  • Synthetic test (handle_test_message)
  • Internal specialist call (orchestrator)
Modelo de LLM
LLM calls in this turn A turn may loop through several API calls (tool-use round-trips) — this is the count actually accumulated, not always 1.
Tokens de entrada
Tokens de saída
Tokens de leitura de cache
Tokens de criação de cache
Cost (USD) Real cost of this turn under the provider's per-token pricing (bots/engine.py::usage_cost_usd) — not a raw token count, an output token costs several times an input one.

AI agent usage logs Tiene los siguientes módulos relacionados y puede ser de su interés: