Skip to content

Commit d948e63

Browse files
authored
chore: Improve error message for missing provider dependencies (#3315)
Generated with CC: Replace cryptic KeyError with clear, actionable error message that shows: - Which API the failing provider belongs to - The provider ID and type that's failing - Which dependency is missing - Clear instructions on how to fix the issue ## Test plan Use a run config with Agents API and no safety provider Before: KeyError: <Api.safety: 'safety'> After: Failed to resolve 'agents' provider 'meta-reference' of type 'inline::meta-reference': required dependency 'safety' is not available. Please add a 'safety' provider to your configuration or check if the provider is properly configured.
1 parent ccaf6aa commit d948e63

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

llama_stack/core/resolver.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,15 @@ async def instantiate_providers(
284284
if provider.provider_id is None:
285285
continue
286286

287-
deps = {a: impls[a] for a in provider.spec.api_dependencies}
287+
try:
288+
deps = {a: impls[a] for a in provider.spec.api_dependencies}
289+
except KeyError as e:
290+
missing_api = e.args[0]
291+
raise RuntimeError(
292+
f"Failed to resolve '{provider.spec.api.value}' provider '{provider.provider_id}' of type '{provider.spec.provider_type}': "
293+
f"required dependency '{missing_api.value}' is not available. "
294+
f"Please add a '{missing_api.value}' provider to your configuration or check if the provider is properly configured."
295+
) from e
288296
for a in provider.spec.optional_api_dependencies:
289297
if a in impls:
290298
deps[a] = impls[a]

0 commit comments

Comments
 (0)