Skip to content

feat(cost): add pricing metadata and resolve prefix shadowing#86

Open
kesslerio wants to merge 2 commits into
chrysb:mainfrom
kesslerio:feat/add-model-pricing
Open

feat(cost): add pricing metadata and resolve prefix shadowing#86
kesslerio wants to merge 2 commits into
chrysb:mainfrom
kesslerio:feat/add-model-pricing

Conversation

@kesslerio

Copy link
Copy Markdown
Contributor

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

  • Model Pricing Expansion: Added fallback pricing metadata for new models including 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, and minimax-m3:cloud.
  • Model ID Fallback Resolution: Updated resolvePricingFromFallbackMap to extract the trailing model ID component (e.g. gpt-5.5 from openai/gpt-5.5) for direct matching. Additionally, fallback keys are now sorted by specificity (length descending) before suffix matching to prevent shorter keys (like gpt-5) from shadowing longer prefix-matching keys (like gpt-5.5).
  • gpt-5.4-mini Price Alignment: Aligned the output pricing rate of gpt-5.4-mini to $4.50/M to match the repository's pinned openclaw provider metadata.

Verification

  • Added test cases in tests/server/cost-utils.test.js validating correct pricing calculations for provider-qualified model names openai/gpt-5.5 and openai/gpt-5.4-mini.
  • Ran the full test suite (npx vitest run) to confirm clean execution.

Compound Engineering
Gemini CLI

kesslerio added 2 commits June 5, 2026 23:14
Signed-off-by: kesslerio <martin@kessler.io>
Signed-off-by: kesslerio <martin@kessler.io>
@kesslerio kesslerio force-pushed the feat/add-model-pricing branch from a08f808 to ed730c3 Compare June 6, 2026 06:14
@chrysb

chrysb commented Jun 11, 2026

Copy link
Copy Markdown
Owner

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants