Skip to content

fix(spend): estimate fallback for zero-valued stream usage + Fireworks GLM-5.2 docs - #454

Merged
Destynova2 merged 3 commits into
mainfrom
fix/stream-zero-usage-fireworks
Jul 2, 2026
Merged

fix(spend): estimate fallback for zero-valued stream usage + Fireworks GLM-5.2 docs#454
Destynova2 merged 3 commits into
mainfrom
fix/stream-zero-usage-fireworks

Conversation

@Destynova2

Copy link
Copy Markdown
Contributor

Summary

Two related changes from the Fireworks GLM-5.2 integration work:

Fix — zero-valued streaming usage billed as $0 (src/server/dispatch/spend_stream.rs)

Some OpenAI-compatible providers (Fireworks among them) emit streaming usage objects with all token counts at zero. Those zeros set saw_usage and were treated as authoritative, so the estimate-mode local fallback never fired and genuinely consumed tokens were billed as $0. Only non-zero counts now mark usage as seen:

  • zero-only streams fall through to the local ~4 chars/token estimate in estimate mode;
  • api mode still bills nothing, matching the non-streaming path;
  • new regression test zero_usage_with_text_falls_back_to_estimate.

docs/reference/configuration.md updated to describe the zero-usage case.

Docs — Fireworks GLM-5.2 provider profile

  • New Fireworks section in docs/how-to/providers.md (OpenAI-compatible endpoint, full model ids).
  • Complete example profile docs/examples/fireworks-glm52.toml (token_counting = "estimate" since Fireworks streams zero-valued usage).
  • Example configs now use $ENV_VAR placeholders instead of your-key-here literals; local grob-*.toml scratch configs gitignored.

The Cargo.lock commit only syncs the RUSTSEC bumps already merged via #452 (identical content, trivial merge).

Test plan

  • cargo test --lib spend_stream — 22 passed, including the new zero-usage regression test
  • prek pre-push suite (fmt, clippy, audit, deny, tests) green

🤖 Generated with Claude Code

Destynova2 and others added 3 commits July 2, 2026 18:41
…lback

Some OpenAI-compatible providers (e.g. Fireworks) emit usage objects in
streaming responses with all token counts at zero. Those zeros set
saw_usage and were taken as authoritative, so the estimate-mode local
fallback never fired and genuinely consumed tokens were billed as $0.

Only non-zero token counts now mark usage as seen, letting zero-only
streams fall through to the local estimate in estimate mode while api
mode still bills nothing, matching the non-streaming path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…olders

Adds a Fireworks section to the providers how-to plus a complete
fireworks-glm52.toml example profile (OpenAI-compatible endpoint,
estimate token counting since Fireworks streams zero-valued usage).

Example configs now use $ENV_VAR placeholders instead of literal
your-key-here strings so they are copy-paste safe. Local grob-*.toml
scratch configs are gitignored.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Same anyhow 1.0.103 / quinn-proto 0.11.15 content as main, so the
pre-push cargo-deny advisories gate passes on this branch; merges
cleanly as the files are identical.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Destynova2
Destynova2 enabled auto-merge July 2, 2026 16:48
@Destynova2
Destynova2 merged commit 1425d2c into main Jul 2, 2026
45 of 46 checks passed
@Destynova2
Destynova2 deleted the fix/stream-zero-usage-fireworks branch July 2, 2026 17:08
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Mutation testing (PR diff sample)

Informational — never blocks merge. Full matrix runs on main.

Metric Value
Status timed-out
Duration 1501 s
Total 25
Caught 0
Missed 0
Timeout 0
Unviable 0

Legend: clean (no survivors), missed (inspect artifact), timed-out (25 min cap reached).

Artifact: mutants-pr-results-2dc7f2081661e98abb006341ccb2323875001794.

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.

1 participant