External power-cost config for local/subscription models #49
Replies: 6 comments 9 replies
|
And as I sit here looking at this some more: Bonus — same DuckDB file could replace And the power config itself (loadWatts, costPerKwh, subscriptionEndpoints) could live in TT's web settings panel — same pattern as your OpenAI-compatible backend config. No external file needed for the primary path. The Pkl schema still works as a source-of-truth definition for the shape, and power users who want file-based config can use the companion tool instead of the web UI. No DB, you have your current defaults. Comment drafted with assistance from Ensemble (ENSEMBLE Framework v3.3.3 protocol on Hermes Agent). Accountable human: @Pauliehedron, Conductor |
Update — what shipped, and the roadmap to fully close thisShipped (PR #74): the core of this proposal is now implemented in-TT:
Validated end-to-end on a local Ollama Being upfront about what is not done yet — tracked for the next PR (
Insights layer (Phase 2, planned): energy (Wh/kWh) per session/day, savings-vs-cloud ("locally $0.0002; ~$0.05 on Claude Sonnet"), a per-model tok/s efficiency leaderboard, and an opt-in CO₂ estimate (kWh × grid intensity) — on a dedicated Local & Power view. Design principle we're adopting (Phase 3): as TT grows these insights, it must stay observably cheap on your machine — heavy features opt-in, low-duty sampling only during active sessions, on-demand not continuous. We plan to dogfood the power feature on TT itself ("TokenTelemetry used ~X Wh today"). On Pkl & the DuckDB sidecar: we took the in-TT path. Pkl we'll ship as an optional typed-source artifact; the DuckDB intermediate we're consciously not adopting (the in-TT read is simpler for users) — flagging that as a decision, not an oversight, happy to revisit if there's appetite for the companion-tool model. And the "one update script instead of chasing prices by hand" idea is now live via build-time models.dev pricing (PR #74). Thanks for the thorough write-up. |
|
TL;DR: Anthropic clarified their new policy for Claude subscriptions applicable from June 15, it confirms the exact multi-source billing complexity PowerConfig targets:
Kudos @VasiHemanth on shipping PR #74 and keep 'em coming ;-) |
|
Follow-up — the Phase 1 items I'd flagged as "not done yet" are now shipped ✅ (PR #100) Closing the loop on my last update, without repeating it:
Still open (tracked): auto-detecting wattage on non-Apple hardware (AMD/Intel/Windows), and live "pool % drained" meters — which need per-session interactive-vs-programmatic tagging to fill. |
|
Great idea. The fixed lookup table vs. external config distinction is exactly the right framing. One extension worth considering: for subscription/flat-rate endpoints, rather than showing cost=0 (which understates the true spend), show a "breakeven tokens" metric. Given the flat monthly price, compute how many tokens the session would have needed to cost on a per-token API to equal the subscription. That lets users see when a flat environment is winning vs. when they are over-provisioned. We run UltraWork on a flat monthly GPU box for exactly this comparison (https://vibecodingagency.com/gpu-cloud/), so this kind of TCO math is the first thing teams ask for. Disclosure: I help run Vibe Coding Agency. Happy to share the breakeven formula we use if useful. |
Uh oh!
There was an error while loading. Please reload this page.
TokenTelemetry's pricing table in
pricing.pymaps model names to per-1M-token USD rates. That works for API calls. But not every session fits that model:A fixed lookup table can't express any of these. An external config file can.
The Pkl schema:
Evaluated to JSON for TT:
{ "loadWatts": 80, "costPerKwh": 0.15, "subscriptionEndpoints": ["https://ollama.com/v1", "http://127.0.0.1:3000/v1"] }Per-session math:
For local sessions:
(output_tokens / real_tokens_per_second) * loadWatts / 3_600_000 * costPerKwhToken rate is computed from the agent's own logs (
out=NNN latency=N.Nsper API call), not a hardcoded estimate. Sessions hitting asubscriptionEndpointget cost=0.How it plugs in:
Two implementation options, same config shape:
In-TT (upstream change): Load
power.jsonalongside existing configs, branch incalculate_cost()for models with no API rate. ~10 lines of Python.Companion tool (no TT change): A standalone script that reads the power config, queries the agent's session database, computes per-session cost, and writes it back. TT picks it up on next refresh. Works if the agent stores session cost in a database TT already reads.
Why external config beats a fixed table:
subscriptionEndpointslistThree-way coverage:
power.jsonwith defaultspower.pklwith types, docs, defaultspower.jsonwith a text editorThe upstream would ship both
config/power.pkl(authored source, typed, documented) andconfig/power.json(pre-rendered, ready to use). Zero new dependencies for TT — it already reads JSON configs. Pkl stays optional for users who want it.No code submission — just the design artifact and the pattern.
Variant: Isolated Cost Cache (DuckDB intermediate)
If writing to the agent's internal database is too invasive for upstream adoption, an intermediate cache decouples the cost computation from the source of truth entirely.
Architecture:
Instead of
tt-power-costwritingestimated_cost_usddirectly into Hermes' state.db, it writes to its own DuckDB file (~/.tokentelemetry/power-cost.duckdb). TokenTelemetry reads the cost from DuckDB in addition to state.db — a two-source join unified in the dashboard.Why DuckDB fits the requirement:
The job for the companion tool: Owns the entire computation — reads the power config, parses agent logs for real token rates, writes per-session cost to the DuckDB file. The upstream doesn't compute anything; it just enriches a session view by checking a second source.
The job for the upstream: Optionally read a second database file. If present, prefer its
estimated_cost_usdover the API-rate fallback. That's it — ~2 lines of conditional logic, no new dependencies (DuckDB Python module is already common in the ecosystem, but you could also ship a CLI wrapper if you prefer zero dep overhead).How this compares to direct state.db write:
Idea drafted with assistance from Ensemble (ENSEMBLE Framework v3.3.3 protocol on Hermes Agent). Accountable human: @Pauliehedron, Conductor
All reactions