fix(ai): omit the default service tier, reprice cache writes from message_delta, repoint the zai default - #2032
Open
snimu wants to merge 1 commit into
Open
fix(ai): omit the default service tier, reprice cache writes from message_delta, repoint the zai default#2032snimu wants to merge 1 commit into
snimu wants to merge 1 commit into
Conversation
…tes from message_delta, and repoint the zai default model Sending service_tier: "default" explicitly breaks strict endpoints (Copilot rejects it) while meaning nothing to OpenAI, so both Responses wire builders omit it. Anthropic message_delta events that carry a cache_creation breakdown reprice the cache-write rate the same way message_start does, instead of billing new tokens at the stale initial rate. The zai default model glm-5.1 no longer exists in the catalog and silently degraded to a fallback template; the default is now glm-5.3 and a catalog-existence test turns future default drift into a CI failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three provider wire/pricing defects:
service_tier: "default"is no longer sent on the wire (OpenAI Responses and Codex Responses). For OpenAI, absence is the default, so this changes nothing there — but strict endpoints such as GitHub Copilot reject the explicit field, failing the whole request. Fixes the defect reported in discussion [Bug] Error: Provider rejected the request (invalid_request_error, 400): service_tier is not supported #1413.message_delta. The cache-write rate was computed once (atmessage_start, or before the stream), andmessage_deltabilled its updated cache-write token count at that stale rate. When a delta carries acache_creationbreakdown (5m/1h mix), the rate is now recomputed exactly asmessage_startdoes; without a breakdown the prior rate is kept. Fixes the defect reported in discussion [Bug] Anthropic reports stale cache-write cost when message_delta updates cache creation #1769.defaultModelPerProvider.zaipointed atglm-5.1, which was removed from the catalog — every default zai selection silently degraded to a fallback template model. The default is nowglm-5.3, and a new catalog-existence test makes any future default/catalog drift a CI failure instead of a silent downgrade. Fixes the defect reported in discussion [Bug] Stale default model for zai provider (glm-5.1 removed from catalog) silently falls back to outdated glm-4.7 #1679.Validation
message_deltabreakdown repricing (exact-cost assertion), and per-provider default catalog existenceanthropic-sse-parsing(7),openai-responses-copilot-provider(24),openai-codex-stream(18),model-resolver(25) — all green, sanitized envnpm run checkpasses via the pre-commit hookLOC
Src +20/−3 across four files (all point fixes; the only added mechanism is the 8-line delta reprice mirroring the existing
message_startpath). Tests +143/−2, changelog 2 fragments.Linear: RES-1266 https://linear.app/primeintellect/issue/RES-1266
Note
Low Risk
Targeted provider request shaping and usage-cost fixes plus a default model ID update; no auth or broad API redesign.
Overview
Fixes three wire/pricing/defaults issues across pi-ai and coding-agent.
OpenAI Responses and Codex no longer put
service_tieron the request body when the tier is"default". Omitting the field is the real default; sending it explicitly breaks strict proxies (e.g. GitHub Copilot). Non-default tiers (flex,priority) are unchanged.Anthropic streaming now recomputes cache-write cost on
message_deltawhen usage includes acache_creationbreakdown (5m vs 1h), matching themessage_startpath. Final token counts from the delta no longer get billed at a stale rate from the start event.zai default model moves from
glm-5.1(removed from the catalog) toglm-5.3. A test asserts everydefaultModelPerProviderentry exists in the catalog so future drift fails in CI instead of silently falling back to a template model.Reviewed by Cursor Bugbot for commit 64e5f3d. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Omit default
service_tieron OpenAI requests, reprice Anthropic cache writes frommessage_delta, point zai default toglm-5.3service_tierfrom OpenAI Responses and Codex request bodies when the tier is"default"; explicitly requested non-default tiers are still serialized.message_deltausage and recalculates cache-write cost using the configured five-minute or one-hour retention tier, replacing the earliermessage_start-derived price.glm-5.1toglm-5.3in model-resolver.ts.message_deltacontaining the cache-creation breakdown; if a response omits it, cache-write cost may be zero or stale. zai consumers relying onglm-5.1as the default will silently move toglm-5.3.Macroscope summarized 64e5f3d.