v0.42.0 — session spend cap for chat/code completions + /cost
Cost control for agent runs (#66): the chat completions themselves are now metered, not just paid asset tools. With DIEM on a use-or-lose Epoch cycle, an agent loop (chat --tools, code) can no longer run unbounded.
--session-max-spend USD— caps total chat-completion spend for the session/run. Each turn's server-reportedusageis priced against the session model's per-1M-token catalog rate; at the cap the loop stops starting new turns and forces a final answer (chat has no pre-call quote, so it bounds further spend, not a turn in flight). Config-backable viadefaults.chat.session_max_spend/defaults.code.session_max_spend.- Distinct from
--max-spend, which stays the per-call auto-approve cap for paid tools — the two are deliberately not conflated. /cost— REPL command to peek the session's running spend (tokens + USD when the model's price is known).- Graceful — a model with unknown pricing is token-counted, not charged;
0/negative = uncapped.
Works across chat --tools, the chat -i REPL (tool + streamed turns), and code one-shot + REPL. Prereq for the multi-agent epic (#52), whose listed risk is cost multiplication.
Closes #66. 563 tests green.