[mirror] refactor(platform/copilot): consolidate 4 model-routing LD flags into 1 JSON flag#4
Open
yashwant86 wants to merge 2 commits intomm-base-12917from
Open
[mirror] refactor(platform/copilot): consolidate 4 model-routing LD flags into 1 JSON flag#4yashwant86 wants to merge 2 commits intomm-base-12917from
yashwant86 wants to merge 2 commits intomm-base-12917from
Conversation
… 1 JSON flag
Replaces 4 string-valued LaunchDarkly flags (copilot-fast-standard-model,
copilot-fast-advanced-model, copilot-thinking-standard-model,
copilot-thinking-advanced-model) with a single JSON flag
`copilot-model-routing` keyed by `{mode: {tier: model}}`.
Same pattern as Significant-Gravitas#12915 (pricing flags) and Significant-Gravitas#12910 (tier-multipliers): one
flag per config domain, atomic updates, smaller LD UI surface. Per-user
targeting is preserved. Missing mode, missing tier-within-mode, non-string
cell value, non-dict payload, and LD failures all fall back to the
existing ChatConfig default — user-visible semantics don't change.
Removes the per-cell _FLAG_BY_CELL dispatch dict in model_router.py;
docstring references in copilot/config.py + copilot/sdk/service.py
updated to point at the new nested key path.
- Mirror the top-level non-dict warning down to the per-mode level: if the
operator types a string at copilot-model-routing[<mode>] instead of a
{tier: model} dict, log a warning so the typo surfaces in operator-facing
logs instead of silently dropping to ChatConfig defaults.
- Annotate `payload: object` to make the dynamic-typed return value explicit
for readers who land mid-function.
⚡ Risk Assessment —
|
| Files | Summary |
|---|---|
Feature Flag Definitionautogpt_platform/backend/backend/util/feature_flag.py |
Replaced 4 separate string-valued model routing flags (COPILOT_FAST_STANDARD_MODEL, COPILOT_FAST_ADVANCED_MODEL, COPILOT_THINKING_STANDARD_MODEL, COPILOT_THINKING_ADVANCED_MODEL) with single JSON-valued COPILOT_MODEL_ROUTING flag supporting nested (mode, tier) structure. |
Model Router Core Logicautogpt_platform/backend/backend/copilot/model_router.py |
Refactored resolve_model() to fetch single JSON payload and navigate nested structure (mode → tier → model string) instead of per-cell flag lookups. Added comprehensive validation for payload shape, mode dict, tier value with granular fallback and logging at each level. |
Configuration Documentationautogpt_platform/backend/backend/copilot/config.py |
Updated field descriptions to reference consolidated copilot-model-routing[mode][tier] flag path instead of individual flag names. |
SDK Service Documentationautogpt_platform/backend/backend/copilot/sdk/service.py |
Updated docstrings and comments to reference consolidated copilot-model-routing[thinking][tier] flag path. |
Test Suite Refactorautogpt_platform/backend/backend/copilot/model_router_test.pyautogpt_platform/backend/backend/copilot/sdk/service_test.py |
Removed _FLAG_BY_CELL import and per-cell flag tests. Added comprehensive tests for JSON payload parsing: None payload, full/partial payloads, missing modes/tiers, non-dict payloads, non-string cell values, empty strings, mode-level type errors, and single LD call regression guard. |
Sequence Diagram
sequenceDiagram
participant Caller
participant resolve_model
participant LD as LaunchDarkly
participant Logger
participant Config
Caller->>resolve_model: resolve_model(mode, tier, user_id)
resolve_model->>LD: get_feature_flag_value("copilot-model-routing", user_id)
alt LD Exception
LD-->>resolve_model: Exception
resolve_model->>Logger: warning("LD lookup failed")
resolve_model->>Config: fallback
else LD Success
LD-->>resolve_model: payload (object)
alt payload is None
resolve_model->>Config: fallback
else payload is not dict
resolve_model->>Logger: warning("expected JSON object")
resolve_model->>Config: fallback
else payload is dict
alt mode not in payload
resolve_model->>Config: fallback
else mode in payload but not dict
resolve_model->>Logger: warning("mode expected dict")
resolve_model->>Config: fallback
else mode is dict
alt tier value is string and non-empty
resolve_model-->>Caller: value.strip()
else tier value is None
resolve_model->>Config: fallback
else tier value is non-string or empty
resolve_model->>Logger: warning("invalid cell value")
resolve_model->>Config: fallback
end
end
end
end
Dig Deeper With Commands
/review <file-path> <function-optional>/chat <file-path> "<question>"/roast <file-path>
Runs only when explicitly triggered.
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.
Mirror of upstream Significant-Gravitas#12917 for benchmark. Do not merge.
Summary by MergeMonkey