Skip to content

Commit 8e31c42

Browse files
committed
fix(buy-x402): run --set-default existence guard before auto-refill warning
The 'paid/<model> not selectable in LiteLLM' guard ran *after* the no-auto-refill WARNING. A model that LiteLLM would refuse still printed a scary 'every chat turn fails when the pool empties' warning describing a primary-model failure mode that cannot occur when the default was never switched. Reorder so we refuse first and only warn when we are actually about to adopt the model.
1 parent beae994 commit 8e31c42

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

  • internal/embed/skills/buy-x402/scripts

internal/embed/skills/buy-x402/scripts/buy.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,16 @@ def _set_agent_default_model(model_id, auto_refill):
16321632
file=sys.stderr,
16331633
)
16341634
return False
1635+
# Existence guard first: if we're going to refuse anyway, don't emit the
1636+
# auto-refill warning below — it describes a primary-model failure mode
1637+
# that can't happen when the default was never switched.
1638+
if not _litellm_has_model(alias):
1639+
print(
1640+
f" Refusing --set-default: {alias!r} is not selectable in LiteLLM; "
1641+
f"leaving the agent default unchanged.",
1642+
file=sys.stderr,
1643+
)
1644+
return False
16351645
# Safety: a paid primary model bricks chat once the pre-signed pool empties.
16361646
if not (auto_refill and auto_refill.get("enabled")):
16371647
print(
@@ -1646,14 +1656,6 @@ def _set_agent_default_model(model_id, auto_refill):
16461656
" Re-run with --auto-refill, or run 'process --all' on a schedule.",
16471657
file=sys.stderr,
16481658
)
1649-
# Existence guard: never point the agent at an unpublished model.
1650-
if not _litellm_has_model(alias):
1651-
print(
1652-
f" Refusing --set-default: {alias!r} is not selectable in LiteLLM; "
1653-
f"leaving the agent default unchanged.",
1654-
file=sys.stderr,
1655-
)
1656-
return False
16571659
# Primary path: native Hermes writer (atomic; per-request re-read, no restart).
16581660
hermes_bin = _find_hermes_bin()
16591661
if hermes_bin:

0 commit comments

Comments
 (0)