Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(model-hub): let custom compatible Sources run hosted tools by their models' vendors (#2876)
Call White63a072ec9c93
diff --git a/core/handlers/model_hub/hosted_tools.py b/core/handlers/model_hub/hosted_tools.pyindex 2b7564809..8cdf873c4 100644--- a/core/handlers/model_hub/hosted_tools.py+++ b/core/handlers/model_hub/hosted_tools.py@@ -5,7 +5,9 @@ overlay offers it there (``runs_on``) and no current refusal exists; Vibey thendecides what each request declares. Search tools that are not native runthrough the executor chain, the Sources whose vendor offers the tool, each onits vendor's lightweight model. ``image_generate`` names its model, chosen from-the image models the user's Sources make available.+the image models the user's Sources make available. A ``custom`` Source names no+vendor: each model it serves takes the priors of the vendor that claims it+(``prior_vendor``), so a compatible relay runs what that vendor's own key would.Every function is pure over a config snapshot and a ``HostedEvidence`` reader,so it is safe off the loop and decides the same way wherever it is asked.@@ -40,9 +42,10 @@ from vibe.backend_model_catalog import (HostedToolSpec,ImageModelSpec,bundled_provider_vendors,- provider_executor_models,provider_image_models,provider_overlay_entry,+ source_executor_models,+ source_image_models,)from .capability_evidence import (@@ -231,7 +234,7 @@ def executor_candidates(return ()candidates: dict[str, ExecutorCandidate] = {}for source in _vibey_order(config):- model_id = listed_executor_model(source)+ model_id = listed_executor_model(source, tool, spec_for=spec_for)candidate = executor_candidate(source, model_id, tool, evidence=evidence, spec_for=spec_for) if model_id else Noneif candidate is not None:candidates[source.id] = candidate@@ -240,24 +243,43 @@ def executor_candidates(return tuple(first + [candidate for source_id, candidate in candidates.items() if source_id not in order])-def listed_executor_model(source: ModelHubSourceConfig) -> Optional[str]:- """The model this Source runs proxied searches on: the first of its vendor's executor models it lists (§6).+def listed_executor_model(source: ModelHubSourceConfig, tool: str, *, spec_for: SpecLookup) -> Optional[str]:+ """The model this Source runs proxied ``tool`` searches on: the first of its executor models it lists that runs+ the tool (§6).Only a listed model: an API-key Source admits unlisted models on a turn'shop, but an executor call nobody asked for must not guess. A dated snapshotof an entry counts as listing it, the latest first; a retired one does not.+ A ``custom`` relay may list several vendors' executor models, and only some+ of them run a given tool, so one that does not is passed over."""listed = {model.id for model in source.models if not model.retired}- for entry in provider_executor_models(source.vendor):- if entry in listed:- return entry+ for entry in source_executor_models(source.vendor, source.protocol):snapshots = sorted(model for model in listed if _DATED_SNAPSHOT.fullmatch(model.removeprefix(entry)) and model != entry)- if snapshots:- return snapshots[-1]+ model_id = entry if entry in listed else snapshots[-1] if snapshots else None+ if model_id is not None and runs_on(source, model_id, tool, spec_for=spec_for) is not None:+ return model_idreturn None+def refused_executors(+ config: ModelHubConfig, tool: str, *, evidence: HostedEvidence, spec_for: SpecLookup+) -> tuple[ModelHubSourceConfig, ...]:+ """The Sources that would run ``tool`` as executors but for a current refusal of it, in Vibey's Source order.++ What sets a call with no executor apart from one with no Source to run it: these Sources exist and their+ upstream refused the tool, so the fix is clearing that refusal, not adding a key.+ """++ refused = []+ for source in _vibey_order(config):+ model_id = listed_executor_model(source, tool, spec_for=spec_for)+ if model_id is not None and evidence.unsupported(source, model_id, EvidenceFeature.hosted(tool, "call")):+ refused.append(source)+ return tuple(refused)++def executor_candidate(source: ModelHubSourceConfig, model_id: str, tool: str, *, evidence: HostedEvidence, spec_for: SpecLookup) -> Optional[ExecutorCandidate]:@@ -310,11 +332,19 @@ class ImageChoices:saved_default_available: bool = False+def image_models_of(source: ModelHubSourceConfig) -> tuple[ImageModelSpec, ...]:+ """The image models this Source may offer by its vendor, or on a ``custom`` Source by its listing (§7.2)."""++ return source_image_models(source.vendor, source.protocol, (model.id for model in source.models if not model.retired))++def _serves_image(source: ModelHubSourceConfig, spec: ImageModelSpec) -> bool:"""The image model's route was verified on this kind of credential, and the Source serves the model.Only a Source whose protocol's engine entry serves the images endpoints is offered one: the engine refuses the- rest on its own, and that refusal is never learned, so it would be offered on every turn.+ rest on its own, and that refusal is never learned, so it would be offered on every turn. For the same reason a+ model must be one of ``image_models_of`` the Source: the engine registers its image models by that same rule+ (``source_image_models``), and a model it did not register is refused locally."""return (@@ -323,6 +353,7 @@ def _serves_image(source: ModelHubSourceConfig, spec: ImageModelSpec) -> bool:and source.kind in spec.kindsand credential_eligible(source)and _serves(source, spec.id)+ and any(offered.id == spec.id for offered in image_models_of(source)))@@ -338,7 +369,7 @@ def image_choices(config: ModelHubConfig, *, evidence: HostedEvidence) -> ImageCsaved = hosted_tool_setting(config, "image_generate").default_imageavailable: list[ImageChoice] = []for source in _vibey_order(config):- for spec in provider_image_models(source.vendor):+ for spec in image_models_of(source):if not _serves_image(source, spec) or evidence.unsupported(source, spec.id, EvidenceFeature.hosted("image_generate", "call")):diff --git a/core/handlers/model_hub/service.py b/core/handlers/model_hub/service.pyindex 78f268457..f75ea0e4f 100644--- a/core/handlers/model_hub/service.py+++ b/core/handlers/model_hub/service.py@@ -60,11 +60,11 @@ from vibe.backend_model_catalog import (bundled_client_presets_once,bundled_provider_overlay,hosted_tool_spec,- provider_image_models,)from vibe.i18n import t as i18n_tfrom vibe.model_hub_runtime.client import RESPONSE_TOO_LARGEfrom vibe.model_hub_runtime.api_key_vendors import (+ api_key_vendor_catalog,catalog_api_key_vendor_label,pinned_api_key_protocol,)@@ -168,6 +168,8 @@ from .hosted_tools import (freeze_turn_tools,hop_hosted_tools,hosted_tools_status,+ image_models_of,+ refused_executors,)from .identifiers import (OPENCODE_PROVIDER_BY_NATIVE_PROTOCOL,@@ -1485,6 +1487,8 @@ class ModelHubService:self.avibe_release = avibe_releasebundled_provider_overlay()bundled_client_presets_once()+ # A custom Source's priors read its vendors' catalog protocols (``prior_vendors``).+ api_key_vendor_catalog()self.migration_blocked_backends: set[str] = set()self.migration_guard = migration_guard or self._unavailable_migration_guardself.migration_reconcile_auth = migration_reconcile_auth@@ -6635,6 +6639,16 @@ class ModelHubService:if not attempt.moves_on:breakif not attempts:+ evidence = self.hosted_evidence()+ # The config grows with use: read it off the controller loop.+ refused = await asyncio.to_thread(+ lambda: refused_executors(self.store.load(), tool, evidence=evidence, spec_for=hosted_tool_spec)+ )+ if refused:+ # Sources that run the tool exist and refused it: clearing that refusal is the fix, not another key.+ names = say("modelHub.hostedTools.listSeparator").join(source.display_name for source in refused)+ text = say(f"modelHub.hostedTools.noExecutor.{tool}.refused", sources=names)+ return {"record": failed_record(Failure(text, None))}vendors = [catalog_api_key_vendor_label(vendor) or vendor for vendor in executor_vendors(tool)]form = "one" if len(vendors) == 1 else "several"listed = say("modelHub.hostedTools.listSeparator").join(vendors)@@ -6768,9 +6782,7 @@ class ModelHubService:if outcome.http_status in {400, 404} and machine_codes_name_model(outcome):refused = [model_id]elif outcome.http_status == 404:- refused = [- spec.id for spec in provider_image_models(source.vendor) if source.kind in spec.kinds- ] or [model_id]+ refused = [spec.id for spec in image_models_of(source) if source.kind in spec.kinds] or [model_id]else:returnawait self.record_hosted_refusals(source, [(refused_id, feature, detail) for refused_id in refused])diff --git a/docs/plans/vibey-hosted-tools.md b/docs/plans/vibey-hosted-tools.mdindex eefcb32c6..c346ce065 100644--- a/docs/plans/vibey-hosted-tools.md+++ b/docs/plans/vibey-hosted-tools.md@@ -104,6 +104,22 @@ The user has an Anthropic API key, an xAI API key and an OpenAI API key, and hasonly its listed models), for which the overlay declares the tool. A Claude subscription Source is never eligible:not for native mode, not as an executor, not for images. Anthropic restricts OAuth credentials to Claude Code andits own apps ([`model-hub-tos-review.md`](model-hub-tos-review.md)).+- **A custom Source takes each model's own vendor's priors (amended 2026-10-20, #2873).** A Source added under+ 自定义 has `vendor: custom`, which has no overlay row, so it used to be excluded from every hosted tool however+ clearly its models were one vendor's. Each model it serves now takes the priors of the one overlay vendor that+ claims it (a model family of that vendor matches it, or it is one of that vendor's image models), on one+ condition: the Source speaks that vendor's catalog protocol (`api_key_vendors.json`), the protocol the vendor's+ declarations and image route were verified on. Everything else follows from those priors, exactly as for a+ `vendor: openai` relay: the tool is assumed, called blind, and a refusal is learned (§3.2).+ - Per model, not per Source: one relay that serves several vendors' models runs each vendor's tools on that+ vendor's models, as far as its one protocol allows (a Responses relay runs OpenAI's and xAI's search; Claude's+ is declared on `anthropic` only, so Claude models there use the proxy function).+ - A model that no vendor claims, or that several do, takes no priors: its vendor is not guessed.+ - Executor and image models come only from the Source's own listing. A catalog vendor's API key may be offered+ its image models unlisted, but nothing except a relay's inventory says that it serves one.+ - `prior_vendor` in `vibe/backend_model_catalog.py` is the one owner. `hosted_tool_spec`, the executor models, the image models, the+ engine's image registration and the narrow rules all read through it, so what is declared, offered,+ registered and learned stays one set.- **Translated paths are never native.** The engine coerces web search across protocols and it worked in the spike,but its result shapes are hybrids (Anthropic `web_search_result_location` citations inside a Responses message),so they are not a contract.@@ -487,7 +503,8 @@ These rules are C-1 rows in `cross-provider.md` and per-protocol rows in `converstill metered. A candidate whose identity changed since the chain was built is not used.- **The chain, built at call time.**1. Candidates are the Sources whose vendor offers the tool natively (§3.1) and that list one of the vendor's- `executor_models`: the first one the Source lists, exactly or as a dated snapshot, never a retired one. `runs_on`+ `executor_models`: the first one the Source lists that runs the tool, exactly or as a dated snapshot, never a+ retired one (a custom relay may list several vendors' executor models, §3.1). `runs_on`must hold for it, with no current negative `call` evidence for that pair. A Source that lists none is excludedwhen the chain is built, not found by a 404: an API-key Source admits unlisted models on a turn's hop, but acall nobody asked for must not guess.@@ -519,7 +536,9 @@ These rules are C-1 rows in `cross-provider.md` and per-protocol rows in `conver(the model chose not to; Anthropic is asked in the message alone) ends the chain with a `failed` record: it isa model choice, not a Source failure, and moving on would double the cost. Any other outcome ends the chain.5. With no admitted candidate, the call returns a `failed` record naming the providers whose Sources can run the- tool ("add a Source from one of these providers: xAI"). With candidates that were all tried and failed, it+ tool ("add a Source from one of these providers: xAI"). When Sources that would run it exist but each has a+ current refusal of the tool, the record names those Sources and points at clearing the refusal in Models › Tools+ instead (amended 2026-10-20, #2873): an upstream refusal is not a missing credential. With candidates that were all tried and failed, itreturns the last failure's reason and names the Sources tried, so the user sees that retrying, or thoseSources, is the issue.- **One deadline for the whole chain**, the tool's call timeout (180 s for search), not one per candidate.@@ -572,8 +591,8 @@ E2E stay."n": {"type": "integer", "minimum": 1, "maximum": 4}}}}```- - **The enum is the image models actually available**: the overlay's `image_models` (§3.1) for each Source where- `runs_on` holds for that model and no current negative `image_generate` evidence exists for the pair (§3.2: a+ - **The enum is the image models actually available**: the overlay's `image_models` (§3.1; on a custom Source only+ those it lists) for each Source where `runs_on` holds for that model and no current negative `image_generate` evidence exists for the pair (§3.2: arelay without the vendor's image endpoint refuses once and is then left out), deduplicated by model id (the first Source in Vibey's order serves an id thattwo Sources offer, unless `default_model` names the other). Each entry's one-line description goes into the`model` description; every line stays short, because the tool block is in every request's prefix. The default is listed first and marked "(default)"; the rest follow sorted by id. So thediff --git a/tests/e2e/test_model_hub_images.py b/tests/e2e/test_model_hub_images.pyindex c3bf6e6f6..b3afb6cbf 100644--- a/tests/e2e/test_model_hub_images.py+++ b/tests/e2e/test_model_hub_images.py@@ -138,7 +138,10 @@ async def test_only_an_upstream_refusal_teaches_that_a_source_lacks_an_image_modgrok = backend_model_catalog.ImageModelSpec("grok-imagine-image", "Grok Imagine", ("size",), ("ratio",), kinds=("api_key",),)- monkeypatch.setattr(hosted_tools_module, "provider_image_models", lambda vendor: (grok,) if vendor == "xai" else ())+ monkeypatch.setattr(+ hosted_tools_module, "source_image_models",+ lambda vendor, protocol, listed: (grok,) if vendor == "xai" else (),+ )vendor, chat_model, model = "xai", "grok-4.6", "grok-imagine-image"else:vendor, chat_model, model = "openai", "gpt-6-astra", "gpt-image-2"diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yamlindex 2e25b4aae..fb4a3ccce 100644--- a/tests/scenarios/model_hub/catalog.yaml+++ b/tests/scenarios/model_hub/catalog.yaml@@ -183,6 +183,7 @@ scenarios:- tests/test_model_hub_vibey_consumer.py::test_both_hop_resolution_copies_state_the_same_contract- tests/test_model_hub_hosted_tools_resolution.py::test_a_hops_facts_come_from_priors_and_refusals- tests/test_model_hub_hosted_tools_resolution.py::test_the_executor_chain_follows_the_users_order_then_vibeys+ - tests/test_model_hub_hosted_tools_resolution.py::test_a_custom_relays_models_take_the_priors_of_the_vendor_that_claims_each- tests/test_model_hub_hosted_tools_resolution.py::test_the_image_enum_is_deterministic_with_the_default_first- tests/test_model_hub_hosted_tools_resolution.py::test_a_turn_freezes_its_tools_executors_and_image_enum_and_each_hop_states_its_own_facts- id: MH-HOSTED-002@@ -361,6 +362,7 @@ scenarios:test: tests/test_model_hub_evidence_rules.py::test_an_upstream_400_teaches_only_the_feature_it_namesrelated_tests:- tests/test_model_hub_evidence_rules.py::test_a_refused_effort_skips_its_hop_instead_of_another_provider_400+ - tests/test_model_hub_evidence_rules.py::test_a_custom_relays_refusal_of_a_declaration_it_was_assumed_to_run_is_learned- tests/test_model_hub_reasoning_tiers.py::test_catalog_row_outranks_user_and_drops_its_client_presets- tests/test_model_hub_reasoning_tiers.py::test_a_persisted_catalog_list_offers_no_client_preset_to_vibey- tests/test_model_hub_vibey_consumer.py::test_a_released_vibey_row_loads_without_its_client_preset@@ -2592,6 +2594,7 @@ scenarios:test: tests/test_model_hub_hosted_executor.py::test_a_proxied_call_that_cannot_complete_is_a_failed_recordrelated_tests:- tests/test_model_hub_hosted_executor.py::test_the_chain_moves_on_only_past_a_source_failure+ - tests/test_model_hub_hosted_executor.py::test_a_call_whose_executors_refused_the_tool_names_them_instead_of_asking_for_a_key- tests/test_model_hub_hosted_executor.py::test_a_call_runs_only_a_tool_its_live_turn_froze- tests/test_model_hub_hosted_executor.py::test_a_turn_keeps_its_tools_and_executor_order_until_the_next_turn- tests/test_model_hub_hosted_executor.py::test_a_malformed_proxy_call_is_refused_before_anything_runs@@ -2626,6 +2629,7 @@ scenarios:- tests/test_model_hub_hosted_images.py::test_a_model_gone_mid_turn_is_unavailable_and_the_record_names_the_others- tests/test_model_hub_hosted_images.py::test_only_usable_images_complete_the_call- tests/test_model_hub_hosted_images.py::test_only_an_upstream_refusal_of_the_model_or_endpoint_is_learned+ - tests/test_model_hub_hosted_images.py::test_a_custom_relay_offers_the_image_models_it_lists_until_its_endpoint_refuses_them- tests/test_model_hub_hosted_images.py::test_a_malformed_image_call_is_refused_before_anything_runs- tests/test_model_hub_hosted_images.py::test_an_image_call_body_is_bounded_by_its_reference_images- tests/test_model_hub_hosted_images.py::test_an_image_call_costs_its_delivered_images_at_their_list_pricediff --git a/tests/test_model_hub_evidence_rules.py b/tests/test_model_hub_evidence_rules.pyindex b7cb1cd11..ad9cd3ccb 100644--- a/tests/test_model_hub_evidence_rules.py+++ b/tests/test_model_hub_evidence_rules.py@@ -118,6 +118,33 @@ async def test_an_upstream_400_teaches_only_the_feature_it_names(assert (record.status, record.detail) == ("unsupported", detail)+ ("protocol", "model_id", "declared", "learned"),+ [+ # A custom relay runs OpenAI's declaration for an OpenAI model, so its refusal of it is learned (#2873).+ ("openai_responses", "gpt-6-luna", "web_search", EvidenceFeature.hosted("web_search", "call")),+ ("openai_responses", "grok-4.6", "x_search", EvidenceFeature.hosted("x_search", "call")),+ # A declaration the relay was never assumed to run teaches nothing about it.+ ("openai_responses", "deepseek-chat", "web_search", None),+ ],+ ids=["openai-model", "xai-model", "unclaimed-model"],+)+def test_a_custom_relays_refusal_of_a_declaration_it_was_assumed_to_run_is_learned(protocol, model_id, declared, learned):+ """MH-HOSTED-006: the narrow rule reads the same bundled priors that declared the tool, so a relay that refuses+ it is not sent the declaration again on every request."""+ from core.handlers.model_hub.adapter import UpstreamRejection+ from core.handlers.model_hub.evidence_rules import learn+ from vibe.backend_model_catalog import hosted_tool_spec++ relay = _source("src_relay0001", "Relay", vendor="custom", protocol=protocol, model_id=model_id)+ rejection = UpstreamRejection(status=400, error_type="invalid_request_error", unsupported_tool_type=declared)+ request = {"input": "hi", "tools": [{"type": declared}]}+ found = learn(+ request, rejection, request_protocol=protocol, source=relay, model_id=model_id, spec_for=hosted_tool_spec,+ )+ assert (found.feature if found is not None else None) == learned++@pytest.mark.asyncioasync def test_a_refused_effort_skips_its_hop_instead_of_another_provider_400(tmp_path):"""MH-HOSTED-006: the next request at a refused effort fails locally, and the chain read shows it."""@@ -271,19 +298,26 @@ async def test_a_refused_effort_still_waits_for_a_capable_hop_that_is_cooling_do@pytest.mark.asyncio-async def test_no_request_path_reads_a_bundled_file_after_startup(tmp_path, monkeypatch):- """MH-HOSTED-006: every immutable bundled input is resolved when the service is built, never on a request."""[email protected](("vendor", "model_id"), [("openai", "shared-model"), ("custom", "gpt-6-luna")])+async def test_no_request_path_reads_a_bundled_file_after_startup(tmp_path, monkeypatch, vendor, model_id):+ """MH-HOSTED-006: every immutable bundled input is resolved when the service is built, never on a request.++ A custom Source's priors read its vendors' catalog protocols too (#2873)."""from dataclasses import replace as replacedfrom pathlib import Pathfrom core.handlers.model_hub.adapter import RawOutcomeKind, UpstreamRejectionfrom core.handlers.model_hub.stream_wire import ProtocolUsageReportfrom tests.test_model_hub_l3 import _canonicalize_fixed_test_routes, _outcome, _service+ from vibe.model_hub_runtime import api_key_vendors- source = _source("src_startup01", "Startup", vendor="openai", protocol="openai_responses")+ # Read once per process: cleared so that only the service's own startup can have read it.+ api_key_vendors.api_key_vendor_catalog.cache_clear()+ api_key_vendors._catalog_by_id.cache_clear()+ source = _source("src_startup01", "Startup", vendor=vendor, protocol="openai_responses", model_id=model_id)service = _service(tmp_path, sources=[source])model = _canonicalize_fixed_test_routes(service)["codex"]- watched = {"backend_models.json", "cliproxyapi_manifest.json"}+ watched = {"backend_models.json", "cliproxyapi_manifest.json", "api_key_vendors.json"}reads = []read_text, path_open = Path.read_text, Path.open@@ -308,15 +342,15 @@ async def test_no_request_path_reads_a_bundled_file_after_startup(tmp_path, monkrejection=UpstreamRejection(status=400, unsupported_tool_type="web_search"),)config = service.store.load()- assert service._effort_refused(source, "shared-model", request) is False- await service._learn_capability_evidence(source, "shared-model", request, rejected)- service.hosted_tools_for_hop(source, "shared-model", service.freeze_turn_hosted_tools(config))+ assert service._effort_refused(source, model_id, request) is False+ await service._learn_capability_evidence(source, model_id, request, rejected)+ service.hosted_tools_for_hop(source, model_id, service.freeze_turn_hosted_tools(config))service.agent_chain("codex", model)service.list_sources()service.hosted_tools_status()service.hosted_call_cost(source,- "shared-model",+ model_id,("web_search",),usage=ProtocolUsageReport.of(input_tokens=10, cached_input_tokens=0, output_tokens=1),counts={"web_search_calls": 1},diff --git a/tests/test_model_hub_hosted_executor.py b/tests/test_model_hub_hosted_executor.pyindex 66f10ab8d..e156afbe4 100644--- a/tests/test_model_hub_hosted_executor.py+++ b/tests/test_model_hub_hosted_executor.py@@ -113,7 +113,9 @@ _EXECUTOR_MODELS: dict[str, tuple[str, ...]] = {}@pytest.fixture(autouse=True)def _executor_models(monkeypatch):_EXECUTOR_MODELS.clear()- monkeypatch.setattr(hosted_tools_module, "provider_executor_models", lambda vendor: _EXECUTOR_MODELS.get(vendor, ()))+ monkeypatch.setattr(+ hosted_tools_module, "source_executor_models", lambda vendor, protocol: _EXECUTOR_MODELS.get(vendor, ()),+ )def _bind(service, tool, executor):@@ -834,6 +836,27 @@ async def test_a_call_reports_the_source_as_its_final_admission_saw_it(tmp_path)assert (answer["execution"]["executor_billing"], answer["execution"]["cost"]) == ("monthly", {"basis": "included"})+async def test_a_call_whose_executors_refused_the_tool_names_them_instead_of_asking_for_a_key(tmp_path):+ """MH-HOSTED-GATEWAY-005: an upstream refusal is not a missing credential (#2873): the record names the Sources+ that refused the tool and points at clearing that refusal, and nothing runs."""++ service = _vibey_service(tmp_path, _sources())+ _bind(service, "web_search", (XAI, "grok-4.6"))+ xai = next(item for item in service.store.config.sources if item.id == XAI)+ await service.record_hosted_refusals(+ xai, [("grok-4.6", EvidenceFeature.hosted("web_search", "call"), "400 invalid_request_error")],+ )+ status, answer = await _call(service, "web_search", {"arguments": {"query": "q"}})+ assert status == 200+ assert answer == {"record": {+ "status": "failed", "sources": [],+ "error": "xAI key refused web search, so no Source can run it right now. "+ "Clear the refusal in Models › Tools to try again.",+ }}+ assert service.adapter.invocations == []++@pytest.mark.asyncioasync def test_failure_text_is_in_the_users_language(tmp_path):"""MH-HOSTED-GATEWAY-005: the record's error is user-visible on the tool card, so it is localized."""diff --git a/tests/test_model_hub_hosted_images.py b/tests/test_model_hub_hosted_images.pyindex 4b9d65676..182853275 100644--- a/tests/test_model_hub_hosted_images.py+++ b/tests/test_model_hub_hosted_images.py@@ -16,7 +16,7 @@ from dataclasses import replaceimport aiohttpimport pytest-from config.v2_config import ModelHubHostedToolConfig+from config.v2_config import ModelHubHostedToolConfig, ModelHubModelConfigfrom core.handlers.model_hub import hosted_images as images_modulefrom core.handlers.model_hub import hosted_tools as hosted_tools_modulefrom core.handlers.model_hub.adapter import RawOutcomeKind@@ -242,6 +242,22 @@ async def test_only_an_upstream_refusal_of_the_model_or_endpoint_is_learned(tmp_assert offered[1] == [model for model in offered[0] if model not in refused]+async def test_a_custom_relay_offers_the_image_models_it_lists_until_its_endpoint_refuses_them(tmp_path):+ """MH-HOSTED-GATEWAY-007: a custom relay that lists an image model of the vendor whose protocol it speaks offers+ it (#2873); a relay without the images endpoint refuses once, and the next turn no longer offers it."""++ relay = _source("src_relayimg1", "OpenAI relay", vendor="custom", protocol="openai_responses", model_id="gpt-6-luna")+ relay.models.append(ModelHubModelConfig(id="gpt-image-2", provenance="discovered"))+ not_served = _outcome(RawOutcomeKind.HTTP_ERROR, status=404, code="not_found_error", source_id=relay.id)+ service = _vibey_service(tmp_path, [relay], handles=[InvokeHandle(not_served)])+ (status, answer), offered = await _call(service, {"model": "gpt-image-2", "prompt": "a cat"}, turns=2)+ assert offered == [["gpt-image-2"], []]+ assert service.adapter.invocations == [(relay.id, "gpt-image-2", "vibey")]+ assert status == 200 and answer["record"]["status"] == "failed"+ live = next(item for item in service.store.config.sources if item.id == relay.id)+ assert service.hosted_evidence().unsupported(live, "gpt-image-2", FEATURE)++@pytest.mark.parametrize("arguments", [{"model": "gpt-image-2", "prompt": "a cat", "style": "vivid"},{"model": "gpt-image-2", "prompt": " "},@@ -289,7 +305,7 @@ async def test_an_image_call_costs_its_delivered_images_at_their_list_price(tmp_"""MH-HOSTED-GATEWAY-007: the price that applies to what was delivered, times the images delivered."""monkeypatch.setattr(- hosted_tools_module, "provider_image_models", lambda vendor: (PRICED,) if vendor == "openai" else (),+ hosted_tools_module, "source_image_models", lambda vendor, protocol, listed: (PRICED,) if vendor == "openai" else (),)service = _vibey_service(tmp_path, [replace(_sources()[0])], handles=[_served(PNG, PNG, size=size)])(status, answer), _ = await _call(service, {"model": "gpt-image-2", "prompt": "a cat", "n": 2})diff --git a/tests/test_model_hub_hosted_tools_config.py b/tests/test_model_hub_hosted_tools_config.pyindex 2cc593977..320c046fb 100644--- a/tests/test_model_hub_hosted_tools_config.py+++ b/tests/test_model_hub_hosted_tools_config.py@@ -337,7 +337,9 @@ def test_an_image_models_card_price_is_only_an_unqualified_list_price(tmp_path,for size, quality, usd in prices),)- monkeypatch.setattr(hosted_tools_module, "provider_image_models", lambda vendor: (spec,) if vendor == "xai" else ())+ monkeypatch.setattr(+ hosted_tools_module, "source_image_models", lambda vendor, protocol, listed: (spec,) if vendor == "xai" else (),+ )service, _store = _api_service(tmp_path)status = service.hosted_tools_status()["hosted_tools"]_validate_status(status)@@ -354,7 +356,9 @@ def test_an_estimated_image_price_of_zero_is_no_unit_price(tmp_path, monkeypatchfrom vibe.backend_model_catalog import ImageModelSpecspec = ImageModelSpec("gemini-3-image", "Nano Banana", ("images",), (), tokens_per_image=1290)- monkeypatch.setattr(hosted_tools_module, "provider_image_models", lambda vendor: (spec,) if vendor == "xai" else ())+ monkeypatch.setattr(+ hosted_tools_module, "source_image_models", lambda vendor, protocol, listed: (spec,) if vendor == "xai" else (),+ )service, _store = _api_service(tmp_path)monkeypatch.setattr(service, "hosted_call_cost", lambda *_args, **_kwargs: SimpleNamespace(usd=valued))image = next(tool for tool in service.hosted_tools_status()["hosted_tools"]["tools"] if tool["name"] == "image_generate")diff --git a/tests/test_model_hub_hosted_tools_resolution.py b/tests/test_model_hub_hosted_tools_resolution.pyindex 8d150044f..9038dda9a 100644--- a/tests/test_model_hub_hosted_tools_resolution.py+++ b/tests/test_model_hub_hosted_tools_resolution.py@@ -41,7 +41,7 @@ from core.handlers.model_hub.hosted_tools import (image_choices,)from core.handlers.model_hub.hosted_turn import ExecutorSlot-from vibe.backend_model_catalog import HostedToolPrice, HostedToolSpec, ImageModelPrice, ImageModelSpec+from vibe.backend_model_catalog import HostedToolPrice, HostedToolSpec, ImageModelPrice, ImageModelSpec, hosted_tool_specNOW = datetime(2026, 10, 15, 12, 0, tzinfo=timezone.utc)ENGINE, AVIBE = "model-hub-engine-v8.0.23-3", "3.2.1"@@ -80,8 +80,13 @@ IMAGE_MODELS = {@pytest.fixture(autouse=True)def _overlay(monkeypatch):- monkeypatch.setattr(hosted_tools_module, "provider_executor_models", lambda vendor: EXECUTOR_MODELS.get(vendor, ()))+ monkeypatch.setattr(+ hosted_tools_module, "source_executor_models", lambda vendor, protocol: EXECUTOR_MODELS.get(vendor, ()),+ )monkeypatch.setattr(hosted_tools_module, "provider_image_models", lambda vendor: IMAGE_MODELS.get(vendor, ()))+ monkeypatch.setattr(+ hosted_tools_module, "source_image_models", lambda vendor, protocol, listed: IMAGE_MODELS.get(vendor, ()),+ )# The bundled overlay's vendors; which of them list image models is `IMAGE_MODELS`.monkeypatch.setattr(hosted_tools_module, "bundled_provider_vendors", lambda: dict.fromkeys(("anthropic", "openai", "xai")))@@ -189,8 +194,8 @@ def test_an_executor_runs_on_a_model_its_source_lists(tmp_path, monkeypatch, lis"""MH-HOSTED-001: an API-key Source admits unlisted models on a hop, but an executor call nobody asked for mustnot guess one: the first of the vendor's executor models the Source lists, or the Source is no executor."""monkeypatch.setattr(- hosted_tools_module, "provider_executor_models",- lambda vendor: ("claude-haiku-5-5", "claude-haiku-4-5") if vendor == "anthropic" else (),+ hosted_tools_module, "source_executor_models",+ lambda vendor, protocol: ("claude-haiku-5-5", "claude-haiku-4-5") if vendor == "anthropic" else (),)source = _source("src_rel00001", "anthropic", "anthropic", listed[0], listed=listed[1:])for model in source.models:@@ -199,6 +204,56 @@ def test_an_executor_runs_on_a_model_its_source_lists(tmp_path, monkeypatch, lisassert [candidate.model_id for candidate in chain] == ([] if expected is None else [expected])+RELAY_MODELS = ("gpt-6-luna", "grok-4.20-0309-non-reasoning", "claude-haiku-5-5", "gpt-image-2", "gemini-2.5-flash-image")+++ ("protocol", "listed", "native", "executors", "images"),+ [+ # The reported relay (#2873): OpenAI's models on OpenAI's protocol run what an OpenAI key would.+ ("openai_responses", ("gpt-6-luna", "gpt-image-2"), {"gpt-6-luna": {"web_search"}},+ {"web_search": "gpt-6-luna"}, ["gpt-image-2"]),+ # One relay serving several vendors: each model takes its own vendor's priors, and each tool runs on an+ # executor model that runs it, not merely the first one listed.+ ("openai_responses", RELAY_MODELS,+ {"gpt-6-luna": {"web_search"}, "grok-4.20-0309-non-reasoning": {"web_search", "x_search"},+ "claude-haiku-5-5": set()},+ {"web_search": "gpt-6-luna", "x_search": "grok-4.20-0309-non-reasoning"}, ["gpt-image-2"]),+ # Anthropic's protocol: Claude's web search, natively and as executor; it has no image endpoint.+ ("anthropic", RELAY_MODELS, {"claude-haiku-5-5": {"web_search"}, "gpt-6-luna": set()},+ {"web_search": "claude-haiku-5-5"}, []),+ # Chat Completions declares no search; Gemini's image models are its vendor's Chat Completions ones.+ ("openai_chat", RELAY_MODELS, {"gpt-6-luna": set()}, {}, ["gemini-2.5-flash-image"]),+ # No executor model listed and no image model listed: the vendor's are not guessed, unlike a hop's model.+ # A model no vendor claims takes no priors at all.+ ("openai_responses", ("gpt-6-astra", "deepseek-chat"), {"gpt-6-astra": {"web_search"}, "deepseek-chat": set()},+ {}, []),+ ],+ ids=["reported-relay", "multi-vendor-responses", "multi-vendor-anthropic", "multi-vendor-chat", "unlisted"],+)+def test_a_custom_relays_models_take_the_priors_of_the_vendor_that_claims_each(+ tmp_path, monkeypatch, protocol, listed, native, executors, images,+):+ """MH-HOSTED-001: a custom Source names no vendor, so the bundled overlay's vendor that claims a model supplies+ its priors, on that vendor's protocol only, with executor and image models only from the Source's listing."""+ monkeypatch.undo() # The bundled overlay, not this module's priors.+ relay = _source("src_rly00001", "custom", protocol, listed[0], base_url="https://relay.example/v1", listed=listed[1:])+ config, evidence = _config(sources=[relay]), _evidence(tmp_path)+ assert {+ model_id: {+ tool for tool in ("web_search", "x_search")+ if hosted_tool_facts(relay, model_id, tool, evidence=evidence, spec_for=hosted_tool_spec).native == "assumed"+ }+ for model_id in native+ } == native+ chains = {+ tool: executor_candidates(config, tool, evidence=evidence, spec_for=hosted_tool_spec)+ for tool in ("web_search", "x_search")+ }+ assert {tool: chain[0].model_id for tool, chain in chains.items() if chain} == executors+ assert [choice.model_id for choice in image_choices(config, evidence=evidence).models] == images++def test_the_executor_chain_follows_the_users_order_then_vibeys(tmp_path):"""MH-HOSTED-001: Sources whose vendor offers the tool, each on its vendor's executor model; a refused pair anda Claude subscription never are candidates."""diff --git a/tests/test_model_hub_runtime.py b/tests/test_model_hub_runtime.pyindex 5fd0ddf5f..75d5a9a68 100644--- a/tests/test_model_hub_runtime.py+++ b/tests/test_model_hub_runtime.py@@ -1843,7 +1843,8 @@ def test_engine_config_declares_text_only_input_only_on_openai_compatibility_moddef test_an_api_key_engine_entry_registers_its_vendors_image_models(tmp_path: Path) -> None:"""MH-HOSTED-GATEWAY-007: image_generate routes only models the engine registered; an OpenAI-compatible entry- serves the images endpoints only for a model it flags, and reload verification expects them all."""+ serves the images endpoints only for a model it flags, and reload verification expects them all. A custom+ relay registers and flags only the image models it lists, of the vendor whose protocol it speaks."""store = EngineStateStore(tmp_path / "state")instance_dir, runtime_secrets = store.prepare_instance("install-1")@@ -1857,7 +1858,9 @@ def test_an_api_key_engine_entry_registers_its_vendors_image_models(tmp_path: Pabase_url=None, model_ids=("gpt-6-astra",)),_binding(refs["gemini"], source_id="src_gemini0001", vendor="gemini", protocol="openai_chat",base_url=None, model_ids=("gemini-3-flash", "gemini-2.5-flash-image")),- _binding(refs["custom"], source_id="src_custom0001", model_ids=("model-a",)),+ _binding(+ refs["custom"], source_id="src_custom0001", model_ids=("model-a", "gemini-2.5-flash-image", "gpt-image-2"),+ ),])config_path = instance_dir / "config.yaml"write_engine_config(@@ -1876,7 +1879,8 @@ def test_an_api_key_engine_entry_registers_its_vendors_image_models(tmp_path: Paassert models(gemini) == {"gemini-3-flash": None, "gemini-2.5-flash-image": True, "gemini-3-pro-image-preview": True,}- assert models(custom) == {"model-a": None}+ # Gemini's image models are Chat Completions ones; GPT Image's vendor speaks Responses, so it stays a chat row.+ assert models(custom) == {"model-a": None, "gemini-2.5-flash-image": True, "gpt-image-2": None}sources = {source.source_id: source for source in store.list_sources()}expected = expected_model_names(store.list_sources(), store, "0")assert f'{sources["src_openai0001"].prefix}/gpt-image-2' in expecteddiff --git a/tests/test_provider_overlay.py b/tests/test_provider_overlay.pyindex 0c7805c4d..4ca244378 100644--- a/tests/test_provider_overlay.py+++ b/tests/test_provider_overlay.py@@ -106,6 +106,13 @@ def test_bundled_providers_section_satisfies_its_schema():("openai", "openai_responses", "o3", "web_search", None),("xai", "openai_responses", "grok-3", "web_search", None),("xai", "anthropic", "grok-4.6", "web_search", None),+ # A custom relay names no vendor: a model takes the priors of the vendor that claims it (#2873) ...+ ("custom", "openai_responses", "gpt-6-luna", "web_search", OPENAI_WEB_SEARCH),+ # ... but only on that vendor's own protocol, the one its declarations were verified on,+ ("custom", "openai_chat", "gpt-6-luna", "web_search", None),+ ("custom", "openai_responses", "claude-opus-5-5", "web_search", None),+ # and a model no vendor claims takes none.+ ("custom", "openai_responses", "deepseek-chat", "web_search", None),],)def test_bundled_overlay_resolves_hosted_tools(vendor, protocol, model, tool, expected):diff --git a/tests/test_vibey_agent.py b/tests/test_vibey_agent.pyindex d09222181..e3439514a 100644--- a/tests/test_vibey_agent.py+++ b/tests/test_vibey_agent.py@@ -3645,10 +3645,11 @@ async def test_vibeys_image_tool_runs_on_the_gateways_image_endpoint_from_the_hofrom tests.test_model_hub_vibey_consumer import _vibey_service# GPT Image at a list price per delivered size, taking reference images.- bundled = hosted_tools_module.provider_image_models+ bundled = hosted_tools_module.source_image_modelspriced = replaced(PRICED, params=("images", "n", "size"))monkeypatch.setattr(- hosted_tools_module, "provider_image_models", lambda vendor: (priced,) if vendor == "openai" else bundled(vendor)+ hosted_tools_module, "source_image_models",+ lambda vendor, protocol, listed: (priced,) if vendor == "openai" else bundled(vendor, protocol, listed),)(tmp_path / "cat.png").write_bytes(base64.b64decode(PNG))service = _vibey_service(tmp_path, _sources(), handles=[_served(PNG, source_id=GEMINI), _served(PNG, size="1536x1024")])@@ -3827,7 +3828,10 @@ async def test_a_proxied_call_after_the_turn_moved_to_another_source_runs_on_thefrom tests.test_model_hub_hosted_executor import OPENAI, XAI, _served_by_openai, _sourcesfrom tests.test_model_hub_vibey_consumer import _vibey_service- monkeypatch.setattr(hosted_tools_module, "provider_executor_models", lambda vendor: ("gpt-6-astra",) if vendor == "openai" else ())+ monkeypatch.setattr(+ hosted_tools_module, "source_executor_models",+ lambda vendor, protocol: ("gpt-6-astra",) if vendor == "openai" else (),+ )service = _vibey_service(tmp_path, _sources(), handles=[_served_by_openai()])config = service.store.configconfig.hosted_tools["web_search"] = ModelHubHostedToolConfig(enabled=True, executor_order=(OPENAI,))@@ -3960,7 +3964,10 @@ async def test_a_search_its_source_refused_names_that_source_through_the_real_gafrom tests.test_model_hub_hosted_executor import OPENAI, XAI, _served_by_openai, _sourcesfrom tests.test_model_hub_vibey_consumer import _vibey_service- monkeypatch.setattr(hosted_tools_module, "provider_executor_models", lambda vendor: ("gpt-6-astra",) if vendor == "openai" else ())+ monkeypatch.setattr(+ hosted_tools_module, "source_executor_models",+ lambda vendor, protocol: ("gpt-6-astra",) if vendor == "openai" else (),+ )service = _vibey_service(tmp_path, _sources(), handles=[_served_by_openai()])service.store.config.hosted_tools["web_search"] = ModelHubHostedToolConfig(enabled=True, executor_order=(OPENAI,))xai = next(source for source in service.store.config.sources if source.id == XAI)diff --git a/vibe/backend_model_catalog.py b/vibe/backend_model_catalog.pyindex aaf199fd1..a0df4f2b8 100644--- a/vibe/backend_model_catalog.py+++ b/vibe/backend_model_catalog.py@@ -799,7 +799,7 @@ def bundled_provider_overlay() -> Mapping[str, tuple[ProviderModelOverlay, ...]]def provider_executor_models(vendor: str) -> tuple[str, ...]:"""The vendor's lightweight models that run proxied search calls, preferred first (vibey-hosted-tools.md §6).- A Source runs the first of them it lists; each names its dated snapshots too.+ A Source runs the first of them it lists that runs the tool; each names its dated snapshots too."""entry = bundled_provider_vendors().get(vendor.strip().lower())@@ -857,14 +857,87 @@ def provider_overlay_entry(vendor: str, model_id: str) -> ProviderModelOverlay |def hosted_tool_spec(vendor: str, protocol: str, model_id: str, tool: str) -> HostedToolSpec | None:- """Return the matching family's declaration, price and include for one tool."""+ """Return the matching family's declaration, price and include for one tool, on a Source of ``vendor``."""- entry = provider_overlay_entry(vendor, model_id)+ prior = prior_vendor(vendor, protocol, model_id)+ entry = provider_overlay_entry(prior, model_id) if prior is not None else Noneif entry is None:return Nonereturn entry.hosted_tools.get(protocol, {}).get(tool)+# The vendor of a Source added as a compatible endpoint (自定义, model-hub-vendor-preset-protocol.md): it names no+# vendor, so the overlay has no entry for it.+CUSTOM_VENDOR: Final = "custom"+++def prior_vendors(vendor: str, protocol: str) -> tuple[str, ...]:+ """The overlay vendors whose priors a Source of ``vendor`` and ``protocol`` may take (vibey-hosted-tools.md §3.1).++ A catalog vendor takes its own. A ``custom`` Source names none, so it may take those of every overlay vendor+ whose catalog protocol it speaks, in overlay order: a route is offered only on the protocol its vendor's was+ verified on, since the engine refuses the rest locally and a local refusal is never learned.+ """++ vendor = vendor.strip().lower()+ if vendor != CUSTOM_VENDOR:+ return (vendor,)+ from vibe.model_hub_runtime.api_key_vendors import pinned_api_key_protocol++ return tuple(name for name in bundled_provider_vendors() if pinned_api_key_protocol(name) == protocol)+++def prior_vendor(vendor: str, protocol: str, model_id: str) -> str | None:+ """The vendor whose priors apply to ``model_id`` on a Source of ``vendor`` and ``protocol``; None for none.++ A catalog vendor's own. On a ``custom`` Source, the one overlay vendor that claims the model (a model family of+ its matches it, or it is one of its image models), when the Source may take that vendor's priors at all. A model+ no vendor claims, or several do, takes none: its vendor is not guessed.+ """++ vendor = vendor.strip().lower()+ if vendor != CUSTOM_VENDOR:+ return vendor+ from core.handlers.model_hub.identifiers import normalized_model_id++ model = normalized_model_id(model_id)+ claimers = [+ name+ for name, entry in bundled_provider_vendors().items()+ if provider_overlay_entry(name, model) is not None or any(spec.id == model for spec in entry.image_models)+ ]+ return claimers[0] if len(claimers) == 1 and claimers[0] in prior_vendors(vendor, protocol) else None+++def source_executor_models(vendor: str, protocol: str) -> tuple[str, ...]:+ """The executor models a Source of ``vendor`` and ``protocol`` may run proxied searches on, preferred first (§6).++ Its vendor's; on a ``custom`` Source, those of every vendor whose priors it may take, in overlay order.+ """++ return tuple(+ dict.fromkeys(model for name in prior_vendors(vendor, protocol) for model in provider_executor_models(name))+ )+++def source_image_models(vendor: str, protocol: str, listed: Iterable[str]) -> tuple[ImageModelSpec, ...]:+ """The image models a Source of ``vendor`` and ``protocol`` may offer, in catalog order (§7.2).++ A catalog vendor's every image model. A ``custom`` Source's are only those it lists (``listed``), each of the+ vendor that claims it: nothing but the endpoint's own inventory says that it serves one.+ """++ if vendor.strip().lower() != CUSTOM_VENDOR:+ return provider_image_models(vendor)+ names = frozenset(listed)+ return tuple(+ spec+ for name in prior_vendors(vendor, protocol)+ for spec in provider_image_models(name)+ if spec.id in names and prior_vendor(vendor, protocol, spec.id) == name+ )++def _overlay_vendor_id(vendor: str) -> str:from config.v2_config import normalize_model_hub_vendor_iddiff --git a/vibe/i18n/en.json b/vibe/i18n/en.jsonindex b59cf50aa..96ed69f8c 100644--- a/vibe/i18n/en.json+++ b/vibe/i18n/en.json@@ -1170,8 +1170,8 @@},"hostedTools": {"noExecutor": {- "web_search": {"one": "No Source can run web search right now. Add an API key from {vendors} as a Source in Models › Sources & gateway; a key stored in Vaults is not used for this.", "several": "No Source can run web search right now. Add an API key from one of {vendors} as a Source in Models › Sources & gateway; a key stored in Vaults is not used for this."},- "x_search": {"one": "No Source can run X search right now. Add an API key from {vendors} as a Source in Models › Sources & gateway; a key stored in Vaults is not used for this.", "several": "No Source can run X search right now. Add an API key from one of {vendors} as a Source in Models › Sources & gateway; a key stored in Vaults is not used for this."}+ "web_search": {"one": "No Source can run web search right now. Add an API key from {vendors} as a Source in Models › Sources & gateway; a key stored in Vaults is not used for this.", "several": "No Source can run web search right now. Add an API key from one of {vendors} as a Source in Models › Sources & gateway; a key stored in Vaults is not used for this.", "refused": "{sources} refused web search, so no Source can run it right now. Clear the refusal in Models › Tools to try again."},+ "x_search": {"one": "No Source can run X search right now. Add an API key from {vendors} as a Source in Models › Sources & gateway; a key stored in Vaults is not used for this.", "several": "No Source can run X search right now. Add an API key from one of {vendors} as a Source in Models › Sources & gateway; a key stored in Vaults is not used for this.", "refused": "{sources} refused X search, so no Source can run it right now. Clear the refusal in Models › Tools to try again."}},"listSeparator": ", ","providerRefused": "The executor's provider refused the call ({detail}).",diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.jsonindex 4ef3a96fb..0142e84bf 100644--- a/vibe/i18n/zh.json+++ b/vibe/i18n/zh.json@@ -1170,8 +1170,8 @@},"hostedTools": {"noExecutor": {- "web_search": {"one": "当前没有能运行网页搜索的供应商。请在 模型 › 供应商与路由 中把 {vendors} 的 API Key 添加为供应商;存在 Vaults 里的密钥不会用于这里。", "several": "当前没有能运行网页搜索的供应商。请在 模型 › 供应商与路由 中把 {vendors} 其中一家的 API Key 添加为供应商;存在 Vaults 里的密钥不会用于这里。"},- "x_search": {"one": "当前没有能运行 X 搜索的供应商。请在 模型 › 供应商与路由 中把 {vendors} 的 API Key 添加为供应商;存在 Vaults 里的密钥不会用于这里。", "several": "当前没有能运行 X 搜索的供应商。请在 模型 › 供应商与路由 中把 {vendors} 其中一家的 API Key 添加为供应商;存在 Vaults 里的密钥不会用于这里。"}+ "web_search": {"one": "当前没有能运行网页搜索的供应商。请在 模型 › 供应商与路由 中把 {vendors} 的 API Key 添加为供应商;存在 Vaults 里的密钥不会用于这里。", "several": "当前没有能运行网页搜索的供应商。请在 模型 › 供应商与路由 中把 {vendors} 其中一家的 API Key 添加为供应商;存在 Vaults 里的密钥不会用于这里。", "refused": "{sources} 拒绝了网页搜索,当前没有能运行它的供应商。在 模型 › 工具 中清除拒绝记录后会再试。"},+ "x_search": {"one": "当前没有能运行 X 搜索的供应商。请在 模型 › 供应商与路由 中把 {vendors} 的 API Key 添加为供应商;存在 Vaults 里的密钥不会用于这里。", "several": "当前没有能运行 X 搜索的供应商。请在 模型 › 供应商与路由 中把 {vendors} 其中一家的 API Key 添加为供应商;存在 Vaults 里的密钥不会用于这里。", "refused": "{sources} 拒绝了 X 搜索,当前没有能运行它的供应商。在 模型 › 工具 中清除拒绝记录后会再试。"}},"listSeparator": "、","providerRefused": "执行方的供应商拒绝了此次调用({detail})。",diff --git a/vibe/model_hub_runtime/config.py b/vibe/model_hub_runtime/config.pyindex 018cfa25f..296519f47 100644--- a/vibe/model_hub_runtime/config.py+++ b/vibe/model_hub_runtime/config.py@@ -15,7 +15,7 @@ from vibe.model_hub_runtime.api_key_vendors import (openai_compatible_endpoint,validate_api_key_auth_scheme,)-from vibe.backend_model_catalog import IMAGE_PROTOCOLS, provider_image_models+from vibe.backend_model_catalog import IMAGE_PROTOCOLS, source_image_modelsfrom vibe.model_hub_runtime.state import EngineStateError, EngineStateStore, RuntimeSecrets, SourceRecord# The engine rotates main.log at 10 MB and deletes the oldest rotated files beyond this total.@@ -279,12 +279,16 @@ def image_model_ids(source: SourceRecord) -> tuple[str, ...]:"""The vendor's image models an API-key Source's engine entry registers, so ``image_generate`` can route them.Only models whose route was verified on API keys, on a protocol whose engine- entry serves the images endpoints.+ entry serves the images endpoints; on a ``custom`` Source, only those it lists."""if source.protocol not in IMAGE_PROTOCOLS:return ()- return tuple(spec.id for spec in provider_image_models(source.vendor) if "api_key" in spec.kinds)+ return tuple(+ spec.id+ for spec in source_image_models(source.vendor, source.protocol, source.model_ids)+ if "api_key" in spec.kinds+ )def _engine_model_name(model: str) -> str: