用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/lukemcqueen/hermes-cortex --skill llm-cost-optimization命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | llm-cost-optimization |
| description | Cut LLM API spend: cache-hit rate, thinking mode, telemetry. |
| version | 1.1.0 |
| category | devops |
| platforms | ["linux","macos"] |
| aliases | ["llm-cost-engineering"] |
| metadata | {"hermes":{"tags":["cost","cache","tokens","llm","deepseek","observability","spending"],"related_skills":["cron-cost-tracking","cron-cost-scheduling"]}} |
Class-level playbook for reducing LLM API spend on a fleet of agents. Built from the 2026-08-21 HC gaps party (Luke's fleet: $8/day pre-hike → $15–20/day after DeepSeek's Aug-16-2026 price increase; target <$10/day). Consolidated 2026-08-22: absorbed llm-cost-engineering (pricing mechanics, audit reading, installer pitfalls, verification).
For DeepSeek v4-flash (and most providers with automatic prefix caching), the price spread between cache-hit and cache-miss input tokens is ~31× ($0.007/M hit vs $0.22/M miss off-peak). Output tokens are a distant second driver. Every cost conversation starts with: what is the cache-hit rate, and is the prefix stable?
| Scenario (50M prompt tokens/day) | $/day |
|---|---|
| 95% cache hit | ~$1.2 |
| 80% cache hit | ~$4.5 |
| 70% cache hit | ~$8.5 |
| 50% cache hit | ~$13.6 |
prompt_cache_hit_tokens / prompt_cache_miss_tokens).prompt_tokens in audit logs is cumulative across turns, not per-call.
A 26M-token "run" is a long session (100+ turns re-sending growing context),
not a single giant call — 1M context limits make single calls impossible.usage_audit.jsonl should carry
cache_read_tokens/cache_write_tokens; without the split every cost claim
is a guess. Verify capture is actually LOADED (gateway restart), not just
patched on disk — see the deployed≠loaded pitfall.Thinking/reasoning tokens are output-priced and NEVER cached. On a thinking
model, reasoning can be 6× the answer text (55K thinking vs 9K answer in a
normal session). Disable thinking on mechanical jobs (reasoning_effort: none on dreams, briefings, prunes, eval) — verified −54% output tokens on the
same job. Keep it on reasoning-heavy work (orchestrator decisions, diagnosis,
evaluation). Pin via the cron manifest so it survives deploys, not just live
jobs.json (live edits get reverted by cortex-update).
Same-session continuation is CHEAPER and better, because re-sent history is a cache hit (~31× cheaper than fresh content):
| Pattern | Cost (modeled) |
|---|---|
| 1×150 turns (same session) | $0.79 |
| 3×50 turns (3 sessions) | $0.48 |
| 5×30 turns (5 sessions) | $0.45 |
The long session costs only ~$0.30 more and that gap is history re-sends at hit price — the cheapest thing you can buy. The real enemies:
reasoning_effort: none does.Rule: keep one session while the topic is coherent AND the prefix stays stable. Start fresh only on a context switch or when the session is so large that compaction/rewrites fire (those bust cache worse than a fresh start).
prompt_tokens per run is CUMULATIVE across turns — a 26M-token "prompt" is a
long session re-sending growing context, NOT one 26M-token call (context cap
makes that impossible).references/interactive-session-cost-state-db.md — state.db sessions
table has interactive tokens+cost live).hermes cron edit --model/--reasoning-effort
writes jobs.json, but the next cortex-update re-registers crons from the
source of truth (cron-manifest.yaml / install-crons.sh). Fix the SOURCE first,
then the live jobs — or your "migration" silently reverts. The manifest and
the installer's pin function must both change (14-cron deepseek-chat→v4-flash
migration reverted exactly this way, 2026-08-21).hermes update. Auto-reapply via a
post-update hook (install-cron-cost-tracking.py --force); a missing
cost_store.py shows as 9× MISS in --status. 2 days of data out of 13 seen
2026-08-21.session_estimated_cost_usd) uses hermes-agent's stale
pre-hike pricing table for v4-flash (in 0.14/out 0.28/hit 0.0028 vs local
0.22/0.66/0.007). Fixed in cost_store.py: record_run recomputes at the local
schedule, reprice guard is now consistency-based (self-heals stale rows).
The daily REPORT was always correct (recomputes from usage_audit); only the
DB store under-reported. See cron-cost-tracking skill.old text wasn't found — verify the real file state, not the installer's word.cache_write_tokens 0 for ALL 4828 rows, so the naive
hit% = read/(read+write) reads a fake 100%. Root cause is UPSTREAM
(hermes-agent agent/usage_pricing.py): the cache_read side maps DeepSeek's
top-level prompt_cache_hit_tokens (line ~1373) but the cache_write fallback
chain (~1385–1400) checks only ,
, — NEVER
DeepSeek's complementary . Since
, the miss tokens land in and the
cost math stays correct (); only the hit-rate metric
lies. — measured 93–99% across
all cron jobs (7-day window, 2026-08-29), so the system-prompt prefix IS
byte-stable. Upstream fix candidate: add to the
cache_write fallback chain (task ).references/deepseek-cache-economics.md — canonical DeepSeek pricing table,
cache rules, thinking-mode switch (absorbed llm-cost-engineering's
deepseek-cache-cost-mechanics.md 2026-08-22).references/fleet-cost-data-sources.md — where each fleet cost number lives
(audit files, DBs, billing page) — from llm-cost-engineering.references/fleet-cost-levers-verified.md — session-verified lever results.references/daemon-restart-peak-pins-2026-08-21.md — restart-gap and peak-pin
session detail.references/interactive-session-cost-state-db.md — state.db sessions table as
the interactive-cost source.references/session-telemetry-reporting.md — session-specific detail behind
the playbook.details.cache_write_tokenscache_creation_input_tokensresponse_usage.cache_write_tokensprompt_cache_miss_tokensprompt_tokens = hit + missinput_tokensmiss = input + writeprompt_cache_miss_tokensorch-upstream-cache-write-fix