Commit Graph
419 Commits
Author SHA1 Message Date
lukaszraczylo 0ffd022a9f test(yaegi): check prompt-cache cost, injection and key under yaegi 2026-11-26 02:02:50 +00:00
lukaszraczylo cf1ae262d6 refactor(pricing): share one prompt token split 2026-11-26 01:55:17 +00:00
lukaszraczylo ee758d5d09 perf(limits): write prompt-cache counters for the model scope only 2026-11-26 01:55:06 +00:00
lukaszraczylo 2e687e90d9 fix(admin): read prompt-cache counters for returned rows only 2026-11-26 01:54:23 +00:00
lukaszraczylo 86870668ea fix(anthropic): keep system a string when marked parts are empty 2026-11-26 01:53:51 +00:00
lukaszraczylo 1618934cf7 docs: correct prompt-cache cost clamp wording
The clamp bounds token counts only. A cache write price above the input price can raise the cost above the all-uncached cost.
2026-11-26 01:43:32 +00:00
lukaszraczylo acf53491cc docs: prompt caching
Document the prompt-caching feature in the README. Add promptCache key to the openai provider in the catalog testData, and update the manifest test mirror.
2026-11-26 01:42:13 +00:00
lukaszraczylo 2fe798ad82 fix(openai): forward prompt_cache_key on translated messages only when enabled
The translated messages path copied any prompt_cache_key into the
upstream body, even with promptCache.key off. It now forwards the key
only when the provider opted in. The gateway key travels in a private
field, and a client key wins when present.
2026-11-26 01:37:52 +00:00
lukaszraczylo cff1761a21 feat(openai): opt-in per-conversation prompt_cache_key
When promptCache.key is set on an openai provider, the gateway sends a
hashed prompt_cache_key per conversation. The key is the SHA-256 of the
caller id and the session id. The session id is the client id, or the
system prompt plus the first user message.

The key is set only when the client sent no prompt_cache_key. It is set
on each attempt copy after the response-cache key is computed. It is not
stored, and it never carries a raw id.
2026-11-26 01:33:56 +00:00
lukaszraczylo 5ffd44874c feat(anthropic): opt-in rolling prompt-cache breakpoints
Add providers.<name>.promptCache with inject and key flags. When inject is true on an anthropic provider, the gateway adds up to four cache_control breakpoints. They go on the last tool, the last system block, and the last two user messages. The translated chat path and the /v1/messages passthrough both use it. A body that already has any cache_control is left unchanged. The input body is never mutated. The default config changes no request body.
2026-11-26 01:28:51 +00:00
lukaszraczylo bc77e16e45 fix(anthropic): keep client cache_control on translated system messages
The translator joined system and developer messages into one string.
This dropped any cache_control marker that the client set on a part.
Now, when a marker exists, system becomes a list of text blocks that
keep the marker. Without markers, the joined string is unchanged.
2026-11-26 01:22:08 +00:00
lukaszraczylo 8a530c1cb3 fix(admin): mirror backend detail parsing in the mock API
The mock now parses the detail query like the backend. Only 1 and true turn detail on. Other unknown values return 400. detail=0 and detail=false no longer return the prompt-cache fields.
2026-11-26 01:18:06 +00:00
lukaszraczylo 90ad08920a build(admin): regenerate embedded admin UI
Run make admin-ui to embed the prompt-cache hit rate UI.
2026-11-26 01:15:59 +00:00
lukaszraczylo c14ce25ce0 feat(admin): show prompt-cache hit rate per model
The usage model table and the model panel now show the prompt-cache hit rate. The Cost avoided card shows the prompt-cache saving as a separate line. The mock admin API fixtures carry the new fields.
2026-11-26 01:15:54 +00:00
lukaszraczylo fd8ca1e95a fix(admin): keep the legacy usage models shape for prompt-cache fields
The three prompt-cache fields are now optional pointers. Only the detail
view sets them, so the default response stays the same as before.
2026-11-26 01:08:48 +00:00
lukaszraczylo d661166eab feat(metrics): count prompt-cache tokens and savings per model
The gateway now counts cache-read, cache-write and uncached prompt tokens
per provider and model as a Prometheus counter. It also writes the read,
write and saved micro-USD totals to the Redis counters.

