harness-core: model pricing + per-step cost accumulation (M3)

- types::ModelCost {input, output, cache_read, cache_write} (USD per 1M tokens)
  with cost_of(usage); reasoning tokens are billed within output by our providers
  so they are not charged separately. ModelInfo gains cost + reasoning/tool_call/
  attachment capability flags (all #[serde(default)] for forward-compat).
- Engine: RunConfig.cost threads pricing into process_step; on_finish now stamps
  the real dollar cost onto the StepFinish part; StepOutcome carries per-step cost.
- run_session accumulates each step's usage and cost onto the session (previously
  never updated) and republishes SessionUpdated — best-effort, store errors logged
  not fatal.
- Store gains a single-session getter (Session cmd + get_session).
- App passes cost: None for now (real rates land with models.dev wiring).
- Tests: ModelCost::cost_of math (+ reasoning exclusion), and the multi-step
  engine test now asserts session usage/cost accumulation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-08 23:45:21 +02:00
co-authored by Claude Opus 4.8
parent 39d62348d8
commit 2f3dfe2305
7 changed files with 151 additions and 11 deletions
+2
View File
@@ -254,6 +254,8 @@ impl EngineHandle {
temperature: None,
max_steps: DEFAULT_MAX_STEPS,
instructions: self.inner.config.instructions.clone(),
// Populated from models.dev metadata in the follow-up increment.
cost: None,
};
// Reserve the run slot *before* spawning. If we inserted after spawning, a run that