feat(cost): add pricing metadata and resolve prefix shadowing#86
feat(cost): add pricing metadata and resolve prefix shadowing#86kesslerio wants to merge 2 commits into
Conversation
Signed-off-by: kesslerio <martin@kessler.io>
Signed-off-by: kesslerio <martin@kessler.io>
a08f808 to
ed730c3
Compare
|
Thanks for splitting this out. I think the prefix-shadowing fix is the right direction, but the new fallback prices should be aligned with the OpenClaw plugin manifests before merge. I checked the bundled OpenClaw manifests in node_modules/openclaw/dist/extensions and found several mismatches:\n\n- openai gpt-5.5 / gpt-5.4-mini have cacheWrite: 0 in the manifest, but this PR sets cacheWrite to the input rate.\n- moonshot kimi-k2.6 is 0.95 input / 4 output / 0.16 cacheRead / 0 cacheWrite in the manifest, but this PR uses 0.8 / 3 / 0.1 / 0.8.\n- deepseek-v4-flash cacheRead is 0.028 in the manifest, but this PR uses 0.0028.\n- glm-5.1 is 1.2 input / 4 output / 0.24 cacheRead / 0 cacheWrite in the manifest, but this PR uses 1.4 / 4.4 / 0.26 / 1.4.\n\nThis is not a runtime-breaking issue, but it is a cost-dashboard correctness issue: when the fallback table is used, especially for provider-qualified or :cloud refs, we would show confidently wrong totals. I would fix the table to mirror the OpenClaw manifests, and ideally add a test for one of the :cloud fallback paths so future updates do not drift. |
Summary
This PR adds fallback model pricing metadata for several new flagship and cloud models and refines the fallback resolver logic to prevent prefix shadowing.
Changes
gpt-5.5,gpt-5.4-mini,kimi-k2.6:cloud,deepseek-v4-flash:cloud,glm-5.1:cloud,grok-4.3,qwen3-coder-next, andminimax-m3:cloud.resolvePricingFromFallbackMapto extract the trailing model ID component (e.g.gpt-5.5fromopenai/gpt-5.5) for direct matching. Additionally, fallback keys are now sorted by specificity (length descending) before suffix matching to prevent shorter keys (likegpt-5) from shadowing longer prefix-matching keys (likegpt-5.5).gpt-5.4-minito$4.50/Mto match the repository's pinnedopenclawprovider metadata.Verification
tests/server/cost-utils.test.jsvalidating correct pricing calculations for provider-qualified model namesopenai/gpt-5.5andopenai/gpt-5.4-mini.npx vitest run) to confirm clean execution.