4646 normalize_workspace_url ,
4747 resolve_pat_token ,
4848 run_databricks_login ,
49- uc_enabled ,
5049)
5150from ucode .mcp import (
5251 MCP_CLIENTS ,
@@ -195,8 +194,6 @@ def configure_shared_state(
195194 profile : str | None = None ,
196195 tools : list [str ] | None = None ,
197196 force_login : bool = False ,
198- enable_uc : bool | None = None ,
199- reset_uc : bool = False ,
200197 use_pat : bool | None = None ,
201198) -> dict :
202199 """Log into Databricks, enforce AI Gateway v2, fetch model lists, persist state.
@@ -211,28 +208,10 @@ def configure_shared_state(
211208 ``--profile`` to every CLI invocation so ambiguous `~/.databrickscfg`
212209 entries (e.g. DEFAULT and a named profile both pointing at the same host)
213210 don't error out. If ``None``, we resolve it from the host after login.
214- ``enable_uc`` is the resolved CLI flag (`--enable-uc`): when not None
215- it overrides both the env var and the persisted state.
216- ``reset_uc`` is True only on the explicit ``ucode configure`` flow.
217211 """
218212 workspace = normalize_workspace_url (workspace )
219213 prior_state = load_state ()
220214 previous_workspace = prior_state .get ("workspace" )
221- # Precedence: explicit CLI flag > env var > (configure: reset to False;
222- # launch: target workspace's persisted state). Use *target* state on the
223- # launch path so the flag is sticky per-workspace and doesn't leak
224- # across workspace switches.
225- # TODO: when this flips uc_enabled True->False, prune any
226- # `system.ai.*` MCP services from state["mcp_servers"] (and their
227- # cross-tool registrations). Today they linger as orphans pointing at
228- # /ai-gateway/mcp-services/* until the user re-runs `configure mcp`
229- # or switches workspaces.
230- if enable_uc is None :
231- if reset_uc :
232- enable_uc = uc_enabled (default = False )
233- else :
234- target_ws_state = load_full_state ().get ("workspaces" , {}).get (workspace ) or {}
235- enable_uc = uc_enabled (default = bool (target_ws_state .get ("uc_enabled" )))
236215 if use_pat is None :
237216 use_pat = bool (prior_state .get ("use_pat" )) and previous_workspace == workspace
238217 fetch_all = tools is None
@@ -278,25 +257,23 @@ def configure_shared_state(
278257 claude_models = {}
279258 gemini_models = []
280259 codex_models = []
281- if enable_uc :
282- # Opt-in: one UC model-services call yields all families as
283- # `system.ai.< model-name>` ids, bucketed by name. The single reason is
284- # shared across the families that were requested .
285- with spinner ("Fetching available models (model services) ..." ):
286- ms_claude , ms_codex , ms_gemini , ms_reason = discover_model_services (workspace , token )
260+ # UC-first, best-effort: one UC model-services call yields all families as
261+ # `system.ai.<model-name>` ids, bucketed by name. If a family comes back
262+ # empty (workspace without UC model-services, or the listing failed), fall
263+ # back to the per-family AI Gateway listing for that family only .
264+ with spinner ("Fetching available models..." ):
265+ ms_claude , ms_codex , ms_gemini , ms_reason = discover_model_services (workspace , token )
287266 if want_claude :
288267 claude_models , claude_reason = ms_claude , ms_reason
268+ if not claude_models :
269+ claude_models , claude_reason = discover_claude_models (workspace , token )
289270 if want_gemini :
290271 gemini_models , gemini_reason = ms_gemini , ms_reason
272+ if not gemini_models :
273+ gemini_models , gemini_reason = discover_gemini_models (workspace , token )
291274 if want_codex :
292275 codex_models , codex_reason = ms_codex , ms_reason
293- else :
294- with spinner ("Fetching available models..." ):
295- if want_claude :
296- claude_models , claude_reason = discover_claude_models (workspace , token )
297- if want_gemini :
298- gemini_models , gemini_reason = discover_gemini_models (workspace , token )
299- if want_codex :
276+ if not codex_models :
300277 codex_models , codex_reason = discover_codex_models (workspace , token )
301278 opencode_models : dict [str , list [str ]] = {}
302279 if claude_models :
@@ -311,9 +288,8 @@ def configure_shared_state(
311288 state ["profile" ] = profile
312289 else :
313290 state .pop ("profile" , None )
314- # Persist the resolved flag so subsequent launches stay on the same
315- # discovery path without the env var or CLI flag being re-passed.
316- state ["uc_enabled" ] = enable_uc
291+ # UC discovery is now always-on; drop any flag persisted by older versions.
292+ state .pop ("uc_enabled" , None )
317293 # Persist the auth mode so launches rebuild the same (PAT-based) agent
318294 # auth command; an explicit re-configure without --use-pat clears it.
319295 if use_pat :
@@ -349,8 +325,6 @@ def _configure_shared_workspace_states(
349325 tools : list [str ] | None ,
350326 * ,
351327 force_login : bool ,
352- enable_uc : bool | None = None ,
353- reset_uc : bool = False ,
354328 use_pat : bool = False ,
355329) -> list [dict ]:
356330 if not workspaces :
@@ -363,8 +337,6 @@ def _configure_shared_workspace_states(
363337 profile = profile ,
364338 tools = tools ,
365339 force_login = force_login ,
366- enable_uc = enable_uc ,
367- reset_uc = reset_uc ,
368340 use_pat = use_pat ,
369341 )
370342 )
@@ -377,8 +349,6 @@ def configure_workspace_command(
377349 workspaces : list [tuple [str , str | None ]] | None = None ,
378350 * ,
379351 prompt_optional_updates : bool = True ,
380- enable_uc : bool | None = None ,
381- reset_uc : bool = False ,
382352 use_pat : bool = False ,
383353 skip_validate : bool = False ,
384354) -> int :
@@ -392,8 +362,6 @@ def configure_workspace_command(
392362 workspace_entries ,
393363 [tool ],
394364 force_login = True ,
395- enable_uc = enable_uc ,
396- reset_uc = reset_uc ,
397365 use_pat = use_pat ,
398366 )
399367 state = states [0 ]
@@ -429,8 +397,6 @@ def configure_workspace_command(
429397 workspace_entries ,
430398 selected_tools ,
431399 force_login = True ,
432- enable_uc = enable_uc ,
433- reset_uc = reset_uc ,
434400 use_pat = use_pat ,
435401 )
436402 state = states [0 ]
@@ -827,18 +793,6 @@ def configure(
827793 "'low' prints terse single-line status instead." ,
828794 ),
829795 ] = "normal" ,
830- enable_uc : Annotated [
831- bool ,
832- typer .Option (
833- "--enable-uc" ,
834- help = "Discover models via UC `model-services` (`system.ai.<model>`) and "
835- "surface curated `system.ai.*` MCP services. Equivalent to setting "
836- "UCODE_ENABLE_UC=1 for this configure run. The value is persisted so "
837- "subsequent `ucode <agent>` launches stay on the same discovery path; "
838- "re-run `ucode configure` without the flag (and without "
839- "UCODE_ENABLE_UC=1 in the env) to turn UC discovery back off." ,
840- ),
841- ] = False ,
842796) -> None :
843797 """Configure workspace URL and AI Gateway."""
844798 if ctx .invoked_subcommand is not None :
@@ -849,10 +803,6 @@ def configure(
849803 set_dry_run (dry_run )
850804 set_verbosity (verbose )
851805 prompt_optional_updates = not skip_upgrade
852- flag_enable_uc : bool | None = True if enable_uc else None
853- # Explicit `ucode configure` is a clean slate: when the user omits both
854- # `--enable-uc` and `UCODE_ENABLE_UC`, persisted `uc_enabled=true` from
855- # a prior run is reset to false.
856806 try :
857807 install_databricks_cli ()
858808 if agent is not None and agents is not None :
@@ -883,15 +833,11 @@ def configure(
883833 prompt_optional_updates = prompt_optional_updates ,
884834 )
885835 if workspace_entries is None :
886- configure_workspace_command (
887- tool , enable_uc = flag_enable_uc , reset_uc = True , ** skip_kwargs
888- )
836+ configure_workspace_command (tool , ** skip_kwargs )
889837 else :
890838 configure_workspace_command (
891839 tool ,
892840 workspaces = workspace_entries ,
893- enable_uc = flag_enable_uc ,
894- reset_uc = True ,
895841 ** skip_kwargs ,
896842 )
897843 elif agents is not None :
@@ -900,17 +846,13 @@ def configure(
900846 configure_workspace_command (
901847 selected_tools = selected_tools ,
902848 prompt_optional_updates = prompt_optional_updates ,
903- enable_uc = flag_enable_uc ,
904- reset_uc = True ,
905849 ** skip_kwargs ,
906850 )
907851 else :
908852 configure_workspace_command (
909853 selected_tools = selected_tools ,
910854 workspaces = workspace_entries ,
911855 prompt_optional_updates = prompt_optional_updates ,
912- enable_uc = flag_enable_uc ,
913- reset_uc = True ,
914856 ** skip_kwargs ,
915857 )
916858 else :
@@ -919,16 +861,12 @@ def configure(
919861 if workspace_entries is None :
920862 configure_workspace_command (
921863 prompt_optional_updates = prompt_optional_updates ,
922- enable_uc = flag_enable_uc ,
923- reset_uc = True ,
924864 ** skip_kwargs ,
925865 )
926866 else :
927867 configure_workspace_command (
928868 workspaces = workspace_entries ,
929869 prompt_optional_updates = prompt_optional_updates ,
930- enable_uc = flag_enable_uc ,
931- reset_uc = True ,
932870 ** skip_kwargs ,
933871 )
934872 if tracing :
0 commit comments