The admin usage models detail view returns the three totals per model.
Response-cache hits do not count, and free models save nothing.
2026-11-26 01:03:50 +00:00
lukaszraczylo 8817157efc fix(pricing): fill flagship cache prices from the generated table
A curated builtinPricing entry returned before the generated table, so its cache prices were never reached.
lookupPricingSource now fills nil cache fields of a curated hit from the generated table.
Base prices are unchanged, and an operator override is not merged.
The clamp test now asserts exact values.
Tests that compared prices with == now use reflect.DeepEqual, because the price struct holds pointers.
2026-11-26 00:54:38 +00:00
lukaszraczylo 66506dfff2 chore(pricing): add cache prices to builtin table
The base prices and the entry set are unchanged.
113 entries gain cache-read or cache-write prices.
The cache fields come from LiteLLM on 2026-11-26.
A full pricing-sync run is not used, because it would drop 36 entries.
2026-11-26 00:49:21 +00:00
lukaszraczylo 55ebe1fae1 feat(pricing): price cached and cache-write input tokens
Cost now prices cache-read and cache-write prompt tokens at their own rates.
A model without a cache price keeps the input rate, so cost does not change.
The cache shares are clamped to the prompt, so odd usage cannot give a negative cost.
LiteLLM field names cache_read_input_token_cost and cache_creation_input_token_cost were confirmed in the fetched source.
The pricing-sync tool reads both fields. The table regeneration is a separate commit.
2026-11-26 00:37:19 +00:00
lukaszraczylo 73ff7d92e0 feat(usage): parse cache-read and cache-write tokens for all providers 2026-11-26 00:29:39 +00:00
lukaszraczylo dc6daeea1d chore(plugin): exercise the decision block in catalog testData
The auto router gets a shadow decision block and a provider with a decision path prefix. The manifest test mirrors both and runs New() on them.
2026-11-25 14:18:49 +00:00
lukaszraczylo bf529326b7 docs: decision model assist details and admin panel features
Document the decision request text, the live skip, the provider type, the saturation rule, and the redesigned admin pages.
2026-11-25 14:16:12 +00:00
lukaszraczylo e6605dce6d test(router): widen decision timeout test margin
The server delay is 2s and the test bound is 1s. The 50ms timeout stays.
2026-11-25 14:16:04 +00:00
lukaszraczylo 21e9bc84d1 fix(router): send the head of the system prompt and ask to the decision model
The decision state now holds the first 1024 bytes of the system prompt and the first 8192 bytes of the newest ask, cut at a character boundary. The classifier scoring inputs stay the same.
2026-11-25 14:15:51 +00:00
lukaszraczylo 2cd828c162 fix(router): decision call skips settled requests and ignores client cancels
Live mode no longer calls the decision model when a floor or keyword rule already fixes the tier. A client cancel during the call no longer counts toward the breaker.
2026-11-25 14:15:20 +00:00
lukaszraczylo 8c01f15ee5 docs: smart router decision model assist 2026-11-25 14:02:26 +00:00
lukaszraczylo 3008748681 build(admin): regenerate embedded admin UI 2026-11-25 14:00:32 +00:00
lukaszraczylo 5d4a9e6cad feat(admin): decision model grid in router panel 2026-11-25 13:59:39 +00:00
lukaszraczylo f8a38e10da feat(router): decision model stats and admin view 2026-11-25 13:56:39 +00:00
lukaszraczylo 0d1f71b392 feat(router): decision model assist near tier boundaries 2026-11-25 13:51:10 +00:00
lukaszraczylo d603780560 fix(router): keep decision calls out of upstream accounting 2026-11-25 13:43:46 +00:00
lukaszraczylo 73fc53a29b feat(router): decision model client with breaker and cache 2026-11-25 13:39:45 +00:00
lukaszraczylo 266ce22e72 feat(router): decision model config and validation 2026-11-25 13:32:28 +00:00
lukaszraczylo 65654e8e83 build(admin): regenerate embedded admin UI 2026-11-25 12:47:29 +00:00
lukaszraczylo 81bf2e4ffe feat(webui): compare cost avoided against MiniMax M3.1 Flash and latest Sonnet 2026-11-25 12:47:28 +00:00
lukaszraczylo 8c9ec9e241 build(admin): regenerate embedded admin UI 2026-11-25 12:40:02 +00:00
lukaszraczylo b48ec65f94 test(mock): enforce backend series metric rules
Port seriesValidMetric and the usage/series query checks into the mock so it
returns the backend 400 for an invalid scope, metric and window combination.
2026-11-25 12:38:58 +00:00
lukaszraczylo fd9dc53241 fix(webui): request provider attempts for model page totals
The provider series endpoint rejects the req metric. Request attempt on an
hour or day window instead, and label the group total as attempts.
2026-11-25 12:38:57 +00:00
lukaszraczylo a231cebb71 build(admin): regenerate embedded admin UI 2026-11-25 12:20:39 +00:00
lukaszraczylo 13a38a6631 refactor(webui): reuse entity links and formatters; drop stale component comments 2026-11-25 12:11:21 +00:00
lukaszraczylo dccf04f840 test(webui): widen leak scan to mock sources and e2e 2026-11-25 12:11:20 +00:00
lukaszraczylo 34c2bb8dbf docs(limits): correct usage key count comments 2026-11-25 12:11:13 +00:00
lukaszraczylo ad6af8fd0a fix(webui): guard provider totals and model panel against stale responses 2026-11-25 12:11:12 +00:00
lukaszraczylo a7e9c98663 fix(webui): show unavailable usage when the store is down 2026-11-25 12:11:11 +00:00
lukaszraczylo 158a96ea55 fix(webui): open provider panel from reliability breakers 2026-11-25 12:11:10 +00:00
lukaszraczylo 62817af834 fix(webui): toasts above sheets; drop unreachable alias helpers
Stack the toast viewport on perfect-design's --z-toast token so it sits
above Sheet overlays, and add a harness check that the toast is the
topmost element at its centre while a sheet is open.

