Skip to content

CLI: record per-turn token usage and model in chat-messages.json #1779

Backlog

Description

@pondorasti

from pondorasti's bot:

What problem are you trying to solve?

tokenmaxxing.sh, a public leaderboard for AI coding agent usage, counts usage through ccusage, which reads the session files coding agents leave on disk. Our users asked us to support Freebuff (851-labs/tokenmaxxing#185), but Freebuff usage can't be counted today: its chat files carry no token counts and no model name.

Tested with Freebuff 0.2.38 (CLI, signed in, two short prompts on the default DeepSeek V4.1 Flash Fast). Chats land in ~/.config/manicode/projects/<project>/chats/<id>/, the same layout as the Codebuff CLI, but every assistant message in chat-messages.json looks like this:

{"variant":"ai","timestamp":"02:27 PM","metadata":{"allowInlineAds":true},"isComplete":true,"completionTime":"1s","credits":0}

run-state.json only has the current contextTokenCount and creditsUsed: 0, and log.jsonl names the model by an opaque id. Older builds kept the run state, usage included, in the message metadata; that has since moved out of chat-messages.json.

What would you like to happen?

Record per-turn usage on each assistant message in chat-messages.json, for example:

  • metadata.usage: input, output, cache read and cache write tokens
  • metadata.model: the provider model id, e.g. deepseek/deepseek-v4-flash

ccusage's codebuff reader already reads these fields. Adding them by hand to one message of the test chat made that turn show up with the right tokens and cost, so nothing else would be needed on the reading side.

Area

CLI (terminal client)

Activity

  1. added
    area:cli
    bot:triaged
    type:feature
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibot:triagedtype:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions