Commit Graph
3 Commits
Author SHA1 Message Date
Andres TuulandClaude Opus 5 5e6c8f9e1f fix(lib): reject invalid token counts and document the Fable/Mythos tier
`estimateCost` used `inputTokens` and `outputTokens` without validation.
A negative count yielded a negative cost, and a non-finite one yielded
NaN. That matters here specifically because this module backs the
cost-aware-llm-pipeline budget skill: `NaN > budget` is false, so a
corrupt token count silently passes the budget check it exists to
enforce. It now throws a RangeError naming the offending field.

The unknown-model fallback to sonnet rates deliberately stays fail-open:
that degrades an estimate, whereas these inputs corrupt one.

Separately, the estimator prices Fable and Mythos at $10/$50 per million
tokens, but all three pricing tables (the skill and its ja-JP and zh-CN
translations) listed only Haiku, Sonnet, and Opus, so a reader could not
budget for two supported model families. Added the missing row to each.

16 of the new assertions fail against the previous behaviour (23 passed,
16 failed) and all pass with the guard (39 passed).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KV43bDJpgyMPovT2CHAoba
2026-08-08 20:28:04 +03:00
Andres Tuul 39416e3cdd fix(lib): correct stale model rates in the shared cost estimator and skill
`scripts/lib/cost-estimate.js` carries a second, independent copy of the
rate table that `scripts/hooks/cost-tracker.js` had, with the same defect:
every `opus` model priced at $15/$75, which are Claude 3 Opus era rates.
Opus 4.5 and later bill at $5/$25, so every current-generation Opus
estimate was exactly 3x real spend. Two more errors in the same table:
`haiku` was $0.80/$4.00, which is Claude 3.5 Haiku rather than Haiku 4.5's
$1/$5; and Fable and Mythos had no bucket at all, so they fell through to
`sonnet` and were understated 3.3x.

Legacy buckets are added rather than overwriting, so correcting the current
generation does not reprice the old one. `opusLegacy` keeps $15/$75 for the
three models that really billed it (Claude 3 Opus, Opus 4.0, Opus 4.1) and
`haikuLegacy` keeps $0.80/$4.00 for Claude 3.5 Haiku. The matching regexes
are the ones already used by the cost tracker, so the two tables now agree
on which model is legacy. Opus 4.0's snapshot is `claude-opus-4-20250514`
with no minor segment, which is why the bare `opus-4-<date>` form is
matched separately: an `opus-4-0` substring alone misses it.

`skills/cost-aware-llm-pipeline/SKILL.md` and its zh-CN and ja-JP
translations published the same stale numbers as prose. The Relative Cost
column is derived from the rates, so it is corrected with them: against a
corrected Haiku 4.5 baseline the multiples are now exact, which is why the
approximation markers are dropped.

`RATE_TABLE` keeps its existing keys and shape, so the export stays
backward compatible.

Tests: the existing test pinned the stale values and was updated to pin the
correct ones. Coverage is added for each legacy spelling (alias, dated
snapshot, Vertex `@` form, Bedrock prefix), for the current Opus line, and
for the Fable and Mythos bucket.
2026-08-06 22:36:24 +03:00
Affaan MustafaandAffaan Mustafa 940135ea47 feat: add ECC statusline observability hooks
Salvages the useful statusline/context monitor work from stale PR #1504 while preserving the current continuous-learning hook runner wiring.

Adds the metrics bridge, context monitor, statusline script, shared cost/session bridge utilities, and tests. Fixes the reviewed false loop-detection hash collision for non-file tools, avoids default-session cost inflation, sanitizes statusline task lookup, and records hook payload session IDs in cost-tracker.
2026-05-11 23:44:06 -04:00