Add GLM to Codex model catalog on startup; remove subagent GLM skip - #269
Closed
masonc08 wants to merge 1 commit into
Closed
Add GLM to Codex model catalog on startup; remove subagent GLM skip#269masonc08 wants to merge 1 commit into
masonc08 wants to merge 1 commit into
Conversation
Codex fetches its model catalog from the gateway at startup (GET /models), but the Databricks AI Gateway doesn't serve that endpoint — so Codex has no catalog and rejects models it doesn't know (notably GLM for subagent spawns). This was the reason the GLM subagent skip guard existed. This PR writes a static model catalog JSON (model_catalog_json config key) on ucode codex startup that includes GLM alongside the discovered GPT models, pre-populated with the smart-routing arms. Codex reads the catalog from the file instead of the API, so GLM becomes a valid subagent model. With GLM in the catalog, the skip_arms guard in codex_routing.route_pre_tool_use is no longer needed — a GLM routing decision is now applied like any other arm. The GLM_SUBAGENT_SKIP_MESSAGE constant is removed. Co-authored-by: Isaac
Collaborator
Author
|
Closing in favor of #273. Tien's model-list change is deployed to staging, so Codex now fetches a real model catalog from the gateway ( |
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.
What & why
Codex fetches its model catalog from the gateway at startup (
GET /ai-gateway/codex/v1/models), but the Databricks AI Gateway returns a 400 for that endpoint — so Codex has no model catalog and rejects models it doesn't recognize. This is why GLM was blocked for subagent spawns (theskip_armsguard in PR #251): GLM isn't in Codex's catalog, so aspawn_agentwithmodel: system.ai.glm-5-2would fail.This PR writes a static model catalog JSON file (
model_catalog_jsonconfig key) onucode codexstartup that includes GLM alongside the discovered GPT models. Codex reads the catalog from the file instead of the API, so GLM becomes a valid subagent model — no API call needed.The mechanism
_write_model_catalog(state)builds aModelsResponseJSON with one entry per discoveredcodex_modelsentry, plus a synthetic GLM entry (if not already present).~/.ucode/codex-model-catalog.jsonand referenced viamodel_catalog_json = "<path>"in the codex config overlay.ModelInfowith 38 fields,ReasoningEffortPreset,TruncationPolicyConfig, etc.) and verified by launching codex with the catalog — it parsed and launched successfully.model_catalog_jsonis added toMANAGED_KEYSso it's tracked/reverted with the rest of ucode's config.The guard removal
With GLM in the catalog, the
skip_arms={GLM_ROUTE_ARM: ...}guard incodex_routing.route_pre_tool_useis no longer needed. A GLM routing decision is now applied like any other arm — the subagent's model is rewritten tosystem.ai.glm-5-2and Codex accepts it.The
GLM_SUBAGENT_SKIP_MESSAGEconstant is removed. The testtest_spawn_glm_decision_keeps_original_modelis replaced withtest_spawn_glm_decision_applies_glm_modelwhich asserts GLM is now applied.How do you know it works
model_catalog_jsonformat was verified empirically: codexexecwith the catalog launched successfully (no parse errors, no "model not found" errors).GET /models400 failure was confirmed via trace logging (failed to refresh available models: ... doesn't match any known API type), proving the catalog fetch is the root cause.This is a follow-up to #251 (codex smart routing) and #266 (route subagents on plaintext message). It decouples GLM subagent support from Tien's separate work on fetching the model list from the gateway.
This pull request and its description were written by Isaac.