Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(model-hub): hold a route_unconfigured refusal for an explicit retry (#2526)

Call White3ed94789d0dc
diff --git a/core/handlers/model_hub/provenance.py b/core/handlers/model_hub/provenance.py
index a08106509..b5b05d34c 100644
--- a/core/handlers/model_hub/provenance.py
+++ b/core/handlers/model_hub/provenance.py
@@ -204,6 +204,9 @@ class TurnOutcomeRenderingRule:
upstream_failure_key: str | None = None
upstream_failure_without_status_key: str | None = None
connection_failure_key: str | None = None
+ # Only a Models change clears this refusal: the same input fails the same way until
+ # then, so it waits for an explicit retry instead of the automatic startup retries.
+ holds_input: bool = False
# This is the only executable projection of the authoritative section 4.5 matrix.
@@ -258,11 +261,13 @@ TURN_OUTCOME_RENDERING_AUTHORITY: dict[str, TurnOutcomeRenderingRule] = {
outcome="no_candidate",
discriminator="route_unconfigured",
copy_keys=(("interrupted", "modelHub.launch.route_unconfigured"),),
+ holds_input=True,
),
"turn.no_candidate.unlisted": TurnOutcomeRenderingRule(
outcome="no_candidate",
discriminator="model_unlisted",
copy_keys=(("interrupted", "modelHub.launch.model_unlisted"),),
+ holds_input=True,
),
"turn.no_candidate.blocked": TurnOutcomeRenderingRule(
outcome="no_candidate",
@@ -474,6 +479,16 @@ def is_unlisted_model_outcome(projection: TurnOutcomeProjectionInput | None) ->
)
+def outcome_holds_input(projection: TurnOutcomeProjectionInput | None) -> bool:
+ """Whether a refused turn's input waits for an explicit retry, as its matrix row says."""
+
+ return projection is not None and any(
+ rule.holds_input
+ and (rule.outcome, rule.discriminator) == (projection.outcome, projection.discriminator)
+ for rule in TURN_OUTCOME_RENDERING_AUTHORITY.values()
+ )
+
+
REQUEST_NONFALLBACK_TURN_OUTCOME = produce_turn_outcome(
"turn.request_nonfallback"
)
diff --git a/docs/plans/model-hub.md b/docs/plans/model-hub.md
index ecf0ac796..6abc6125f 100644
--- a/docs/plans/model-hub.md
+++ b/docs/plans/model-hub.md
@@ -1325,7 +1325,7 @@ switch, remedy, or message branch absent from it.
| `turn.request_nonfallback` | `failed_terminal` | any non-fallback request-level failure, plus optional `upstream_detail`: the upstream error envelope's `message`, credential-redacted, whitespace-collapsed, and bounded to 400 characters by L1 | the attempted Source remains runnable and no switch occurred | without `upstream_detail`: `models.launch.request_incompatible`: this request is incompatible; switching Sources will not help. With it: `models.launch.request_incompatible_detail`, the same claim followed by the upstream text verbatim so the user can act on the real cause (for example a client-version floor) |
| `turn.engine_down` | `failed_terminal` | local `engine_down` at any request phase, including after an upstream attempt or streamed output | no Source is blamed or mutated; no replay or next-hop walk occurs | `models.errors.engine_down`; after output began it also states that this turn's output may be incomplete |
| `turn.streamed_fallback` | `failed_terminal` | streamed fallback-class Source failure, plus `source_transition_persisted: boolean` recording whether its cooldown or `needs_action` transition was committed | replay is forbidden. When `source_transition_persisted=true`, render `models.launch.retry` only when live inspection of the same effective chain makes a different hop current for the next turn; otherwise no switch exists. When `false`, attempt history remains committed, no switch/current change is claimed, and the existing config-recovery warning owns remediation | persisted with a different current hop: “The next turn has switched Sources; retry.” Persisted with no runnable hop: use the same `waiting`/`interrupted` rendering selected for `exhausted`. Not persisted: `modelHub.errors.stream_interrupted`, with no route-change or new-remedy claim |
-| `turn.no_candidate.unconfigured` | `no_candidate` | configured chain is empty | no Source was attempted because no hop is configured | `models.launch.route_unconfigured`, naming the requested model and pointing to Models |
+| `turn.no_candidate.unconfigured` | `no_candidate` | configured chain is empty | no Source was attempted because no hop is configured; sending the same input again cannot succeed until a Route is configured, so it waits for an explicit retry instead of automatic startup retries | `models.launch.route_unconfigured`, naming the requested model and pointing to Models |
| `turn.no_candidate.unlisted` | `no_candidate` | configured chain is empty because the requested model is not in the backend's model list and keeps no manual Route the backend can address (OpenCode addresses only listed rows) | no Source was attempted because the backend no longer offers this model; sending the same input again cannot succeed, so it waits for an explicit retry instead of automatic startup retries. The id is no model of this backend, so no `supply_interrupted` event is recorded | `models.launch.model_unlisted`, naming the requested model and the backend and asking the user to choose another model |
| `turn.no_candidate.blocked` | `no_candidate` | configured chain is nonempty and model `supply_state` is `waiting` or `interrupted` | no Source was attempted because every exact hop is currently blocked | derive copy from the exact blocker set and reuse `_launch_failure` remedies: reauthorize, replace the key, or top up; `waiting` uses `models.launch.waiting`, while `interrupted` uses `models.launch.interrupted` |
| `turn.canceled` | `canceled` | the turn FSM, never a transport inference, settled Stop/cancel | no Source failure or route switch is fabricated | no Model Hub supply copy; the existing turn-canceled surface owns the message |
diff --git a/docs/plans/vibey-default-agent.md b/docs/plans/vibey-default-agent.md
index c8b0fa981..1c073ce89 100644
--- a/docs/plans/vibey-default-agent.md
+++ b/docs/plans/vibey-default-agent.md
@@ -112,7 +112,9 @@ On master before this change:
- the backend page notice and its Models link
- **One refusal, held.** A supply refusal fails the same way until someone changes Models, so its input is held for
an explicit retry (prewrite failure evidence `model_supply_refusal`) instead of spending the automatic startup
- retries. IM has no Retry control, so there the held input waits in the Session's queue, where the Workbench
+ retries. So are the two route refusals only Models can clear, as their §4.5 matrix rows in
+ [model-hub.md](model-hub.md) say: a model with no Route (`model_hub_route_unconfigured`) and a model not in the
+ backend's list (`model_hub_model_unlisted`). IM has no Retry control, so there the held input waits in the Session's queue, where the Workbench
retries or removes it; the person's next message still runs. The notice is plain text: a supply refusal is shown as
its own copy (`❌ …`), with no "Error:" wrapper and no formatter markup. Another dispatch error is escaped for the
IM it goes to, never for the Workbench.
diff --git a/modules/agents/model_hub.py b/modules/agents/model_hub.py
index a68432980..7090b1a0c 100644
--- a/modules/agents/model_hub.py
+++ b/modules/agents/model_hub.py
@@ -38,6 +38,7 @@ from core.handlers.model_hub.provenance import (
TurnOutcomeProjectionInput,
exact_hop_blockers,
is_unlisted_model_outcome,
+ outcome_holds_input,
project_turn_outcome_copy,
render_turn_outcome_copy,
supply_interruption_reason,
@@ -153,9 +154,6 @@ def drain_turn_mode_stamps(timeout: float) -> bool:
_CONTEXT_LAUNCH_ATTR = "_vibe_model_hub_launch"
_CONTEXT_MODE_ATTR = "_vibe_model_hub_turn_mode"
_CONTEXT_FAILURE_RECORDED_ATTR = "_vibe_model_hub_failure_recorded"
-# The durable hold's reason when a turn asks for a model its backend's list
-# does not hold: the same input fails the same way until another model is chosen.
-UNLISTED_MODEL_RETRY_REASON = "model_hub_model_unlisted"
_NATIVE_QUOTA_RE = re.compile(
r"(?:quota|usage|credit|billing).{0,32}(?:exhaust|exceed|limit|deplet|insufficient)|"
r"(?:exhaust|exceed|limit|deplet|insufficient).{0,32}(?:quota|usage|credit|billing)|"
@@ -549,14 +547,17 @@ def hold_refused_input(context: Any) -> None:
def _hold_unrunnable_input(context: Any, error: ModelHubError) -> None:
- """Keep an input whose model the backend does not list for an explicit retry.
+ """Keep an input only a Models change can run for an explicit retry.
- Sending it again unchanged fails the same way, so it must not spend the
- automatic startup retries a transient failure gets.
+ Its model is not in the backend's list, or has no Route: sending it again
+ unchanged fails the same way, so it must not spend the automatic startup
+ retries a transient failure gets. The hold's reason names the refusal, as
+ ``model_hub_model_unlisted`` or ``model_hub_route_unconfigured``.
"""
- if context is not None and is_unlisted_model_outcome(error.turn_outcome):
- mark_prewrite_recovery_required(context, UNLISTED_MODEL_RETRY_REASON)
+ outcome = error.turn_outcome
+ if context is not None and outcome_holds_input(outcome):
+ mark_prewrite_recovery_required(context, f"model_hub_{outcome.discriminator}")
def _language(controller: Any) -> str:
diff --git a/tests/scenarios/model_hub/test_model_hub_live_resolution_scenarios.py b/tests/scenarios/model_hub/test_model_hub_live_resolution_scenarios.py
index 0d0dc8b00..7a2006124 100644
--- a/tests/scenarios/model_hub/test_model_hub_live_resolution_scenarios.py
+++ b/tests/scenarios/model_hub/test_model_hub_live_resolution_scenarios.py
@@ -1434,24 +1434,26 @@ def test_mh_unlisted_001_removed_model_fails_its_next_turn_with_one_clear_reason
@pytest.mark.parametrize(
- ("case", "discriminator", "held", "event_reason"),
+ ("case", "discriminator", "hold_reason", "event_reason"),
(
- ("listed_without_route", "route_unconfigured", False, "route_unconfigured"),
- ("unlisted", "model_unlisted", True, None),
- ("unlisted_with_manual_route", "blocked_supply_state", False, "source_missing"),
+ ("listed_without_route", "route_unconfigured", "model_hub_route_unconfigured", "route_unconfigured"),
+ ("unlisted", "model_unlisted", "model_hub_model_unlisted", None),
+ ("unlisted_with_manual_route", "blocked_supply_state", None, "source_missing"),
),
)
-def test_only_an_unlisted_model_holds_its_input_for_an_explicit_retry(
+def test_a_refusal_only_models_can_clear_holds_its_input_for_an_explicit_retry(
tmp_path: Path,
case: str,
discriminator: str,
- held: bool,
+ hold_reason: str | None,
event_reason: str | None,
) -> None:
"""MH-UNLISTED-001: an empty chain is the list's answer only for an id the
list does not hold; a listed row still asks for a Route, and a retained
- manual Route still reports its own blocker. Only the unlisted id is final,
- and, being no model of this backend, it interrupts no supply in the feed."""
+ manual Route still reports its own blocker. A missing Route and an unlisted
+ id fail the same way until Models changes, so each holds its input under its
+ own reason; a blocker keeps the automatic startup retries. Being no model of
+ this backend, the unlisted id interrupts no supply in the feed."""
config = _config()
model_id = _requested_model("claude") if case == "listed_without_route" else "claude-gone-9"
@@ -1480,9 +1482,7 @@ def test_only_an_unlisted_model_holds_its_input_for_an_explicit_retry(
assert refused.value.turn_outcome is not None
assert refused.value.turn_outcome.discriminator == discriminator
assert prewrite_failure_evidence(context) == (
- {"reason": "model_hub_model_unlisted", "requires_explicit_retry": True}
- if held
- else {}
+ {"reason": hold_reason, "requires_explicit_retry": True} if hold_reason else {}
)
assert [
event["reason"]