fix(codex): remove model_catalog_json — wrong format crashed Codex

model_catalog_json expects internal Codex ModelsResponse format with
complex ModelInfo structs (slug, display_name, visibility, shell_type,
supported_reasoning_levels, etc.), not simple OpenAI API format.
Removed from all configs to restore working state.

env_key = "OPENAI_API_KEY" fix is preserved (fixes 401 Unauthorized).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
delta-cloud-208e
2026-03-08 08:48:31 +00:00
parent 416720ae51
commit fa07058917
3 changed files with 0 additions and 60 deletions

View File

@@ -44,7 +44,6 @@ RESET = "\033[0m"
# Managed config keys (we update these, preserve everything else)
MANAGED_TOP_KEYS = {
"model", "model_reasoning_effort", "model_provider",
"model_catalog_json",
"approval_policy", "sandbox_mode",
"check_for_update_on_startup", "forced_login_method",
}
@@ -164,14 +163,6 @@ def generate_config_toml(existing, config):
lines.append(f'model = "{config["model"]}"')
lines.append(f'model_reasoning_effort = "{config.get("model_reasoning_effort", "high")}"')
lines.append('model_provider = "custom"')
# Model catalog path (for model picker)
codex_dir = os.path.join(os.path.expanduser("~"), ".codex")
catalog_path = os.path.join(codex_dir, "model_catalog.json")
# Use forward slashes for cross-platform TOML compatibility
catalog_path_toml = catalog_path.replace("\\", "/")
lines.append(f'model_catalog_json = "{catalog_path_toml}"')
lines.append(f'approval_policy = "{config.get("approval_policy", "never")}"')
lines.append(f'sandbox_mode = "{config.get("sandbox_mode", "danger-full-access")}"')
lines.append(f'check_for_update_on_startup = {toml_value(config.get("check_for_update", False))}')
@@ -473,21 +464,6 @@ def apply_all_patches(config, home_dir=None):
# Backup before any changes
backup_file(config_path)
# Generate model catalog JSON for model picker
catalog_path = os.path.join(codex_dir, "model_catalog.json")
models = config.get("models", [config["model"]])
catalog_entries = []
for m in models:
catalog_entries.append({
"id": m,
"object": "model",
"created": 1700000000,
"owned_by": "system"
})
with open(catalog_path, "w", encoding="utf-8") as f:
json.dump(catalog_entries, f, indent=2)
print(f" {'[OK]':>8} Catalog: {catalog_path} ({len(models)} models)")
# Generate new config.toml (merge)
new_content = generate_config_toml(existing, config)
@@ -598,13 +574,6 @@ def patch_user(user_home, config):
existing = read_toml(config_path)
backup_file(config_path)
# Generate model catalog
catalog_path = os.path.join(codex_dir, "model_catalog.json")
models = config.get("models", [config["model"]])
catalog_entries = [{"id": m, "object": "model", "created": 1700000000, "owned_by": "system"} for m in models]
with open(catalog_path, "w", encoding="utf-8") as f:
json.dump(catalog_entries, f, indent=2)
new_content = generate_config_toml(existing, config)
with open(config_path, "w", encoding="utf-8") as f:
f.write(new_content)