Skip to content

Gateway /status command always reports 0 tokens #11087

@rustyorb

Description

@rustyorb

Bug

The /status command in Discord/Telegram/etc always shows Tokens: 0 regardless of how many tokens the session has consumed.

Root Cause

SessionEntry.total_tokens is initialized to 0 in the dataclass constructor and never updated during the session lifecycle. The agent tracks cumulative tokens internally on agent.session_total_tokens, but that value is never written back to the session store's SessionEntry.

The update_session() method only accepts last_prompt_tokens — there's no pathway for total_tokens to be persisted.

Steps to Reproduce

  1. Start a gateway session (Discord, Telegram, etc.)
  2. Send a few messages so the agent consumes tokens
  3. Run /status
  4. Observe Tokens: 0

Expected Behavior

/status should show the cumulative token count for the current session.

Fix

PR incoming — adds total_tokens parameter to update_session() and pipes agent.session_total_tokens through the result dict after each agent run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliverytype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions