Repository navigation
feat(agents): Hermes and Codex give each turn's counts by model - #896
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…delUsage.of, and the sandboxed proxy gives rows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
marked this pull request as ready for review
November 23, 2026 21:15
…in one place, and Hermes names its turn's models in a function of its own Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes
The last of P16 (FD-6744): Hermes and Codex give each turn's counts by model (
Usage.models, #887), so each model a turn used is priced at its own rate. The other agents switch to the protocol helper #893 added.CodexResult.threads: the turn's own thread, then each subagent's) with the model its rollout last ran on, read from the rollout'sturn_context. One reader,read_rollout, now reads a rollout's running total, its request count and that model in one pass, in place of a function each.spawn_agentcan start a subagent on another model, so this matters for Codex. A thread whose rollout names no model counts as the turn's configured model; with none known, the turn gives no rows and is priced at the role's model.delegate_taskchild inherits it, as the profile the bridge writes pins no other. The usage file names the main loop's model; thepost_api_requestevents name each child's (and, for a killed turn, each call's). A turn whose calls named more than one model gives no rows rather than guess how they split.ModelUsage.of(feat(agents): Claude Code, Gemini, OpenCode, Letta Code and the proxy give each turn's counts by model #893), as the proxy's does.Usage.models.ModelUsage.of(0.1.641 and 0.1.642 never reached PyPI).Tests
tst/unit/agents/codex/test_usage.py: a subagent on another model is that model's row, with the calls each thread made; a thread whose rollout names no model counts as the turn's; none known gives no rows.tst/unit/agents/hermes/test_message_contract.py: a turn's counts, its title call's and a child's included, are its model's one row, with Hermes' cost when it priced every call; calls naming two models give no rows; a killed turn's row is the model its calls named.ModelUsage.of.E2E against the real proxy
On an admin host, through a logging pass-through in front of the real proxy, each run's solver entry was compared row by row with the proxy's own count for each model its calls named, and each row's cost with the map's price of the proxy's counts.
gpt-5.6-solparent, subagent ongpt-6-lunadelegate_taskchild, title callModelUsage.of)gpt-6-lunasubagent's two calls cost $0.0019 at its own rate, beside the parent's $0.0588.gpt-5.3-codexparent (OpenAI) with agpt-5.6-solorgpt-6-lunasubagent (Azure OpenAI): every subagent request ends inresponse.failed(invalid_encrypted_content, the parent's encrypted reasoning can't be read there), so the subagent used nothing. The two-model run above keeps both on Azure.gpt-5.4-miniisn't one Codex 0.162.1 letsspawn_agentchoose.Model spend: about $1.25 at list prices.
Docs
For FD-6263 and FD-6442: Hermes and Codex give their counts by model, so every shipped agent that knows its calls' models now does (Claude Code, Gemini, OpenCode, Letta Code, Hermes, Codex, the proxy, sandboxed and in-process). Through Scale's proxy, a Codex subagent on a model the proxy routes to another provider than its parent's fails (
invalid_encrypted_content: the parent's encrypted reasoning can't be read there).🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable new issues were found.Summary
Codex and Hermes now report turn usage by model. Gemini and the shared relay use
ModelUsage.of, and agent requirements raise the protocol floors.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR C[Codex thread rollouts] --> T[Turn counts per thread] T --> M[Usage.models] H[Hermes usage file and child events] --> S{One named model?} S -->|Yes| M S -->|No| U[Turn totals only] M --> P[Price each model separately]Reviews (5) · Last reviewed commit: "refactor(agents): Codex reads each rollo..." · Reviewed by Greptile