fix(ai): omit the default service tier, reprice cache writes from message_delta, repoint the zai default - #2032
Closed
snimu wants to merge 4 commits into
Closed
fix(ai): omit the default service tier, reprice cache writes from message_delta, repoint the zai default#2032snimu wants to merge 4 commits into
snimu wants to merge 4 commits 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.
xeophon
pushed a commit
that referenced
this pull request
Sep 4, 2026
…rces (#2039) Explicit, reviewed regeneration via `npm run generate-models`: 1238 -> 1262 models (41 added, 17 removed). No provider dropped wholesale or lost >30% of its rows. GitHub Copilot removed claude-opus-4.5, claude-opus-4.6, claude-sonnet-4, claude-sonnet-4.5, gemini-3.1-pro-preview, gpt-4.1, gpt-5.2, and gpt-5.2-codex; its stale claude-sonnet-4.5 entry is what broke CI type checks against the regenerated catalog. Test references to the removed Copilot models move to claude-sonnet-4.6 and gpt-5.3-codex; the interleaved-thinking beta test uses claude-haiku-4.5, the only remaining non-adaptive Claude in the Copilot catalog. All other providers' referenced ids are unchanged. Every defaultModelPerProvider entry exists in the refreshed catalog except the pre-existing zai glm-5.1 gap already fixed in #2032. Linear: RES-1269
… default value For OpenAI, an absent service_tier means auto (the project-configured tier), not default: omitting an explicitly requested default silently upgraded users on Priority-configured projects and could under-report cost, since response.service_tier is only guaranteed when the request field is present. Copilot rejects the FIELD itself (400 'service_tier is not supported') for every value, per the original report. The omission is now provider-scoped: Copilot never sends the field, everyone else always sends the explicit value, including default.
The Codex default-tier pin becomes a row of the existing service-tier table; the delta-reprice pin reuses createCacheUsageEvents via an optional delta breakdown.
Contributor
sethkarten
added a commit
that referenced
this pull request
Sep 7, 2026
) * refactor(coding-agent): move the semantic-edge ledger onto the event-log substrate The recorder's private append/replay/repair IO is deleted; EventLog owns it, the same move #1987 made for the RLM spawn ledger. One durability rule is unified in the substrate rather than dropped: an unterminated final line is an uncommitted append, skipped on read and truncated before the next append — never newline-completed and never surfaced to a consumer whose next append destroys it. * fix(coding-agent): make the explicit ledger reader's ENOENT contract atomic readSemanticEdgeLedger probed with statSync before reading through EventLog, which swallows ENOENT; a ledger deleted between the two returned [] instead of throwing. The missing-file decision now lives at the single open (replaySync missingFileThrows), so no check-then-read window exists. * docs(coding-agent): state the event-log tail rule once The unterminated-tail contract was restated four times (module doc, replaySync doc, two test comments). It now lives once in the module doc; the method doc keeps only its own parse/missing-file semantics and the test comments reference the contract. * fix(coding-agent): write event-log appends fully and gate appends on tail repair writeSync may write short (ENOSPC after a prefix); appendSync now loops until the payload is fully on disk so write-before-action callers never act on a torn record reported as success. A tail-repair failure (e.g. append-only ACL permitting O_APPEND but not r+) now propagates instead of being swallowed: writing through an unrepaired torn tail would weld it to the new record as permanent interior corruption. ENOENT and the concurrent-writer instability path keep their existing semantics. * fix(coding-agent): reclaim short event-log writes instead of completing them The rlm spawn ledger is multi-writer by documented design (supervisor plus each worker over one file), so completing a short O_APPEND write with a second write could interleave with a rival append and weld two records. A short write now truncates its own torn prefix back off (only while this writer still owns the tail) and fails the append; a torn tail is read-tolerated, a weld is permanent corruption. The append fd opens a+ so the ownership check can read the tail. * fix(coding-agent): leave the torn tail on a short write instead of reclaiming it The tail-match reclaim could truncate a rival's committed record whose final bytes coincide with our torn prefix - committed-data loss, strictly worse than the torn tail it prevented. A short write now just fails the append: the torn tail is the one tolerated shape, skipped on read and truncated by any writer's next repair (verified for both topologies: a resumed single-writer recorder repairs on its first append; every rlm-ledger writer repairs before each append). * refactor(coding-agent): compress event-log comments * fix(ai): omit the default service tier, reprice cache writes from message_delta, repoint the zai default Incorporates #2032 at f82c7fa. * fix(tui,coding-agent): survive lone surrogates in table cells and terminate the WebP EXIF scan Incorporates #2033 at a3d1139. * fix(coding-agent): restart dead kernels on ensure() and read mcp>=2 tool schemas Incorporates #2034 at 749e216. * fix: one crash-safe owner for durable state writes Incorporates #2035 at f0f02d2. * fix(coding-agent): one zombie-aware process-liveness probe Incorporates #2041 at 92a0eac. * fix(coding-agent): snapshot transfer ids from the materialized cursor; mismatches settle the transfer, not the worker channel Incorporates #2044 at 5af3bbe. * fix(coding-agent): failed workers recover on touch; roster gaps answer a structured recovering error Incorporates #2047 at 77b747a. * fix(coding-agent): seven session and IO correctness defects Incorporates #2037 at 41b5d72. * fix(coding-agent): coalesce child-usage attribution and gate agent-status persistence on real changes Incorporates #2050 at 6b0af5d. * fix(coding-agent): incremental single-flight session metadata scans Incorporates #2043 at df032c1. * fix(coding-agent): memoize the passive RLM topology derivation Incorporates #2051 at 0ee114c. * fix(coding-agent): preserve accounting and metadata across deferred updates Keep durable child-usage aggregates separate from pending sibling usage. Retry optional topology metadata after transient reads. Completes #2050 and #2051 integration. * fix: preserve session accounting and read-only persistence boundaries --------- Co-authored-by: Seth <seth@primeintellect.ai>
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_tierfield. Copilot rejects the field itself (400 service_tier is not supported) for every value. The omission is provider-scoped: for everyone else the explicit value — including"default"— stays on the wire, because for OpenAI an absent field means"auto"(the project-configured tier), not"default"; omitting it would silently upgrade users on Priority-configured projects and could under-report cost (response.service_tieris only guaranteed when the request field is present). 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
Total src: +19/−3 (net +16); tests: +78/−9 (net +69).
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
Medium Risk
Changes affect live API request bodies (Copilot) and reported Anthropic cache-write costs when delta usage differs from message_start; zai users get a different default model.
Overview
Fixes three provider wiring and billing issues: GitHub Copilot no longer gets a
service_tierfield on OpenAI Responses requests (Copilot 400s on the field for any value), while other providers still send an explicit tier—including"default", since omitting it would mean"auto"on OpenAI, not default tier/cost behavior.Anthropic streaming now recomputes cache-write cost when
message_deltaincludes acache_creationTTL breakdown, so final token counts are priced with the delta’s mix instead of a stale rate frommessage_start.Coding-agent changes the zai default from removed
glm-5.1toglm-5.3, and adds a test that everydefaultModelPerProviderentry exists in the catalog so silent fallback templates do not return.Reviewed by Cursor Bugbot for commit f82c7fa. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Reprice Anthropic cache writes from
message_delta, omitservice_tierfor Copilot, repoint zai default toglm-5.3streamAnthropic, cache-write cost is recalculated from themessage_deltacache-creation breakdown (read via a compatibility cast) using the configured cache TTL, instead of retaining themessage_startrate for the whole stream.buildParams, theservice_tierfield is omitted from the request JSON for thegithub-copilotprovider but still serialized for other OpenAI Responses providers.defaultModelPerProviderchanges fromglm-5.1toglm-5.3; a new test asserts every provider default exists in its catalog.message_deltanow produce different cache-write costs than before; Copilot requests no longer sendservice_tier; zai clients without an explicit model now resolve toglm-5.3.Macroscope summarized f82c7fa.