Repository navigation
Description
Issue: Missing MODEL_COSTS for muse-spark-1.3 + no prompt_cache_key sent (cache collapse on Contrib)
Provider version: 0.6.4
Models affected: meta/muse-spark-1.3, meta/muse-spark-1.3-contributor
Bug 1 — 1.3 models bill $0.00 locally (pricing table never updated for 1.3)
src/pricing.ts (PRICING_LAST_VERIFIED = "2026-09-01") has entries for
meta/muse-spark-1.1, meta/muse-spark-1.2, meta/muse-spark-1.2-contributor
— but nothing for 1.3, even though src/commandcode-catalog.ts already lists
both 1.3 IDs. index.ts:128 then falls back silently:
cost: MODEL_COSTS[model.id] ?? ZERO_MODEL_COST,Verified in my session logs: all 387 meta/muse-spark-1.3-contributor
assistant messages record
usage.cost = {input:0, output:0, cacheRead:0, cacheWrite:0, total:0} while the
server billed real money (81% of 5h cap, 76% of weekly cap burned in ~12h).
Anything downstream of local cost (quota display, overflow decisions) is blind
for these two models.
Fix: add both 1.3 entries (same rates as 1.2 / 1.2-contrib per
commandcode.ai plan pages: 1.3-contrib = $0.10 / $0.20 / $0.002), and consider
warning instead of silently zeroing unknown models.
Feature 2 — send prompt_cache_key so server-side prefix caching can hit
src/core.ts (~L566-569) sends only max_tokens, temperature,
reasoning_effort. No prompt_cache_key is ever sent, although Meta documents
it as the lever that raises hit rates at scale
(dev.meta.ai/docs/cookbook/prompt-caching: "at scale [a prompt_cache_key]
routes same-prefix requests to the same backend and raises the hit rate").
Measured impact from my own session logs (pi session, 387 requests on
meta/muse-spark-1.3-contributor, single continuous session):
- fresh-input distribution: min 120, p10 309, median 1,670, p75 125,179,
p90 335,074, max 392,880 - i.e. caching works early, then collapses entirely in the tail (~100 requests
at near-100% fresh, ~$0.035 each) - same harness on
xiaomi/mimo-v2.5: avg ~7k fresh / ~160k cached (~95% hits)
Independent corroboration:
- HN (
news.ycombinator.com/item?id=49493163): "Muse Spark drops the cache in
less than 5m. MiMo keeps it around for at least an hour... A 500K token input
repeatedly read for full input price 12 times an hour = $0.60 vs expected
$0.012 — a 50x difference." - r/openclaw (
.../muse_spark_12_contributor_cache_not_working_well): 1.2
Contributor cache hit rate "stuck at 0%" with a 25-min heartbeat. - r/CommandCode (
.../commandcode_extremely_high_token_usage_in_any): 30M
tokens billed on a 250k conversation via opencode/Claude Code; same prompt in
the first-party CLI bills 500k–1M. - Even Meta's own team reports ~45% hit rates on agentic runs with an
explicit key and 24h TTL.
Sending one stable prompt_cache_key per session/prefix (as Meta's cookbook
recommends for production) is the cheapest available mitigation for every
pi-commandcode-provider user on Contrib models. Happy to test a branch.
Teams affected: anyone running long agentic sessions on Contrib tiers through
pi. Current behavior turns a $0.0002/req assumption into ~$0.036/req reality.
Activity
Star-233 commentedon Sep 5, 2026
Just opened #85 for the pricing table fix.
Looked into
prompt_cache_keyas well, but hit two blockers:First, tested sending it directly to
/alpha/generateand the Command Code gateway just drops unknown fields. Meta never sees it anyway, so passing it from the provider won't do anything right now.Second, tested the caching behavior directly. Contributor caching actually works, but Meta seems to have a ~3,000 token minimum before it kicks in. Sent 1.7k–2.8k tokens and got 0% cache hits across turns, but bumped it to ~3.1k tokens and immediately got a 98.8% hit (3,057 / 3,105 tokens). So the 0% hits are probably a mix of prompts under 3k tokens and the short TTL / lack of sticky routing on the Contrib pool.
Until CC's gateway explicitly supports cache routing keys, not much we can do on the client side.
zarguell commentedon Sep 10, 2026
Same root cause (
index.ts:128->ZERO_MODEL_COST) affects two more paidmodels that are in
commandcode-catalog.tsbut absent fromMODEL_COSTS.Diffing the provider's catalog (68 models) against
MODEL_COSTS(62 entries)on 0.6.4 leaves 6 unpriced; two are legitimately free and four are not:
meta/muse-spark-1.3meta/muse-spark-1.3-contributorgoogle/gemini-3.8-flashQwen/Qwen3.8-Max-0902inclusionai/ling-3.0-flash-sante:freemeituan/LongCat-2.0:free(Paid rates from commandcode.ai/docs/resources/pricing-limits, checked
2026-09-10. The two
:freeIDs correctly resolve to zero.)So as well as the two 1.3 muses,
google/gemini-3.8-flashandQwen/Qwen3.8-Max-0902bill $0.00 locally today. Fixing all four togetherwould be ideal.
Also worth noting as a separate bug in the same file: the DeepSeek V4 family is
peak/off-peak priced and
pricing.tspins the off-peak rate, so peak calls areunder-reported 2x — filed as #89. A warn-or-throw on a missing
MODEL_COSTSentry would have surfaced all of these immediately.
patlux commentedon Sep 15, 2026
Thanks for documenting both issues in such detail! The missing Muse Spark 1.3 pricing entries are now fixed in 0.7.0, available on npm.
The
prompt_cache_keypart still needs investigation. Would you be interested in opening a focused PR for that remaining piece? AI-assisted contributions are very welcome, especially with a regression test showing the emitted request shape and evidence that Command Code accepts and forwards the parameter on the affected transport.A stable key may help routing, but we should avoid promising a particular cache-hit rate since that also depends on the upstream service. Thanks again for offering to test — that would be really useful here!
beyondhumanwork commentedon Sep 18, 2026
Thanks for shipping 0.7.0 — confirmed locally:
on 0.7.0,
src/pricing.tsnow has bothmeta/muse-spark-1.3(1.25 / 4.25 / 0.15) andmeta/muse-spark-1.3-contributor(0.10 / 0.20 / 0.002), plusgemini-3.8-flashandQwen3.8-Max-0902.PRICING_LAST_VERIFIED = 2026-09-15. So the$0.00local billing half is resolved on my side.Happy to do the focused
prompt_cache_keyPR as suggested — with a regression test showing the emitted request shape insrc/core.ts, and evidence whether CC's gateway accepts/forwards it on the affected transport. Noted on not promising a hit rate, and on @Star-233's finding that/alpha/generatecurrently drops unknown fields + the ~3k token minimum. That gives us a clear thing to prove/disprove first.One timing caveat: I've burned through my CommandCode GOAT plan allowance, it renews on the 20th. I can't run live cache-hit tests until next week — Monday 21st earliest. If you push a test branch before then I can pick it up Monday, or I can start the PR + regression test and then add live evidence after renewal.
Let me know which order you prefer.
beyondhumanwork commentedon Sep 21, 2026
Allowance renewed — probe done, reporting back as promised.
Method. Live A/B against
POST /alpha/generate, pairs of back-to-back identical requests, fresh stable key per pair,maxTokens: 20. Run 1:meta/muse-spark-1.3, shared ~2.9k-token fixture, 8 calls. Run 2:deepseek/deepseek-v4.1-flash, isolated ~15KB fixture per pair, 8 calls. Runs 3+4:meta/muse-spark-1.3-contributor, isolated ~3–3.8k fixtures (above the ~3k minimum), 12 calls. 28 calls total, alldone, no errors. Spots tested: none (control),params.prompt_cache_key, top-levelprompt_cache_key,x-prompt-cache-keyheader.Full pool (1.3): control missed call1 then hit 97% on call2. Keyed pairs hit throughout (warming from control).
DeepSeek, isolated fixtures:
Contrib: control replicates @Star-233 — >3.1k fixture, 97% immediate-repeat hit, twice with identical numbers. Keyed pairs were coin flips: all-miss in run 3, then a 97% hit in run 4 — including a hit on an entry written minutes earlier in a previous run. So TTL isn't the binding constraint; the documented lack of sticky routing is. The key changes nothing in either direction.
Conclusions. (1) The gateway accepts the key in all three spots without error — unknown fields are silently ignored, not rejected. (2) No evidence of benefit anywhere: keyed pairs never outperform the keyless control on any pool. (3) The field appears dropped/ignored server-side — a fresh key still hits another pair's warm cache, which shouldn't happen if the key participated in cache identity.
Limitations. Immediate-repeat pairs only; single-digit samples per spot on Contrib, where routing luck dominates — no claim of statistical significance, just absence of any positive signal. Observed
cacheReadTokensonly, no rate promised.Net: a client-side key can't be shown to help — the gateway needs to allowlist/forward the field before any
core.tschange is meaningful. I have a mock-server regression scaffold ready (tests/test-prompt-cache-key.ts: 2 characterization tests pinning "no key sent today," 1 skipped red test forsessionId → params.prompt_cache_key) — say the word on the intended wire spot and I'll open the PR with it flipped on.patlux commentedon Sep 24, 2026
Thanks for the thorough probe, @beyondhumanwork. This is exactly the evidence we needed.
The pricing half shipped in 0.7.0. For
prompt_cache_key, your A/B shows the gateway accepts the field in all three places but ignores it: keyed pairs never beat the keyless control, and a fresh key still hit another pair's warm cache. Until Command Code forwards the key to the upstream cache, sending it from the provider would be a no-op, so I'm closing this for now and not adding the pending test.If Command Code documents or starts forwarding
prompt_cache_key(or another cache routing key), please reopen or ping here. Your regression scaffold would then be the right starting point.urawazakun commentedon Sep 26, 2026
FWIW:
prompt_cache_keyseems to be forwarded on/provider/v1/responses(not on/chat/completions). Withmeta/muse-spark-1.3-contributor, keyed requests hit ~99% from the 2nd call (keyless: 0/5), and pointing thecmdCLI at it via a BYOK provider (api: "openai-responses",options.prompt_cache_key) took a real session from 44% to 88% cache reads. Small sample, so YMMV.— ClaudeOpusより (from Claude Opus)