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): project both OpenCode limits once either is known (#2319)
Call White6e54bfa08b09
diff --git a/core/handlers/model_hub/service.py b/core/handlers/model_hub/service.pyindex 9878d4165..e8dc09602 100644--- a/core/handlers/model_hub/service.py+++ b/core/handlers/model_hub/service.py@@ -296,13 +296,13 @@ def project_opencode_public_model("name": model.display_name or identifier,}if model.context_window is not None or model.max_output_tokens is not None:+ # OpenCode requires both limits once either is present and validates the+ # whole config file on start, so one partial entry fails every launch.+ # It reads 0 as unknown: no overflow compaction for the context, and its+ # default cap for the output.projected["limit"] = {- key: value- for key, value in (- ("context", model.context_window),- ("output", model.max_output_tokens),- )- if value is not None+ "context": model.context_window if model.context_window is not None else 0,+ "output": model.max_output_tokens if model.max_output_tokens is not None else 0,}modalities: dict[str, list[str]] = {}if model.input_modalities:diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yamlindex 9257bb02b..002cd3bea 100644--- a/tests/scenarios/model_hub/catalog.yaml+++ b/tests/scenarios/model_hub/catalog.yaml@@ -480,6 +480,12 @@ scenarios:kind: injectionlayer: e2etest: tests/e2e/test_model_hub_backend_settings.py::test_opencode_native_settings_cannot_change_hub_transport+ - id: MH-OPENCODE-LAUNCH-002+ name: Every model the Hub projects for OpenCode satisfies OpenCode's config schema, so one incompletely described model cannot fail every launch+ status: covered+ kind: injection+ layer: unit+ test: tests/test_model_hub_l3.py::test_every_projected_opencode_model_satisfies_the_opencode_schema- id: MH-AC29-001name: A persisted import-shaped Source survives canonical serialization and reloadstatus: covereddiff --git a/tests/test_model_hub_l3.py b/tests/test_model_hub_l3.pyindex e3d7cf4f9..297d9b9b4 100644--- a/tests/test_model_hub_l3.py+++ b/tests/test_model_hub_l3.py@@ -5742,6 +5742,50 @@ def test_opencode_public_model_hides_preserved_efforts_when_reasoning_is_disable}[email protected]("protocol", ["anthropic", "openai_responses"])[email protected](("context_window", "max_output_tokens"), [+ (None, None), (200_000, None), (None, 8_192), (200_000, 8_192),+])[email protected](("input_modalities", "output_modalities"), [([], []), (["text", "image"], []), ([], ["text"])])[email protected]("supports_tools", [None, True, False])[email protected]("supports_reasoning", [None, True, False])+def test_every_projected_opencode_model_satisfies_the_opencode_schema(+ protocol: str,+ context_window: int | None,+ max_output_tokens: int | None,+ input_modalities: list[str],+ output_modalities: list[str],+ supports_tools: bool | None,+ supports_reasoning: bool | None,+) -> None:+ """MH-OPENCODE-LAUNCH-002: OpenCode validates its whole config on start, so+ one model described with only a context window (or only an output cap)+ failed every OpenCode launch, for every model and session."""+ from core.handlers.model_hub.migration import _OPENCODE_MODEL, _opencode_value_well_typed++ model = ModelHubBackendModelConfig(+ id="custom-模型",+ display_name="Custom 模型",+ native_protocol=protocol,+ context_window=context_window,+ max_output_tokens=max_output_tokens,+ input_modalities=input_modalities,+ output_modalities=output_modalities,+ supports_tools=supports_tools,+ supports_reasoning=supports_reasoning,+ reasoning_efforts=["low", "none"],+ )++ projected = project_opencode_public_model(model)++ assert _opencode_value_well_typed(_OPENCODE_MODEL, projected), projected+ if context_window is None and max_output_tokens is None:+ assert "limit" not in projected+ else:+ # A limit the catalog does not know stays OpenCode's "unknown" 0.+ assert projected["limit"] == {"context": context_window or 0, "output": max_output_tokens or 0}++@pytest.mark.parametrize("protocol", ["anthropic", "openai_responses"])@pytest.mark.parametrize("supports_reasoning", [None, True, False])@pytest.mark.parametrize("efforts", [[], ["none"], ["low", "medium", "custom-tier"], ["low", "none", "custom-tier"]])