With ENABLE_CUSTOM_MODEL_FALLBACK enabled, chatting with a custom
workspace model whose base model was removed still failed with "Model
not found" for non-admin users. The access check ran before the
fallback resolution and walked the preset's base_model_id chain;
has_base_model_access treats a base model without a model-table row as
admin-only, so regular users were rejected before the fallback to the
default (Selected) model could ever apply. Admins bypass the access
check by default, which is why the fallback only appeared to work for
them.
Resolve the fallback model first, and when one applies, skip the
missing base-model hop on the requested preset and enforce access on
the fallback model that will actually serve the chat instead.
check_model_access gains a check_base_model flag for this; all other
callers keep the default chain enforcement.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sc922g12Yp16TdcCt74AWi