Repository navigation
Conversation
* Add upstream system-to-user role compatibility Gate the rewrite behind rewrite-all-system-to-user. Preserve the original system and developer roles in <system_instruction> and <developer_instruction> tags, and declare those tags in the leading system instruction when needed. * Send empty leading system instructions without role tags --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…reams (Menci#802) Third-party relays and Claude Code pool resellers commonly enforce Claude Code client checks: User-Agent, X-Stainless-*, x-app, anthropic-beta, the billing header, metadata.user_id, and the identity system blocks. The wire mimicry that satisfies those checks lived only inside @floway-dev/upstream-claude-code, so a Custom upstream layered on top of such a relay had no way to reuse it. Move the OAuth-independent Claude Code wire profile into @floway-dev/upstream/client-profiles: request detection, the pinned header surface, the inbound header allowlist, the Anthropic Messages mimicry chain (backfill required fields, synthesize metadata.user_id, hoist caller system text, inject the billing, identity, and cached template blocks), and the per-profile default flags. The Claude Code subscription provider delegates to the shared layer and keeps OAuth, quota, and account state local. Expose the profile as clientProfile: 'claude-code' on Custom upstreams, validated in provider config and the control-plane schema, preserved on serialization, and clearable through PATCH. Genuine Claude Code-shaped Messages requests pass through with their system blocks, anthropic-beta opt-ins, and metadata intact. Other requests run the mimicry chain, merge caller-requested beta tokens without duplicates, keep ingressHeadersRules override precedence, and do not leak profile-admitted headers into non-Messages protocols. The profile layers strip-billing-attribution: false and rewrite-disallowed-mid-conv-system-to-user: true beneath operator and model overrides; enabling strip-billing-attribution removes the billing block and claude-code-20250219 token. Cached auto-model flags are recomputed when the profile changes. The dashboard gains a Client profile selector with en and zh-Hans strings, a warning when the profile is set without the Anthropic Messages endpoint, and profile-aware defaults in both flag editors.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…e rewrite on chatgpt Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
yyyr-p
marked this pull request as ready for review
December 2, 2026 12:25
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
The upstream editor offered every optional flag on every upstream kind, including flags that can never take effect for that kind, and one (
strip-billing-attributionon Claude Code) that always breaks billing. Each kind's exhaustive flag-defaults map can now mark a flag'unavailable', and the gateway enforces that end-to-end. The dashboard adds no new control; it hides those flags.Because
*_DEFAULT_FLAGSis exhaustive, adding a flag to the catalog fails to compile until every kind declares it on, off, or unavailable. Availability and defaults live in one map.resolveEffectiveFlags(defaults, layers)now takes the kind's defaults separately. An unavailable flag starts off and ignores every override layer (operator, client profile, per-model), so a stored override for it never takes effect.POST /api/upstreamsandPATCH /api/upstreams/:idreturn 400 forflag_overridesthat set an id fromunavailableFlagIds(flagDefaultsForKind(kind)). Serialized records drop those ids fromflag_overrides(withoutUnavailableFlags), so a dashboard round-trip clears stale values.flag_defaultscarries'unavailable'on the wire.FeatureFlagsEditorskips flags whose default is'unavailable'at both the upstream and per-model level, and does not render a group left with no flags.custom,azurecopilot,kimi-code,ollamavendor-deepseek,vendor-qwen,vendor-mistralchatgptanthropic-messages-web-search-shim,rewrite-disallowed-mid-conv-system-to-user,openai-responses-store-false,usage-exclusive-cached-tokensstore: false, and its usage follows the OpenAI conventionclaude-codeopenai-responses-*web-search, image-generation, compact, compact-decrypt, agent-message, standalone-tool-output and null-unresolved-namespace flags,rewrite-developer-to-system,rewrite-system-to-developer,strip-prompt-cache-key,usage-exclusive-cached-tokens,openai-responses-store-false,strip-billing-attributionSource-side shims (
openai-responses-*,anthropic-messages-web-search-shim) act on the downstream request, but their flag only takes effect when the selected target natively speaks that protocol, e.g.if (ctx.targetApi === 'openaiResponses' && !flags.has(...)) return run(). On every other target the shim always engages. They are therefore hidden only on kinds whose models never expose that endpoint.openai-responses-collaboration-shimis gated by its flag alone, so it stays visible everywhere.