mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:20:33 +08:00
fix(codex): update model catalog compatibility version
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
"""Audited OpenAI Codex compatibility constants."""
|
||||
|
||||
CODEX_UPSTREAM_COMMIT = "81da9deb065d7adb283816b19b40f89bcc484276"
|
||||
CODEX_CLIENT_VERSION = "0.145.0"
|
||||
# Catalog compatibility: rust-v0.153.4, commit
|
||||
# 3d2ee51ca2d5db578f328aa75e20aa22c0197c9a. Older versions omit eligible models.
|
||||
# This request version is independent of the installed CLI and OAuth audit above.
|
||||
CODEX_CLIENT_VERSION = "0.153.4"
|
||||
CODEX_OAUTH_ISSUER = "https://auth.openai.com"
|
||||
CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann"
|
||||
CODEX_OAUTH_SCOPE = "openid profile email offline_access api.connectors.read api.connectors.invoke"
|
||||
|
||||
39
tests/services/codex_auth/fixtures/astra-model.json
Normal file
39
tests/services/codex_auth/fixtures/astra-model.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"slug": "gpt-6-astra",
|
||||
"display_name": "GPT-6-Astra",
|
||||
"visibility": "list",
|
||||
"priority": 1,
|
||||
"default_reasoning_level": "medium",
|
||||
"supported_reasoning_levels": [
|
||||
{
|
||||
"effort": "low",
|
||||
"description": "Fast responses with lighter reasoning"
|
||||
},
|
||||
{
|
||||
"effort": "medium",
|
||||
"description": "Balances speed and reasoning depth for everyday tasks"
|
||||
},
|
||||
{
|
||||
"effort": "high",
|
||||
"description": "Greater reasoning depth for complex problems"
|
||||
},
|
||||
{
|
||||
"effort": "xhigh",
|
||||
"description": "Extra high reasoning depth for complex problems"
|
||||
},
|
||||
{
|
||||
"effort": "max",
|
||||
"description": "Maximum reasoning depth for the hardest problems"
|
||||
},
|
||||
{
|
||||
"effort": "ultra",
|
||||
"description": "Maximum reasoning with automatic task delegation"
|
||||
}
|
||||
],
|
||||
"supports_reasoning_summary_parameter": true,
|
||||
"supports_reasoning_summaries": true,
|
||||
"supports_parallel_tool_calls": true,
|
||||
"use_responses_lite": true,
|
||||
"context_window": 272000,
|
||||
"max_context_window": 872000
|
||||
}
|
||||
106
tests/services/codex_auth/test_catalog_refresh.py
Normal file
106
tests/services/codex_auth/test_catalog_refresh.py
Normal file
@@ -0,0 +1,106 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
from deeptutor.services.codex_auth.catalog import CodexModelCatalog, parse_models_response
|
||||
from deeptutor.services.codex_auth.contracts import CatalogSnapshot, CodexCredentials
|
||||
from deeptutor.services.codex_auth.oauth import CodexOAuthClient
|
||||
from deeptutor.services.codex_auth.service import (
|
||||
CODEX_PROFILE_ID,
|
||||
CodexOAuthService,
|
||||
codex_model_id,
|
||||
sync_codex_catalog,
|
||||
)
|
||||
from deeptutor.services.codex_auth.storage import CodexCredentialStore
|
||||
from deeptutor.services.config.model_catalog import ModelCatalogService
|
||||
from deeptutor.services.config.provider_runtime import resolve_llm_runtime_config
|
||||
|
||||
FIXTURES = Path(__file__).parent / "fixtures"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_refresh_discovers_version_gated_model_and_preserves_selection(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
# Same-account live comparison on 2026-09-06: 0.145.0 omits Astra;
|
||||
# official rust-v0.153.4 exposes it. Only model metadata is retained.
|
||||
old_payload = json.loads((FIXTURES / "models-response.json").read_text())
|
||||
astra = json.loads((FIXTURES / "astra-model.json").read_text())
|
||||
new_payload = {"models": [astra, *old_payload["models"]]}
|
||||
requests: list[httpx.Request] = []
|
||||
|
||||
def respond(request: httpx.Request) -> httpx.Response:
|
||||
requests.append(request)
|
||||
version = request.url.params["client_version"]
|
||||
assert version in {"0.145.0", "0.153.4"}
|
||||
payload = old_payload if version == "0.145.0" else new_payload
|
||||
return httpx.Response(200, json=payload, headers={"etag": '"new-catalog"'})
|
||||
|
||||
store = CodexCredentialStore(tmp_path)
|
||||
credentials = store.commit_credentials(
|
||||
CodexCredentials(
|
||||
schema_version=1,
|
||||
access_token="test-access",
|
||||
refresh_token="test-refresh",
|
||||
id_token="test-id",
|
||||
account_id="test-account",
|
||||
expires_at=2_000_000_000,
|
||||
generation=0,
|
||||
),
|
||||
expected_generation=0,
|
||||
)
|
||||
model_catalog = ModelCatalogService(tmp_path / "model_catalog.json")
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(respond)) as http:
|
||||
catalog = CodexModelCatalog(store, http=http, clock=lambda: 1_000)
|
||||
# Seed a still-fresh pre-upgrade cache and a user's selected model.
|
||||
previous = CatalogSnapshot(
|
||||
models=parse_models_response(old_payload),
|
||||
source="live",
|
||||
fetched_at=1_000,
|
||||
etag='"old-catalog"',
|
||||
generation=credentials.generation,
|
||||
account_hash=hashlib.sha256(credentials.account_id.encode()).hexdigest(),
|
||||
)
|
||||
store.save_catalog_cache(previous.to_dict())
|
||||
sync_codex_catalog(model_catalog, previous, account_id=credentials.account_id)
|
||||
service = CodexOAuthService(
|
||||
store, catalog, model_catalog, oauth_client=CodexOAuthClient(http), clock=lambda: 1_000
|
||||
)
|
||||
await service.set_reasoning_effort("gpt-5.6-sol", "high")
|
||||
before = model_catalog.load()
|
||||
status = await service.refresh_models()
|
||||
|
||||
assert requests[0].headers["if-none-match"] == '"old-catalog"'
|
||||
assert [m["model"] for m in status["models"]].count("gpt-6-astra") == 1
|
||||
refreshed = model_catalog.load()
|
||||
llm = refreshed["services"]["llm"]
|
||||
assert llm["active_model_id"] == before["services"]["llm"]["active_model_id"]
|
||||
profile = next(p for p in llm["profiles"] if p["id"] == CODEX_PROFILE_ID)
|
||||
assert {m["model"] for m in profile["models"]} == {"gpt-6-astra", "gpt-5.6-sol"}
|
||||
existing = next(m for m in profile["models"] if m["model"] == "gpt-5.6-sol")
|
||||
assert existing["reasoning_effort"] == "high"
|
||||
selected = next(m for m in profile["models"] if m["model"] == "gpt-6-astra")
|
||||
assert selected["name"] == astra["display_name"]
|
||||
assert selected["context_window"] == str(astra["context_window"])
|
||||
assert selected["codex_supported_reasoning_levels"] == [
|
||||
level["effort"] for level in astra["supported_reasoning_levels"]
|
||||
]
|
||||
assert selected["codex_use_responses_lite"] is astra["use_responses_lite"]
|
||||
|
||||
# The settings model card persists these two IDs when the user selects it.
|
||||
llm["active_profile_id"] = CODEX_PROFILE_ID
|
||||
llm["active_model_id"] = codex_model_id("gpt-6-astra")
|
||||
model_catalog.save(refreshed)
|
||||
await service.refresh_models()
|
||||
reopened = ModelCatalogService(model_catalog.path)
|
||||
loaded = reopened.load()
|
||||
resolved = resolve_llm_runtime_config(loaded, service=reopened)
|
||||
assert resolved.model == "gpt-6-astra"
|
||||
service.validate_runtime_profile(await service.get_token(), resolved.model)
|
||||
assert service.public_status()["active_model"] == "gpt-6-astra"
|
||||
assert [m["model"] for m in service.public_status()["models"]].count("gpt-6-astra") == 1
|
||||
@@ -47,7 +47,7 @@ def _model() -> CodexModel:
|
||||
def test_codex_upstream_contract_is_pinned() -> None:
|
||||
assert CODEX_OAUTH_CLIENT_ID == "app_EMoamEEZ73f0CkXaXp7hrann"
|
||||
assert CODEX_CALLBACK_PORTS == (1455, 1457)
|
||||
assert CODEX_CLIENT_VERSION == "0.145.0"
|
||||
assert CODEX_CLIENT_VERSION == "0.153.4"
|
||||
assert CODEX_MODELS_URL.endswith("/backend-api/codex/models")
|
||||
assert CODEX_DEFAULT_MODEL == "gpt-5.6-sol"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user