Skip to content

Add GLM to Codex model catalog on startup; remove subagent GLM skip - #269

Closed
masonc08 wants to merge 1 commit into
mainfrom
masonc08/glm-subagent-catalog
Closed

Add GLM to Codex model catalog on startup; remove subagent GLM skip#269
masonc08 wants to merge 1 commit into
mainfrom
masonc08/glm-subagent-catalog

Conversation

@masonc08

@masonc08 masonc08 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

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 (the skip_arms guard in PR #251): GLM isn't in Codex's catalog, so a spawn_agent with model: system.ai.glm-5-2 would fail.

This PR writes a static model catalog JSON file (model_catalog_json config key) on ucode codex startup 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 a ModelsResponse JSON with one entry per discovered codex_models entry, plus a synthetic GLM entry (if not already present).
  • The catalog is written to ~/.ucode/codex-model-catalog.json and referenced via model_catalog_json = "<path>" in the codex config overlay.
  • The catalog schema was reverse-engineered from the Codex 0.146 binary's serde structs (ModelInfo with 38 fields, ReasoningEffortPreset, TruncationPolicyConfig, etc.) and verified by launching codex with the catalog — it parsed and launched successfully.
  • model_catalog_json is added to MANAGED_KEYS so 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 in codex_routing.route_pre_tool_use is no longer needed. A GLM routing decision is now applied like any other arm — the subagent's model is rewritten to system.ai.glm-5-2 and Codex accepts it.

The GLM_SUBAGENT_SKIP_MESSAGE constant is removed. The test test_spawn_glm_decision_keeps_original_model is replaced with test_spawn_glm_decision_applies_glm_model which asserts GLM is now applied.

How do you know it works

  • Full suite: 1139 passed, lint clean.
  • The model_catalog_json format was verified empirically: codex exec with the catalog launched successfully (no parse errors, no "model not found" errors).
  • The gateway's GET /models 400 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.

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
@masonc08

masonc08 commented Aug 5, 2026

Copy link
Copy Markdown
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 (GET /ai-gateway/codex/v1/models no longer 400s) — GLM is present via the API and this static model_catalog_json file is redundant. #273 (just dropping ucode's GLM subagent guard) is the complete fix, and has been validated end-to-end: a GLM-routed subagent spawns successfully.

@masonc08 masonc08 closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant