From 194d41d91a95a03693ea41631e5766df11ca2e45 Mon Sep 17 00:00:00 2001 From: KoNit-K Date: Thu, 24 Sep 2026 02:31:52 +0800 Subject: [PATCH] fix(agent): defer title upgrades for named custom providers (cherry picked from commit 679214de501bace242886d8c0154aa97f6c9e42c) --- agent/title_generator.py | 5 +++-- tests/agent/test_title_generator.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/agent/title_generator.py b/agent/title_generator.py index 9e5073cbb8..a0cfa9a96b 100644 --- a/agent/title_generator.py +++ b/agent/title_generator.py @@ -180,7 +180,8 @@ def _model_title_upgrade_enabled() -> bool: def title_upgrade_must_wait_for_turn(main_runtime: Optional[dict]) -> bool: """True when the model title call would hit the SAME self-hosted endpoint as the turn's own request. - A ``custom`` main route (llama.cpp, Ollama, vLLM, LM Studio…) whose ``auxiliary.title_generation`` + A ``custom`` (including ``custom:``) main route (llama.cpp, Ollama, vLLM, LM Studio…) + whose ``auxiliary.title_generation`` is not pinned elsewhere shares one local server between the streaming main request and the concurrent ``response_format: json_schema`` title request. Single-slot servers then serve the title grammar/completion into the main turn: the user's reply arrives as ``{"title": ...}``, is @@ -189,7 +190,7 @@ def title_upgrade_must_wait_for_turn(main_runtime: Optional[dict]) -> bool: Hosted providers multiplex requests independently and keep the turn-start timing. """ provider = str((main_runtime or {}).get("provider") or "").strip().lower() - if provider != "custom": + if provider != "custom" and not provider.startswith("custom:"): return False try: cfg = _title_config() diff --git a/tests/agent/test_title_generator.py b/tests/agent/test_title_generator.py index 7063f749f2..b0e26d6b09 100644 --- a/tests/agent/test_title_generator.py +++ b/tests/agent/test_title_generator.py @@ -391,6 +391,7 @@ class TestMaybeAutoTitle: "main_runtime, title_cfg, deferred", [ ({"provider": "custom", "base_url": "http://127.0.0.1:8080/v1"}, {}, True), + ({"provider": "custom:gptoss-local", "base_url": "http://127.0.0.1:8080/v1"}, {}, True), ({"provider": "custom", "base_url": "http://127.0.0.1:8080/v1"}, {"base_url": "http://127.0.0.1:8080/v1/"}, True), ({"provider": "custom", "base_url": "http://127.0.0.1:8080/v1"}, {"provider": "openrouter"}, False), ({"provider": "custom", "base_url": "http://127.0.0.1:8080/v1"}, {"base_url": "http://10.0.0.2:8080/v1"}, False),