DEV Community

chovy
chovy

Posted on Originally published at dev.profullstack.com

A $315 agent session, and where the money actually went

One row in moshcode cost --all said $315.34. A single agent session, twenty hours, one worktree, 6,285 lines added and 397 removed.

I expected the output tokens to be the expensive part. They were not.

Where the money went

Splitting that row by token class:

  • cache reads: $252, which is 80 percent of it
  • one hour cache writes: $50
  • output tokens: $13
  • fresh input: under a dollar

437.9 million cache reads on Opus at $0.50 per million, plus 33.3 million on Fable at $1. The session generated 454,042 output tokens, which at $25 per million comes to $9.68.

So the bill is not what the model wrote. It is the context being read back on every single turn.

That changes which lever matters. Trimming a prompt does close to nothing here. The cost is roughly context size multiplied by turn count, and a twenty hour session has a lot of turns. A long session on a large context is expensive even if it produces almost nothing, and cheap-looking sessions are the short ones, not the quiet ones.

Worth knowing: this figure is an estimate. Claude Code records tokens and no price, because on a subscription the marginal request costs nothing extra, so moshcode multiplies by published API rates and marks the number with a ~. Claude Code's own internal accounting for the same session said $318.42, about 1 percent apart on the window I was looking at.

Then I wanted the PR

Once you notice a session that cost $315, the next thing you want is the thing it produced. That lives on GitHub, not on this machine, and the cost table had no way to get you there.

Claude Code already writes a pr-link record into its transcript when a session opens a pull request. Nothing was reading it.

moshcode 0.95.0 adds a pr column to moshcode cost and moshcode cost --all:

  session  engine  model          in    out  cache   cost    age  pr
  api      claude  claude-opus-5  1.2k  27k  10.5M   $9.91~  42m  view #128
  audit    codex   gpt-5.6-sol    400   200  600     -       12m  -
Enter fullscreen mode Exit fullscreen mode

view #128 is a link. Click it and the pull request opens in your browser.

Four characters wide, sixty characters of target

That cell is an OSC 8 hyperlink. The useful property is that the label and the click target are separate things: the terminal paints view #128 while the URI it hands your browser is the full GitHub URL. A plain URL column would have been sixty characters of table.

Two things had to change to make it line up. strip in our layout code only matched SGR colour sequences, so a cell with a URL hidden inside an escape would have measured sixty columns wide and pushed every other column off the right edge. And clip now copies an OSC 8 wrapper whole and closes one it cut into, because a terminal handed an opener with no closer keeps linking everything printed afterwards.

Not every terminal speaks OSC 8, and there is no way to ask one whether it does. Piped output prints the raw URL instead, and MOSHCODE_HYPERLINKS=0 forces that same plain form in a terminal that would otherwise paint a view nobody can click.

moshcode ps deliberately did not get the column. It runs in 0.22s, and the transcript scan the PR link comes from takes 1.75s. That is a nine times regression on the command you run constantly, for a cell that is empty while the work is still in progress.

moshcode upgrade self
Enter fullscreen mode Exit fullscreen mode

Top comments (0)