[Skip to content](https://github.com/NousResearch/hermes-agent/pull/76596#start-of-content)

You signed in with another tab or window. [Reload](https://github.com/NousResearch/hermes-agent/pull/76596) to refresh your session.You signed out in another tab or window. [Reload](https://github.com/NousResearch/hermes-agent/pull/76596) to refresh your session.You switched accounts on another tab or window. [Reload](https://github.com/NousResearch/hermes-agent/pull/76596) to refresh your session.Dismiss alert

{{ message }}

## Conversation

[![@webtecnica](https://avatars.githubusercontent.com/u/75556242?s=80&v=4)](https://github.com/webtecnica)

### ![@webtecnica](https://avatars.githubusercontent.com/u/75556242?s=48&v=4)**[webtecnica](https://github.com/webtecnica)**     commented   [on Aug 2Aug 2, 2026](https://github.com/NousResearch/hermes-agent/pull/76596\#issue-5040813294)


Copy link


Copy Markdown

Closes [#76589](https://github.com/NousResearch/hermes-agent/issues/76589)

## Summary

Adds a `hermes sessions cost` CLI command that reports per-session token usage, cache-hit rate, estimated cost, and the counterfactual cost if the prompt cache had never hit — surfacing data Hermes already collects (`input_tokens`, `cache_read_tokens`, `cache_write_tokens`, `output_tokens`, `estimated_cost_usd` on the `sessions` table via `update_token_counts` / `record_auxiliary_usage`).

```
hermes sessions cost                  # table across recent sessions
hermes sessions cost --session <id>   # detail for one session (id or unique prefix)
```

Per session it reports:

- `input_tokens` / `cache_read_tokens` / `cache_write_tokens` / `output_tokens`
- cache-hit % = `cache_read / (input + cache_read + cache_write)`
- estimated cost actually paid (the recorded `estimated_cost_usd`)
- estimated cost if cache had been 0% (counterfactual) and the savings delta
- a `⚠` marker when cache-hit drops below 70% — the signal that a workspace switch, toolset swap, or compression invalidated the prompt prefix

## Counterfactual estimate

Provider per-token price splits are not persisted, so the "no-cache" cost is a documented estimate: the recorded cost is attributed to the input side in proportion to token counts, then the cache-read share is re-priced as if billed at the cold input rate. The cache→cold price ratio is configurable:

```
cost:
  cache_hit_ratio: 0.10   # cache reads = 10% of cold input price (default)
```

Conservative default `0.10` (e.g. DeepSeek ~10x, OpenAI/Anthropic 5x spreads); values outside `(0, 1]` fall back to the default. No new env vars, no new model tools, no provider-specific logic — pure edge expansion of the existing `sessions` command.

## Files

- `hermes_cli/session_cost.py` — new pure computation/formatting helpers (breakdown, config read, formatting)
- `hermes_cli/sessions_cmd.py` — `cost` action dispatch alongside `list`/`delete`/`export`
- `hermes_cli/main.py` — `sessions cost` subparser (`--session`, `--limit`, `--source`) \+ help strings
- `hermes_cli/config_defaults.py` — `cost.cache_hit_ratio` default
- `tests/hermes_cli/test_session_cost.py` — unit tests for the breakdown math, config fallback, formatting
- `tests/hermes_cli/test_sessions_cost_cli.py` — CLI integration tests (table, flags, detail, not-found)

## Test plan

- `pytest tests/hermes_cli/test_session_cost.py tests/hermes_cli/test_sessions_cost_cli.py` — 32 passed
- Existing sessions tests (`test_sessions_delete.py`, `test_sessions_size_delta_label.py`, `test_sessions_export_md_cli.py`, `test_session_filters.py`, `test_session_browse.py`, `test_aux_usage_accounting.py`) — 37 passed, no regressions
- Config suites (`test_config.py`, `test_config_validation.py`, `test_set_config_value.py`, `test_fast_command.py`) — 183 passed; the new `cost` root key is auto-accepted since `_KNOWN_ROOT_KEYS` is derived from `DEFAULT_CONFIG`

Sorry, something went wrong.


### Uh oh!

There was an error while loading. [Please reload this page](https://github.com/NousResearch/hermes-agent/pull/76596).

All reactions

[![@webtecnica](https://avatars.githubusercontent.com/u/75556242?s=40&v=4)](https://github.com/webtecnica)

`
          feat(sessions): add cost/cache-hit report command (NousResearch#76589)
`

Loading

Loading status checks…

### Uh oh!

There was an error while loading. [Please reload this page](https://github.com/NousResearch/hermes-agent/pull/76596).

`
          2cee5c1
`

[![@webtecnica](https://avatars.githubusercontent.com/u/75556242?s=40&v=4)](https://github.com/webtecnica)[webtecnica](https://github.com/webtecnica)

mentioned this pull request
[on Aug 2Aug 2, 2026](https://github.com/NousResearch/hermes-agent/pull/76596#ref-issue-5040773026)

[\[Feature\]: hermes sessions cost — per-session cache-hit and savings report\\
#76589](https://github.com/NousResearch/hermes-agent/issues/76589)

Open

[![@alt-glitch](https://avatars.githubusercontent.com/u/52913345?s=40&u=b0d1b58e0f8358f695a038e6f8c8dcf02e5963b0&v=4)](https://github.com/alt-glitch)[alt-glitch](https://github.com/alt-glitch)

added
[type/feature](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Atype%2Ffeature) New feature or request [comp/cli](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Acomp%2Fcli) CLI entry point, hermes\_cli/, setup wizard [area/sessions](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Aarea%2Fsessions) Session lifecycle, resume, persistence, history [area/usage-cost](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Aarea%2Fusage-cost) [P3](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3AP3) Low — cosmetic, nice to have [sweeper:risk-compatibility](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Asweeper%3Arisk-compatibility) Sweeper risk: may break existing users, config, migrations, defaults, or upgrades

labels

[on Aug 2Aug 2, 2026](https://github.com/NousResearch/hermes-agent/pull/76596#event-28837516073)

[![teknium1](https://avatars.githubusercontent.com/u/127238744?s=60&v=4)](https://github.com/teknium1)

**[teknium1](https://github.com/teknium1)**

reviewed

[on Aug 2Aug 2, 2026](https://github.com/NousResearch/hermes-agent/pull/76596#pullrequestreview-4837366190)

[View reviewed changes](https://github.com/NousResearch/hermes-agent/pull/76596/files/2cee5c177958cda78c2a241d92d2b06bf34889d0)

### ![@teknium1](https://avatars.githubusercontent.com/u/127238744?s=48&v=4)**[teknium1](https://github.com/teknium1)**     left a comment


Copy link


Copy Markdown

Collaborator

There was a problem hiding this comment.

### Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. [Learn more](https://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment).


Choose a reason
SpamAbuseOff TopicOutdatedDuplicateResolvedLow QualityHide comment

Thanks for building this as a CLI-edge feature; current main has the session usage fields but no equivalent `sessions cost` command.

### Problems

- `hermes_cli/session_cost.py:87` turns every non-null stored cost into a known price. Unknown pricing returns `amount_usd=None` with `status="unknown"` in `agent/usage_pricing.py:1320`, and `hermes_state.py:4341` persists that missing estimate as zero. The report would therefore show an unavailable cost as `$0.0000` and derive zero no-cache cost/savings.
- The new command and `cost.cache_hit_ratio` setting are absent from the existing command/config documentation surfaces (`website/docs/reference/cli-commands.md:1447`, `website/docs/user-guide/sessions.md:280`).

### Suggested changes

- Use `cost_status` to distinguish unknown, included, and estimated costs; add a regression case for an unknown-cost zero row.
- Add user documentation for the command, its counterfactual assumptions, and the configuration key.

Automated hermes-sweeper review.

Sorry, something went wrong.


### Uh oh!

There was an error while loading. [Please reload this page](https://github.com/NousResearch/hermes-agent/pull/76596).

All reactions

Comment thread[hermes\_cli/session\_cost.py](https://github.com/NousResearch/hermes-agent/pull/76596/files/2cee5c177958cda78c2a241d92d2b06bf34889d0#diff-22620c76c54659d443b307d46f4d967183ae5c74f6ef280aadeef902a774af99)

|     |     |     |
| --- | --- | --- |
|  |  | Returns a dict with: |
|  |  |  |
|  |  | \\* \`\`input\_tokens\`\` / \`\`cache\_read\_tokens\`\` / \`\`cache\_write\_tokens\`\` / |
|  |  | \`\`output\_tokens\`\` — the per-type totals (ints) |

### ![@teknium1](https://avatars.githubusercontent.com/u/127238744?s=48&v=4)**[teknium1](https://github.com/teknium1)** [on Aug 2Aug 2, 2026](https://github.com/NousResearch/hermes-agent/pull/76596\#discussion_r3697998974)


Copy link


Copy Markdown

Collaborator

There was a problem hiding this comment.

### Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. [Learn more](https://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment).


Choose a reason
SpamAbuseOff TopicOutdatedDuplicateResolvedLow QualityHide comment

Please distinguish an unknown stored estimate from a real zero-cost session. `estimate_usage_cost()` returns `amount_usd=None, status="unknown"` when pricing is unavailable (`agent/usage_pricing.py:1320`), while `update_token_counts()` persists that missing delta as zero (`hermes_state.py:4341`); this conversion would display that case as a known `$0.0000` cost and zero savings.

Sorry, something went wrong.


### Uh oh!

There was an error while loading. [Please reload this page](https://github.com/NousResearch/hermes-agent/pull/76596).

All reactions

[![@teknium1](https://avatars.githubusercontent.com/u/127238744?s=40&u=b17ed1d4d68a017b076db1f674491d2896d6076d&v=4)](https://github.com/teknium1)[teknium1](https://github.com/teknium1)

added
the [sweeper:blast-contained](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Asweeper%3Ablast-contained) Sweeper blast radius: contained — one narrow path / opt-in / few users
label

[on Aug 2Aug 2, 2026](https://github.com/NousResearch/hermes-agent/pull/76596#event-28838223556)

[![@GottZ](https://avatars.githubusercontent.com/u/559564?s=80&u=83019299bbbe9a83a3c282599124c3df56d53e86&v=4)](https://github.com/GottZ)

### **[GottZ](https://github.com/GottZ)**     commented   [on Aug 3Aug 3, 2026](https://github.com/NousResearch/hermes-agent/pull/76596\#issuecomment-5167425217)


Copy link


Copy Markdown

|     |
| --- |
| > _This was generated by AI during triage._<br>#### Summary<br>One PR, [#76596](https://github.com/NousResearch/hermes-agent/pull/76596), directly addresses [#76589](https://github.com/NousResearch/hermes-agent/issues/76589) by adding a `hermes sessions cost` table and per-session detail view over existing token, cache, and estimated-cost fields, including counterfactual savings and low-hit warnings.<br>#### Related pull requests<br>- [feat(sessions): hermes sessions cost — cache-hit and savings report (#76589) #76596](https://github.com/NousResearch/hermes-agent/pull/76596)`best fix` — (+693/-1) — partial fix: [feat(sessions): hermes sessions cost — cache-hit and savings report (#76589) #76596](https://github.com/NousResearch/hermes-agent/pull/76596) implements the requested CLI reporting, calculations, configuration, and tests, but the diff treats every persisted zero cost as a known `$0.0000` even though unavailable pricing is also persisted as zero. Consistent with the keep\_open review on [feat(sessions): hermes sessions cost — cache-hit and savings report (#76589) #76596](https://github.com/NousResearch/hermes-agent/pull/76596), it must use `cost_status` to distinguish unknown, included, and estimated costs, add an unknown-cost zero-row regression test, and document the command and its configuration and counterfactual assumptions.<br>#### Suggested consolidation<br>Keep [#76596](https://github.com/NousResearch/hermes-agent/pull/76596) open with a salvage path: preserve its CLI-edge command, cache-hit reporting, counterfactual calculation, warning marker, and tests, while requiring the `cost_status` handling, regression coverage, and documentation requested by the contributor review before it resolves [#76589](https://github.com/NousResearch/hermes-agent/issues/76589). There are no duplicate PRs to close.<br>#### Complex graph<br>Render<br>best fix<br>[issue #76589 (open)](https://github.com/NousResearch/hermes-agent/issues/76589) [PR #76596 (open)](https://github.com/NousResearch/hermes-agent/pull/76596)<br>Loading<br>```<br>flowchart LR<br>    classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a<br>    classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d<br>    classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937<br>    classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151<br>    classDef best stroke-width:3px,stroke:#b45309<br>    classDef target stroke-width:3px,stroke:#4338ca<br>    I76589(["issue #76589 (open)"])<br>    P76596["PR #76596 (open)"]<br>    P76596 -->|best fix| I76589<br>    class I76589 open<br>    class P76596 open<br>    class P76596 best<br>    class P76596 target<br>    click I76589 "https://github.com/NousResearch/hermes-agent/issues/76589"<br>    click P76596 "https://github.com/NousResearch/hermes-agent/pull/76596"<br>```<br>_Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label)._<br>_Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 28 kB of PR diffs, 5 kB of issue/PR text, 3 kB of discussion (3 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch._ |

All reactions

Sorry, something went wrong.


### Uh oh!

There was an error while loading. [Please reload this page](https://github.com/NousResearch/hermes-agent/pull/76596).

[![@alt-glitch](https://avatars.githubusercontent.com/u/52913345?s=40&u=b0d1b58e0f8358f695a038e6f8c8dcf02e5963b0&v=4)](https://github.com/alt-glitch)[alt-glitch](https://github.com/alt-glitch)

added
[area/billing](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Aarea%2Fbilling) Account usage, credit usage, billing (cross-cutting)

and removed
[area/usage-cost](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Aarea%2Fusage-cost)

labels

[8 hours agoOct 17, 2026](https://github.com/NousResearch/hermes-agent/pull/76596#event-33512535494)

### This branch has not been deployed

No deployments


This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
[Learn more about bidirectional Unicode characters](https://github.co/hiddenchars)

[Show hidden characters](https://github.com/NousResearch/hermes-agent/pull/76596)

[Sign up for free](https://github.com/join?source=comment-repo) **to join this conversation on GitHub**.
Already have an account?
[Sign in to comment](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNousResearch%2Fhermes-agent%2Fpull%2F76596)

### Reviewers

[![@teknium1](https://avatars.githubusercontent.com/u/127238744?s=40&v=4)](https://github.com/teknium1)[teknium1](https://github.com/teknium1)teknium1 left review comments

### Assignees

No one assigned

### Labels

[area/billing](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Aarea%2Fbilling) Account usage, credit usage, billing (cross-cutting) [area/sessions](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Aarea%2Fsessions) Session lifecycle, resume, persistence, history [comp/cli](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Acomp%2Fcli) CLI entry point, hermes\_cli/, setup wizard [P3](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3AP3) Low — cosmetic, nice to have [sweeper:blast-contained](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Asweeper%3Ablast-contained) Sweeper blast radius: contained — one narrow path / opt-in / few users [sweeper:risk-compatibility](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Asweeper%3Arisk-compatibility) Sweeper risk: may break existing users, config, migrations, defaults, or upgrades [type/feature](https://github.com/NousResearch/hermes-agent/issues?q=state%3Aopen%20label%3Atype%2Ffeature) New feature or request

### Projects

None yet

### Milestone

No milestone

### Development

Successfully merging this pull request may close these issues.

[\[Feature\]: hermes sessions cost — per-session cache-hit and savings report](https://github.com/NousResearch/hermes-agent/issues/76589)

### 4 participants

[![@webtecnica](https://avatars.githubusercontent.com/u/75556242?s=52&v=4)](https://github.com/webtecnica)[![@GottZ](https://avatars.githubusercontent.com/u/559564?s=52&v=4)](https://github.com/GottZ)[![@teknium1](https://avatars.githubusercontent.com/u/127238744?s=52&v=4)](https://github.com/teknium1)[![@alt-glitch](https://avatars.githubusercontent.com/u/52913345?s=52&v=4)](https://github.com/alt-glitch)

Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

You can’t perform that action at this time.