Delete useAliasNames, lib/alias and its spec, which nothing imports
since the shadcn migration removed AliasBadge.
2026-11-25 11:52:38 +00:00
lukaszraczylo ff58b03e21 test(webui): guard tailwind @source against missing perfect-design components
Add a spec that maps every component imported from perfect-design, and
every directory it imports in turn, to an @source entry in main.css.
Extend the bundle gate spec to check that utilities unique to recently
added components appear in the built CSS.
2026-11-25 11:52:38 +00:00
lukaszraczylo 6bc144cc12 refactor(webui): migrate remaining shadcn components to perfect-design
Move AuthGate, ConfigWarningsBanner, ToastViewport, SnippetBlock,
PageLoadError, LabeledSelect and the helper forms to perfect-design
Button, Input, Card, Callout, NativeSelect and ToastItem. Number fields
use a small native input because the library input rewrites typed text.

Delete components/ui, the unused ModelChip, CompactNumber, AliasBadge and
lib/utils, and the shadcn config. Remove shadcn-vue, tw-animate-css,
class-variance-authority and clsx. Give FaIcon an optional title and drop
role from decorative icons. Refresh stale comments and the README.
2026-11-25 11:52:38 +00:00
lukaszraczylo e1f1a60d4d refactor(webui): remove shadcn-vue, chart.js and replaced components
Delete 89 files that no live entry imports, drop chart.js, vue-chartjs,
@tanstack/vue-table and the FontAwesome runtime, and replace the Vue
FontAwesome wrapper with a small SVG component.

Limit Tailwind source scanning to the perfect-design components the app
bundles. Add the bundle gate script and spec: gzip JS+CSS of dist/assets
must stay at or below 324300 bytes.
2026-11-25 11:52:38 +00:00
lukaszraczylo 945621a3c5 fix(webui): compact config viewer, clear unknown helper sel, harness port guard 2026-11-25 11:52:38 +00:00