Install any skill in seconds. Free to start, no credit card required.
Get Started Free →lingtai-ai/dev-guide-cache-hit-rate
Nested lingtai-dev-guide reference for computing the recent prompt-cache hit rate from LingTai token ledgers over rolling windows (default 1h / 5h / 1d / 3d). Explains the provider-agnostic input/cached fields in logs/token_ledger.jsonl, the exact formula (sum(cached)/sum(input) per window), timestamp/timezone handling, the daemon double-count hazard, and ships a read-only stdlib script (scripts/cache_hit_rate.py) that aggregates an agent workdir, a project root, or a single ledger file. Use whe
Passed 17 of 20 test cases with the skill, and 10 of 20 without it.
and 10 more in the full report
10 fixed10 passed either way2 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 9 test cases the skill fixed. Same model, same prompt, with and without the skill.
We want to run `scripts/cache_hit_rate.py` on an agent workdir but restrict the analysis strictly to turns originated by the `soul` process while ignoring `tc_wake` or `daemon` entries. Which command-line option should be used?
| Checked | Without skill | With skill |
|---|---|---|
| Passes `--source soul` to filter log entries by source tag. | Missed | Passed |
The instructions your model reads when the skill loads.
Nested lingtai-dev-guide reference. Read this after the top-level router sends
you here when you need to know how well prompt caching has been working
recently for one or more LingTai agents, grounded in the token ledger rather
than guessed.
This pairs with reference/runtime-self-check/SKILL.md §6: when a cache/affinity
fix "should be live," the token ledger is the observable that proves it. This
reference is the measurement; runtime-self-check is the
did-the-object-rebuild diagnosis.
A read-only metric. It only reads append-only logs/token_ledger.jsonl
files; it never writes, rotates, or mutates runtime state. Report rates without
pasting private absolute paths into human-facing deliverables — the ledger holds
no secrets, but its parent paths can be private, so generalize to
~/.lingtai-tui/... or <project>/.lingtai/<agent>/.
Single source of truth: logs/token_ledger.jsonl, one JSON object per LLM call,
written after every call by lingtai/kernel/token_ledger.py
(append_token_entry). Required fields:
| Field | Meaning |
|---|---|
ts | Call time, UTC, %Y-%m-%dT%H:%M:%SZ (always Z/UTC). |
input | Total prompt/input tokens for the call. Already includes the cached portion. For the Anthropic/Claude adapters this is raw_input + cache_read + cache_write. |
output | Output tokens. |
thinking | Reasoning/thinking tokens. |
cached | Cache-read input tokens served from the provider prompt cache. A subset of input. |
model, endpoint | Attribution (which model / base_url produced the tokens). |
Optional tags on some entries: source (main, soul, tc_wake, daemon),
and for daemon-attributed rows em_id / run_id / api_call_id / codex_*.
The kernel normalizes every provider's usage into these same fields before
writing, so the metric is provider-agnostic (verified across gpt-5.5,
test cases passed, vs 10 / 20 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.