huggingface/smolagents · warning · FutureWarning
The 'model_id' parameter will be required in version 2.0.0.
Error message
The 'model_id' parameter will be required in version 2.0.0. Please update your code to pass this parameter to avoid future errors. For now, it defaults to 'anthropic/claude-3-5-sonnet-20240620'.
What it means
AnthropicModel.__init__ emits the same style FutureWarning when model_id is omitted; the current fallback is 'anthropic/claude-3-5-sonnet-20240620' but the parameter becomes mandatory in smolagents 2.0.0.
Source
Thrown at src/smolagents/models.py:1234
Custom role conversion mapping to convert message roles in others.
Useful for specific models that do not support specific message roles like "system".
flatten_messages_as_text (`bool`, *optional*): Whether to flatten messages as text.
Defaults to `True` for models that start with "ollama", "groq", "cerebras".
**kwargs:
Additional keyword arguments to forward to the underlying LiteLLM completion call.
"""
def __init__(
self,
model_id: str | None = None,
api_base: str | None = None,
api_key: str | None = None,
custom_role_conversions: dict[str, str] | None = None,
flatten_messages_as_text: bool | None = None,
**kwargs,
):
if not model_id:
warnings.warn(
"The 'model_id' parameter will be required in version 2.0.0. "
"Please update your code to pass this parameter to avoid future errors. "
"For now, it defaults to 'anthropic/claude-3-5-sonnet-20240620'.",
FutureWarning,
)
model_id = "anthropic/claude-3-5-sonnet-20240620"
self.api_base = api_base
self.api_key = api_key
flatten_messages_as_text = (
flatten_messages_as_text
if flatten_messages_as_text is not None
else model_id.startswith(("ollama", "groq", "cerebras"))
)
super().__init__(
model_id=model_id,
custom_role_conversions=custom_role_conversions,
flatten_messages_as_text=flatten_messages_as_text,
**kwargs,View on GitHub (pinned to 30bb116109)
Solutions
- Pass model_id explicitly (e.g. 'claude-sonnet-4-20250514' or your current model)
- Pin the old default explicitly if behavior must not change
- Grep code for AnthropicModel( without model_id before moving to 2.x
Example fix
# before model = AnthropicModel(api_key=KEY) # after model = AnthropicModel(model_id='claude-sonnet-4-20250514', api_key=KEY)
Defensive patterns
Strategy: validation
Validate before calling
model = AnthropicModel(model_id='claude-sonnet-4-20250514', api_key=API_KEY)
Try / catch
import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', FutureWarning)
model = AnthropicModel(api_key=API_KEY) # temporary Prevention
- Pass model_id explicitly for every provider model
- Review dated default model snapshots after upgrades
When it happens
Trigger: Creating AnthropicModel(api_key=...) without model_id after upgrade; legacy snippets relying on the Claude 3.5 Sonnet default.
Common situations: Upgrades where the implicit dated model snapshot is undesirable anyway; billing/capability drift when the pinned default model is deprecated by the provider.
Related errors
- The 'model_id' parameter will be required in version 2.0.0.
- Unsupported model type: {model_type}
- Parameter 'messages' is deprecated and will be removed in ve
- Parameter 'structured_output' was not specified. Currently i
- Parameter 'structured_output' was not specified. Currently i
AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28).
Data as JSON: /api/errors/690fc8590a673e92.
Report an issue: GitHub.