Skip to content

Missing MODEL_COSTS for muse-spark-1.3 + no prompt_cache_key sent (cache collapse on Contrib) #83

Closed as not planned

Description

@beyondhumanwork

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

  1. Star-233 commented on Sep 5, 2026

    @Star-233
    Contributor

    Just opened #85 for the pricing table fix.

    Looked into prompt_cache_key as well, but hit two blockers:

    First, tested sending it directly to /alpha/generate and 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.

  2. zarguell commented on Sep 10, 2026

    @zarguell

    Same root cause (index.ts:128 -> ZERO_MODEL_COST) affects two more paid
    models
    that are in commandcode-catalog.ts but absent from MODEL_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:

    model id input/M output/M cache read/M free?
    meta/muse-spark-1.3 $1.25 $4.25 $0.15 no
    meta/muse-spark-1.3-contributor $0.10 $0.20 $0.002 no
    google/gemini-3.8-flash $1.50 $7.50 $0.15 no
    Qwen/Qwen3.8-Max-0902 $2.00 $6.00 $0.25 no
    inclusionai/ling-3.0-flash-sante:free $0 $0 $0 yes
    meituan/LongCat-2.0:free $0 $0 $0 yes

    (Paid rates from commandcode.ai/docs/resources/pricing-limits, checked
    2026-09-10. The two :free IDs correctly resolve to zero.)

    So as well as the two 1.3 muses, google/gemini-3.8-flash and
    Qwen/Qwen3.8-Max-0902 bill $0.00 locally today. Fixing all four together
    would be ideal.

    Also worth noting as a separate bug in the same file: the DeepSeek V4 family is
    peak/off-peak priced and pricing.ts pins the off-peak rate, so peak calls are
    under-reported 2x — filed as #89. A warn-or-throw on a missing MODEL_COSTS
    entry would have surfaced all of these immediately.

  3. patlux commented on Sep 15, 2026

    @patlux
    Owner

    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_key part 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!

  4. beyondhumanwork commented on Sep 18, 2026

    @beyondhumanwork
    Author

    Thanks for shipping 0.7.0 — confirmed locally:

    • on 0.7.0, src/pricing.ts now has both meta/muse-spark-1.3 (1.25 / 4.25 / 0.15) and meta/muse-spark-1.3-contributor (0.10 / 0.20 / 0.002), plus gemini-3.8-flash and Qwen3.8-Max-0902. PRICING_LAST_VERIFIED = 2026-09-15. So the $0.00 local billing half is resolved on my side.

    • Happy to do the focused prompt_cache_key PR as suggested — with a regression test showing the emitted request shape in src/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/generate currently 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.

  5. beyondhumanwork commented on Sep 21, 2026

    @beyondhumanwork
    Author

    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, all done, no errors. Spots tested: none (control), params.prompt_cache_key, top-level prompt_cache_key, x-prompt-cache-key header.

    Full pool (1.3): control missed call1 then hit 97% on call2. Keyed pairs hit throughout (warming from control).

    DeepSeek, isolated fixtures:

    spot call1 call2
    none miss (read=0) 93% hit
    params miss 92% hit
    top-level miss 91% hit
    header miss 94% hit

    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 cacheReadTokens only, 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.ts change 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 for sessionId → params.prompt_cache_key) — say the word on the intended wire spot and I'll open the PR with it flipped on.

  6. patlux commented on Sep 24, 2026

    @patlux
    Owner

    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.

  7. urawazakun commented on Sep 26, 2026

    @urawazakun

    FWIW: prompt_cache_key seems to be forwarded on /provider/v1/responses (not on /chat/completions). With meta/muse-spark-1.3-contributor, keyed requests hit ~99% from the 2nd call (keyless: 0/5), and pointing the cmd CLI 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions