Repository navigation
fix(sse): make anthropic-compatible mid-conversation system turns a per-connection opt-in - #18341
Merged
diegosouzapw merged 27 commits intoNov 5, 2026
Conversation
…without the client beta cheaper-inference#16236 kept mid-conversation role:system turns in messages[] for plain anthropic-compatible-* relays only when the global ANTHROPIC_COMPATIBLE_MID_CONVERSATION_SYSTEM flag was on AND the client sent the mid-conversation-system-2026-04-07 anthropic-beta. Several Claude Code builds (cli and claude-desktop-3p) keep those turns in the body but never send the beta, so with the flag on they were still hoisted into the top-level system: system grew by one <total_tokens> line each turn and the cache read stayed flat at ~30K while ~110K was re-written every turn. Whether the shape is accepted is a property of the relay, not of the client, so the decision moves to the connection: providerSpecificData .keepMidConversationSystem (strict boolean, default off, toggle in the edit-connection modal for plain anthropic-compatible-*, en/ru strings, validated and normalized like the other knobs). The client's own beta is still forwarded when present and never invented. The global feature flag, its definition, i18n description and FEATURE_FLAGS.md rows are removed.
|
Same here on 3.8.53,
|
# Conflicts: # docs/i18n/am/docs/reference/FEATURE_FLAGS.md # docs/i18n/ar/docs/reference/FEATURE_FLAGS.md # docs/i18n/az/docs/reference/FEATURE_FLAGS.md # docs/i18n/bg/docs/reference/FEATURE_FLAGS.md # docs/i18n/bn/docs/reference/FEATURE_FLAGS.md # docs/i18n/da/docs/reference/FEATURE_FLAGS.md # docs/i18n/de/docs/reference/FEATURE_FLAGS.md # docs/i18n/el/docs/reference/FEATURE_FLAGS.md # docs/i18n/es/docs/reference/FEATURE_FLAGS.md # docs/i18n/et/docs/reference/FEATURE_FLAGS.md # docs/i18n/fa/docs/reference/FEATURE_FLAGS.md # docs/i18n/fi/docs/reference/FEATURE_FLAGS.md # docs/i18n/fr/docs/reference/FEATURE_FLAGS.md # docs/i18n/ga/docs/reference/FEATURE_FLAGS.md # docs/i18n/gu/docs/reference/FEATURE_FLAGS.md # docs/i18n/ha/docs/reference/FEATURE_FLAGS.md # docs/i18n/hr/docs/reference/FEATURE_FLAGS.md # docs/i18n/hu/docs/reference/FEATURE_FLAGS.md # docs/i18n/hy/docs/reference/FEATURE_FLAGS.md # docs/i18n/id/docs/reference/FEATURE_FLAGS.md # docs/i18n/ig/docs/reference/FEATURE_FLAGS.md # docs/i18n/it/docs/reference/FEATURE_FLAGS.md # docs/i18n/ka/docs/reference/FEATURE_FLAGS.md # docs/i18n/km/docs/reference/FEATURE_FLAGS.md # docs/i18n/kn/docs/reference/FEATURE_FLAGS.md # docs/i18n/lt/docs/reference/FEATURE_FLAGS.md # docs/i18n/lv/docs/reference/FEATURE_FLAGS.md # docs/i18n/ml/docs/reference/FEATURE_FLAGS.md # docs/i18n/mr/docs/reference/FEATURE_FLAGS.md # docs/i18n/ms/docs/reference/FEATURE_FLAGS.md # docs/i18n/mt/docs/reference/FEATURE_FLAGS.md # docs/i18n/my/docs/reference/FEATURE_FLAGS.md # docs/i18n/ne/docs/reference/FEATURE_FLAGS.md # docs/i18n/nl/docs/reference/FEATURE_FLAGS.md # docs/i18n/no/docs/reference/FEATURE_FLAGS.md # docs/i18n/or/docs/reference/FEATURE_FLAGS.md # docs/i18n/pa/docs/reference/FEATURE_FLAGS.md # docs/i18n/phi/docs/reference/FEATURE_FLAGS.md # docs/i18n/pt-BR/docs/reference/FEATURE_FLAGS.md # docs/i18n/pt/docs/reference/FEATURE_FLAGS.md # docs/i18n/ro/docs/reference/FEATURE_FLAGS.md # docs/i18n/ru/docs/reference/FEATURE_FLAGS.md # docs/i18n/sl/docs/reference/FEATURE_FLAGS.md # docs/i18n/sr/docs/reference/FEATURE_FLAGS.md # docs/i18n/sv/docs/reference/FEATURE_FLAGS.md # docs/i18n/sw/docs/reference/FEATURE_FLAGS.md # docs/i18n/ta/docs/reference/FEATURE_FLAGS.md # docs/i18n/te/docs/reference/FEATURE_FLAGS.md # docs/i18n/th/docs/reference/FEATURE_FLAGS.md # docs/i18n/uk-UA/docs/reference/FEATURE_FLAGS.md # docs/i18n/ur/docs/reference/FEATURE_FLAGS.md # docs/i18n/uz/docs/reference/FEATURE_FLAGS.md # docs/i18n/vi/docs/reference/FEATURE_FLAGS.md # docs/i18n/yo/docs/reference/FEATURE_FLAGS.md # docs/i18n/zh-TW/docs/reference/FEATURE_FLAGS.md # docs/reference/FEATURE_FLAGS.md # tests/unit/feature-flags-settings.test.ts # tests/unit/server-owned-tool-loop-flag.test.ts
…ocale Fills providers.keepMidConversationSystemLabel and keepMidConversationSystemDescription in the 65 locales that lacked them so i18n:check-keys passes. Machine translated; the next i18n wave can polish them. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
…-per-connection Resolve the feature-flag count conflicts after the tip grew to 114 flags: the removed ANTHROPIC_COMPATIBLE_MID_CONVERSATION_SYSTEM flag brings the catalog to 113 (Runtime 54) in the English reference, the two count tests and the FEATURE_FLAGS mirrors. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
…-per-connection Resolve FEATURE_FLAGS.md i18n mirror conflicts after the tip retouched them: take the tip mirror, drop the removed ANTHROPIC_COMPATIBLE_MID_CONVERSATION_SYSTEM row, flag count 114 -> 113, Runtime 55 -> 54. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
# Conflicts: # docs/i18n/am/docs/reference/FEATURE_FLAGS.md # docs/i18n/ar/docs/reference/FEATURE_FLAGS.md # docs/i18n/az/docs/reference/FEATURE_FLAGS.md # docs/i18n/bg/docs/reference/FEATURE_FLAGS.md # docs/i18n/bn/docs/reference/FEATURE_FLAGS.md # docs/i18n/bs/docs/reference/FEATURE_FLAGS.md # docs/i18n/cs/docs/reference/FEATURE_FLAGS.md # docs/i18n/da/docs/reference/FEATURE_FLAGS.md # docs/i18n/de/docs/reference/FEATURE_FLAGS.md # docs/i18n/el/docs/reference/FEATURE_FLAGS.md # docs/i18n/es/docs/reference/FEATURE_FLAGS.md # docs/i18n/et/docs/reference/FEATURE_FLAGS.md # docs/i18n/fa/docs/reference/FEATURE_FLAGS.md # docs/i18n/fi/docs/reference/FEATURE_FLAGS.md # docs/i18n/fr/docs/reference/FEATURE_FLAGS.md # docs/i18n/ga/docs/reference/FEATURE_FLAGS.md # docs/i18n/gu/docs/reference/FEATURE_FLAGS.md # docs/i18n/ha/docs/reference/FEATURE_FLAGS.md # docs/i18n/he/docs/reference/FEATURE_FLAGS.md # docs/i18n/hi/docs/reference/FEATURE_FLAGS.md # docs/i18n/hr/docs/reference/FEATURE_FLAGS.md # docs/i18n/hu/docs/reference/FEATURE_FLAGS.md # docs/i18n/hy/docs/reference/FEATURE_FLAGS.md # docs/i18n/id/docs/reference/FEATURE_FLAGS.md # docs/i18n/ig/docs/reference/FEATURE_FLAGS.md # docs/i18n/it/docs/reference/FEATURE_FLAGS.md # docs/i18n/ja/docs/reference/FEATURE_FLAGS.md # docs/i18n/ka/docs/reference/FEATURE_FLAGS.md # docs/i18n/km/docs/reference/FEATURE_FLAGS.md # docs/i18n/kn/docs/reference/FEATURE_FLAGS.md # docs/i18n/ko/docs/reference/FEATURE_FLAGS.md # docs/i18n/lt/docs/reference/FEATURE_FLAGS.md # docs/i18n/lv/docs/reference/FEATURE_FLAGS.md # docs/i18n/ml/docs/reference/FEATURE_FLAGS.md # docs/i18n/mr/docs/reference/FEATURE_FLAGS.md # docs/i18n/ms/docs/reference/FEATURE_FLAGS.md # docs/i18n/mt/docs/reference/FEATURE_FLAGS.md # docs/i18n/my/docs/reference/FEATURE_FLAGS.md # docs/i18n/ne/docs/reference/FEATURE_FLAGS.md # docs/i18n/nl/docs/reference/FEATURE_FLAGS.md # docs/i18n/no/docs/reference/FEATURE_FLAGS.md # docs/i18n/or/docs/reference/FEATURE_FLAGS.md # docs/i18n/pa/docs/reference/FEATURE_FLAGS.md # docs/i18n/phi/docs/reference/FEATURE_FLAGS.md # docs/i18n/pl/docs/reference/FEATURE_FLAGS.md # docs/i18n/pt-BR/docs/reference/FEATURE_FLAGS.md # docs/i18n/pt/docs/reference/FEATURE_FLAGS.md # docs/i18n/ro/docs/reference/FEATURE_FLAGS.md # docs/i18n/ru/docs/reference/FEATURE_FLAGS.md # docs/i18n/si/docs/reference/FEATURE_FLAGS.md # docs/i18n/sk/docs/reference/FEATURE_FLAGS.md # docs/i18n/sl/docs/reference/FEATURE_FLAGS.md # docs/i18n/sr/docs/reference/FEATURE_FLAGS.md # docs/i18n/sv/docs/reference/FEATURE_FLAGS.md # docs/i18n/sw/docs/reference/FEATURE_FLAGS.md # docs/i18n/ta/docs/reference/FEATURE_FLAGS.md # docs/i18n/te/docs/reference/FEATURE_FLAGS.md # docs/i18n/th/docs/reference/FEATURE_FLAGS.md # docs/i18n/tr/docs/reference/FEATURE_FLAGS.md # docs/i18n/uk-UA/docs/reference/FEATURE_FLAGS.md # docs/i18n/ur/docs/reference/FEATURE_FLAGS.md # docs/i18n/uz/docs/reference/FEATURE_FLAGS.md # docs/i18n/vi/docs/reference/FEATURE_FLAGS.md # docs/i18n/yo/docs/reference/FEATURE_FLAGS.md # docs/i18n/zh-CN/docs/reference/FEATURE_FLAGS.md # docs/i18n/zh-TW/docs/reference/FEATURE_FLAGS.md # docs/reference/FEATURE_FLAGS.md # tests/unit/feature-flags-settings.test.ts # tests/unit/server-owned-tool-loop-flag.test.ts
|
Caution Review failedAn error occurred during the review process. Please try again later.
|
# Conflicts: # docs/reference/FEATURE_FLAGS.md # src/app/(dashboard)/dashboard/providers/[id]/components/modals/EditConnectionModal.tsx # src/shared/constants/featureFlagDefinitions.ts # tests/unit/feature-flags-settings.test.ts # tests/unit/server-owned-tool-loop-flag.test.ts
This was referenced Nov 4, 2026
… anthropic-compatible (cheaper-inference#18332)
…solve conflicts with earlier train PRs)
diegosouzapw
added a commit
to shevar0/OmniRoute
that referenced
this pull request
Nov 4, 2026
…er-connection opt-in (cheaper-inference#18341)
This was referenced Nov 4, 2026
…nd exactly the validated change)
diegosouzapw
merged commit Nov 5, 2026
17d7e63
into
cheaper-inference:release/v3.8.53
3 of 8 checks passed
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
role: "system"turns insidemessages[]for plainanthropic-compatible-*relays only when the globalANTHROPIC_COMPATIBLE_MID_CONVERSATION_SYSTEMflag is onand the client itself sends the
mid-conversation-system-2026-04-07anthropic-beta. Several Claude Codebuilds (
cc_entrypoint=cli2.1.299,claude-desktop-3p2.1.308 on our deployment) put those turns in the bodybut do not send the beta. With the flag on, their turns are still hoisted into the top-level
system.systemthen grows by one<total_tokens>line every turn and the cached history after it never matches:one session read 30461 → 30482 → 30503 → 30524 … from cache (exactly +21 tokens per turn) while ~110–120K was
re-written every turn. A client on the same relay that does send the beta read 93% from cache.
role: "system"insidemessages[]is accepted is a property of the relay, not ofthe client. Gating on the client's beta silently disables the fix for clients that never negotiate it, and a
global flag cannot distinguish relays that 400 on the shape from relays that accept it.
Fix: the decision moves to the connection.
providerSpecificData.keepMidConversationSystem(strict boolean, default off), shown as a toggle in theedit-connection modal for plain
anthropic-compatible-*only (not CC-compatible / nativeclaude), en/rustrings, validated + normalized like the other boolean knobs.
resolveClaudeMidConversationSystemPolicy()now reads that opt-in from the connection'sproviderSpecificData(plumbed throughnormalizeClaudeUpstreamMessages→liftSystemRoleMessages) and nolonger requires the client beta. The client's own beta is still forwarded when present
(
applyClientAnthropicBeta, unchanged), never invented.ANTHROPIC_COMPATIBLE_MID_CONVERSATION_SYSTEMflag is removed: definition, i18n description, andthe
FEATURE_FLAGS.mdrows / counts (111 → 110 flags, Runtime 53 → 52) in all locales.Migration note: an operator who had the global flag on needs to enable the toggle on the relevant
connections. The flag's DB override row becomes inert.
Related Issues
Target Branch
release/v3.8.xbranch (the highest openrelease/v*), notmainProof Of Fix (required)
tests/unit/claude-mid-conversation-system-compatible-passthrough.test.tsdrives the realhandleChatCorewith fetch captured. New cases: beta-less client and client without anyanthropic-betastay in place with the beta never invented; a beta-less client across successive turns keeps
systemstableand earlier messages a prefix; strict-boolean policy; validation/normalization.
Production files reverted to the base, test kept:
runner-baseimage, throwaway container, plainanthropic-compatible-*connection pointed at a capture relay, Claude Code-shaped request with mid-conversation system turns and a
client
anthropic-betawithout the mid-conversation token:[user, assistant, user],system3 blocks (hoisted);[user, system, assistant, user, system],system1 block, no beta invented, 200.Scope
Validation
feature-flags incl. doc-sync, provider-specific-data, executor-default, cc-compatible, chatcore translation):
533/533
npm run typecheck:core, eslint on touched filesnpm run check:docs-all: 81 STRICT drifts, identical on the base (translated README migration counts 210 vs 211); none from this PRReviewer Notes
role: "system"inmessages[]it answers 400 and the operator turns the toggle off for that connection only.disableCooling); whichever lands second needs a trivial merge.