Skip to content

python: cost in flow view, estimated with its price table or unknown, per session and chain - #57

Merged
pwngh merged 1 commit into
mainfrom
view-cost
Dec 2, 2026
Merged

pwngh merged 1 commit into
mainfrom
view-cost

Conversation

@pwngh

@pwngh pwngh commented Dec 2, 2026

Copy link
Copy Markdown
Owner

flow view showed what each session did but not what it cost. The cost module from #33 existed but nothing displayed it.

Each session page now shows the session's cost and each chain's. A cost is "estimated" with the price table's version and SHA-256. It is "unknown" with the reason when there is no table, a price is missing or usage is missing, never zero. The table comes from flow view --prices FILE, else $FLOW_HOME/prices.json if it exists. A bad table, or a missing --prices file, stops flow view with a message, and the home's privacy check runs before the table is opened.

A response with an error status is not billed. A chain counts its rounds' answers and their earlier attempts. The session counts every answer in the file, side requests included.

Proof: 4 new tests in tests/viewer/test_view.py check a synthetic table against hand-computed totals (0.75 and 1.12 USD), unknown without a table and with a missing price, a refused bad table, and an answer without a model name. Python suite 512 passed.

Reviewed with sol-loop: 3 rounds with gpt-6.2-sol. Sol verdict: approved

Sol's fixes: a non-string model name is unknown, only an omitted --prices falls back to the default, and the privacy check comes first.

@pwngh
pwngh merged commit a2458ce into main Dec 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant