Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix: correct the provider PRs merged this round

Bingxi Zhao (Frank)f2b7828bc49a
diff --git a/README.md b/README.md
index 6e88112f6..97f5fe2f8 100644
--- a/README.md
+++ b/README.md
@@ -219,8 +219,6 @@ deeptutor start # starts backend + frontend; keep the terminal open
`deeptutor init` prompts for backend port (default `8001`), frontend port (default `3782`), LLM provider / base URL / API key / model, and an optional embedding provider for Knowledge Base / RAG.
-[OrcaRouter](https://www.orcarouter.ai) is supported as a named OpenAI-compatible gateway for both LLM and embedding. With one `ORCAROUTER_API_KEY` (keys start with `sk-orca-`) you get 150+ models from OpenAI, Anthropic, Google, DeepSeek, Qwen, MiniMax and xAI behind a single `https://api.orcarouter.ai/v1` endpoint. Pick it in the `deeptutor init` provider menu (or **Settings → Models**), use gateway model ids like `anthropic/claude-sonnet-4.6`, `deepseek/deepseek-v4-pro`, or `orcarouter/auto` for OrcaRouter's auto-routing alias, and set embedding models such as `openai/text-embedding-3-large`. It also runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes.
-
After `deeptutor start`, open the frontend URL printed in the terminal — by default [http://127.0.0.1:3782](http://127.0.0.1:3782). Press `Ctrl+C` in that terminal to stop both backend and frontend. Skipping `deeptutor init` is fine for a quick trial; the app boots with default ports and empty model settings, configure them later in **Settings → Models**.
</details>
diff --git a/deeptutor/api/routers/settings.py b/deeptutor/api/routers/settings.py
index 4d5bb74b6..204cc2646 100644
--- a/deeptutor/api/routers/settings.py
+++ b/deeptutor/api/routers/settings.py
@@ -645,12 +645,17 @@ async def update_openai_codex_reasoning_effort(
) -> dict[str, Any]:
_require_codex_oauth_actor()
try:
- return await get_codex_oauth_service().set_reasoning_effort(
+ status_payload = await get_codex_oauth_service().set_reasoning_effort(
payload.model,
payload.reasoning_effort,
)
except CodexAuthError as exc:
raise _codex_http_exception(exc) from None
+ # This writes the catalog the runtime resolves against, like every other
+ # catalog write here — without it the next turn keeps the old effort until
+ # something else happens to invalidate.
+ _invalidate_runtime_caches()
+ return status_payload
@router.get("/catalog")
diff --git a/deeptutor/services/codex_auth/service.py b/deeptutor/services/codex_auth/service.py
index bfab3aff9..1555a905b 100644
--- a/deeptutor/services/codex_auth/service.py
+++ b/deeptutor/services/codex_auth/service.py
@@ -82,6 +82,15 @@ def codex_model_id(slug: str) -> str:
return f"llm-model-openai-codex-{digest}"
+def _stale_codex_config() -> CodexAuthError:
+ """The one 409 every runtime-profile rejection raises."""
+ return CodexAuthError(
+ "codex_catalog_unavailable",
+ "Refresh Codex models before using this configuration.",
+ 409,
+ )
+
+
def _codex_account_binding(account_id: str) -> str:
return hashlib.sha256(account_id.encode("utf-8")).hexdigest()
@@ -604,9 +613,14 @@ class CodexOAuthService:
self,
token: CodexToken,
model_slug: str,
- reasoning_effort: str | None,
+ reasoning_effort: str | None = None,
) -> None:
- """Reject a model config that no longer belongs to the loaded token."""
+ """Reject a model config that no longer belongs to the loaded token.
+
+ ``reasoning_effort`` is accepted for call compatibility and
+ deliberately unused — see the membership check below.
+ """
+ del reasoning_effort
credentials = self._store.load_credentials()
catalog = self._model_catalog.load()
profiles = catalog.get("services", {}).get("llm", {}).get("profiles", [])
@@ -617,27 +631,24 @@ class CodexOAuthService:
or credentials.generation != token.generation
or credentials.account_id != token.account_id
or not isinstance(profile, Mapping)
- or profile.get("codex_account_binding") != _codex_account_binding(token.account_id)
):
- raise CodexAuthError(
- "codex_catalog_unavailable",
- "Refresh Codex models before using this configuration.",
- 409,
- )
-
+ raise _stale_codex_config()
+
+ # Only a binding that is PRESENT and different is an account switch.
+ # Profiles published before this key existed carry none at all, and
+ # reading absence as a mismatch would lock every account that signed in
+ # before it shipped out of Codex until they re-ran "Refresh models".
+ binding = profile.get("codex_account_binding")
+ if binding is not None and binding != _codex_account_binding(token.account_id):
+ raise _stale_codex_config()
+
+ # Membership only. ``reasoning_effort`` is a per-request knob, not part
+ # of the identity that ties a config to a token: a caller that varies it
+ # for one turn is making a legal request, not presenting a stale config.
for model in profile.get("models", []):
- if not isinstance(model, Mapping) or model.get("model") != model_slug:
- continue
- stored_effort = model.get("reasoning_effort")
- effective_effort = stored_effort if isinstance(stored_effort, str) else None
- if effective_effort == reasoning_effort:
+ if isinstance(model, Mapping) and model.get("model") == model_slug:
return
- break
- raise CodexAuthError(
- "codex_catalog_unavailable",
- "Refresh Codex models before using this configuration.",
- 409,
- )
+ raise _stale_codex_config()
async def _refresh_credentials(
self,
diff --git a/deeptutor/services/provider_registry.py b/deeptutor/services/provider_registry.py
index b11c724a8..42384f0b9 100644
--- a/deeptutor/services/provider_registry.py
+++ b/deeptutor/services/provider_registry.py
@@ -169,7 +169,6 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
detect_by_key_prefix="sk-orca-",
detect_by_base_keyword="orcarouter",
default_api_base="https://api.orcarouter.ai/v1",
- supports_prompt_caching=True,
),
ProviderSpec(
name="edenai",
diff --git a/deeptutor_cli/init_wizard.py b/deeptutor_cli/init_wizard.py
index 0e78086bb..a725732fd 100644
--- a/deeptutor_cli/init_wizard.py
+++ b/deeptutor_cli/init_wizard.py
@@ -47,7 +47,6 @@ FEATURED_LLM_PROVIDERS: tuple[str, ...] = (
"gemini",
"siliconflow",
"openrouter",
- "orcarouter",
"ollama",
)
@@ -77,7 +76,7 @@ LLM_FALLBACK_MODELS: dict[str, tuple[str, ...]] = {
),
"orcarouter": (
"orcarouter/auto",
- "anthropic/claude-sonnet-4.6",
+ "anthropic/claude-sonnet-4-6",
"deepseek/deepseek-v4-pro",
"openai/gpt-4o",
),
@@ -96,7 +95,6 @@ FEATURED_EMBEDDING_PROVIDERS: tuple[str, ...] = (
"jina",
"cohere",
"openrouter",
- "orcarouter",
"azure_openai",
"vllm", # also covers LM Studio, llama.cpp via the same OpenAI-compatible adapter
"ollama",
diff --git a/tests/services/codex_auth/test_service.py b/tests/services/codex_auth/test_service.py
index 688cf739d..91a80ea53 100644
--- a/tests/services/codex_auth/test_service.py
+++ b/tests/services/codex_auth/test_service.py
@@ -771,20 +771,68 @@ async def test_owner_sets_supported_reasoning_effort_on_their_managed_model(
@pytest.mark.asyncio
-async def test_runtime_validation_rejects_a_stale_reasoning_effort(tmp_path: Path) -> None:
+async def test_runtime_validation_accepts_any_effort_for_a_bound_model(tmp_path: Path) -> None:
+ """Effort is a per-request knob, not part of what binds a config to a token.
+
+ Rejecting a request whose effort differs from the stored default would fail
+ every caller that varies it for a single turn.
+ """
+ snapshot = _snapshot("live", _model("gpt-5.6-sol"))
+ service, _model_catalog = _bound_reasoning_service(tmp_path, snapshot)
+ token = await service.get_token()
+
+ for effort in ("high", "low", None):
+ service.validate_runtime_profile(token, "gpt-5.6-sol", effort)
+
+
+async def test_runtime_validation_rejects_a_model_outside_the_profile(tmp_path: Path) -> None:
snapshot = _snapshot("live", _model("gpt-5.6-sol"))
service, _model_catalog = _bound_reasoning_service(tmp_path, snapshot)
token = await service.get_token()
- validator = getattr(service, "validate_runtime_profile", None)
- assert callable(validator)
with pytest.raises(CodexAuthError) as exc_info:
- validator(token, "gpt-5.6-sol", "high")
+ service.validate_runtime_profile(token, "some-other-model", None)
assert exc_info.value.code == "codex_catalog_unavailable"
assert exc_info.value.http_status == 409
+async def test_a_profile_predating_the_account_binding_still_works(tmp_path: Path) -> None:
+ """Absent is legacy, not "someone else's".
+
+ Managed profiles published before ``codex_account_binding`` existed carry
+ no such key. Reading that as a mismatch would lock every account that
+ signed in before it shipped out of Codex entirely.
+ """
+ snapshot = _snapshot("live", _model("gpt-5.6-sol"))
+ service, model_catalog = _bound_reasoning_service(tmp_path, snapshot)
+ token = await service.get_token()
+
+ catalog = model_catalog.load()
+ _managed_profile(catalog).pop("codex_account_binding", None)
+ model_catalog.save(catalog)
+
+ service.validate_runtime_profile(token, "gpt-5.6-sol", None)
+
+
+async def test_a_profile_bound_to_another_account_is_still_refused(tmp_path: Path) -> None:
+ snapshot = _snapshot("live", _model("gpt-5.6-sol"))
+ service, model_catalog = _bound_reasoning_service(tmp_path, snapshot)
+ token = await service.get_token()
+
+ catalog = model_catalog.load()
+ _managed_profile(catalog)["codex_account_binding"] = "another-account-binding"
+ model_catalog.save(catalog)
+
+ with pytest.raises(CodexAuthError) as exc_info:
+ service.validate_runtime_profile(token, "gpt-5.6-sol", None)
+
+ assert exc_info.value.http_status == 409
+
+
def test_profile_binding_matches_only_current_credentials(tmp_path: Path) -> None:
snapshot = _snapshot("live", _model("gpt-5.6-sol"))
service, model_catalog = _bound_reasoning_service(tmp_path, snapshot)