[PR #13945] [CLOSED] cmd: add /usage to chat to see token consumption #45700

Closed
opened 2026-04-25 01:21:36 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13945
Author: @BruceMacD
Created: 1/28/2026
Status: Closed

Base: mainHead: brucemacd/usage-cli


📝 Commits (1)

  • e6f5a98 cmd: add usage cmd to chat to see token consumption

📊 Changes

2 files changed (+19 additions, -8 deletions)

View changed files

📝 cmd/cmd.go (+7 -7)
📝 cmd/interactive.go (+12 -1)

📄 Description

Adding a /usage command to interactive cli chat sessions that displays the tokens used in the current sessions. This can be used alongside the models context window to understand when a context shift is going to happen.

The goal here is to demostrate how clients can track token usage to understand context window consumption.

$ ollama run gpt-oss:20b
>>> hi
Thinking...
The user says "hi". We need a friendly greeting, respond.
...done thinking.

Hello! 👋 How can I help you today?

>>> /usage
prompt tokens:     68
completion tokens: 35
>>> Send a message (/

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13945 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 1/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `brucemacd/usage-cli` --- ### 📝 Commits (1) - [`e6f5a98`](https://github.com/ollama/ollama/commit/e6f5a982d34bb2ec237b85debefd7943e1156b4d) cmd: add usage cmd to chat to see token consumption ### 📊 Changes **2 files changed** (+19 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+7 -7) 📝 `cmd/interactive.go` (+12 -1) </details> ### 📄 Description Adding a `/usage` command to interactive cli chat sessions that displays the tokens used in the current sessions. This can be used alongside the models context window to understand when a context shift is going to happen. The goal here is to demostrate how clients can track token usage to understand context window consumption. ```bash $ ollama run gpt-oss:20b >>> hi Thinking... The user says "hi". We need a friendly greeting, respond. ...done thinking. Hello! 👋 How can I help you today? >>> /usage prompt tokens: 68 completion tokens: 35 >>> Send a message (/ ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 01:21:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#45700