v1.17.0

huggingface/smolagentsv1.17.0May 27, 2025by albertvillanova

AI Summary

Adds structured generation to CodeAgent, RunResult object for Agent.run(), and streamable HTTP MCP servers. Includes a security enhancement preventing indirect submodule access in LocalPythonExecutor.

Key Highlights

  • Added optional structured outputs support in CodeAgent
  • Agent.run() can now return a RunResult object
  • Support for streamable HTTP MCP servers
  • Security enhancement preventing indirect submodule access

New Features

  • Structured generation
  • RunResult
  • Streamable HTTP MCP
  • Security fix

Full Release Notes

## New Features ✨
* **Structured Generation in CodeAgent**: Add optional support for structured outputs in `CodeAgent`, enabling more reliable and consistent generation patterns
  * Adding optional structured generation to CodeAgent by @akseljoonas in https://github.com/huggingface/smolagents/pull/1346
* **Support for Streamable HTTP MCP Servers**: Expand compatibility with new server types to support streamable HTTP MCP implementations
  * Support Streamable HTTP MCP servers by @albertvillanova in https://github.com/huggingface/smolagents/pull/1384
* **Run Results from `Agent.run()`**: The `Agent.run()` method can now return a `RunResult` object, providing richer metadata on agent execution
  * Agent.run() can return RunResult object by @aymeric-roucher in https://github.com/huggingface/smolagents/pull/1337

## Security Enhancements 🔒
* **Safer LocalPythonExecutor**: Prevent indirect submodule access via attribute resolution, mitigating potential security risks in user-defined code
  * Prevent submodules through indirect attribute access in LocalPythonExecutor by @albertvillanova in https://github.com/huggingface/smolagents/pull/1375

## Enhancements 🛠️
* **LocalPythonExecutor Enhancements**:
  * Support annotated assignments within class definition in LocalPythonExecutor by @albertvillanova in https://github.com/huggingface/smolagents/pull/1355
  * Fix evaluate_class_def for Assign Attribute target in LocalPythonExecutor by @albertvillanova in https://github.com/huggingface/smolagents/pull/1357
  * Support 'pass' statement in class definition in LocalPythonExecutor by @albertvillanova in https://github.com/huggingface/smolagents/pull/1358
  * Refactor tests of LocalPythonExecutor by @albertvillanova in https://github.com/huggingface/smolagents/pull/1356
* Improve LaTeX rendering in GradioUI with extended delimiter support by @albertvillanova in https://github.com/huggingface/smolagents/pull/1387

## Bug Fixes 🐛
* **Streaming fixes**
  * Fix live streaming when generating planning steps by @FlorianVal in https://github.com/huggingface/smolagents/pull/1348
  * Stop streaming if LiteLLM provide a finish_reason by @FlorianVal in https://github.com/huggingface/smolagents/pull/1350
  * add api_base and api_keys to preparation of kwargs for generate stream by @FlorianVal in https://github.com/huggingface/smolagents/pull/1344
* Fix WebSearchTool validation error by @albertvillanova in https://github.com/huggingface/smolagents/pull/1367
* Fix smolagents benchmark by @aymeric-roucher in https://github.com/huggingface/smolagents/pull/1377

## Documentation Improvements 📚
* Add example docs about using OpenRouter models by @albertvillanova in https://github.com/huggingface/smolagents/pull/1364
* Fix Llama model name in docs example by @SaiDunoyer in https://github.com/huggingface/smolagents/pull/1379
* fix typo  in docstring in mcp_client.py by @grll in https://github.com/huggingface/smolagents/pull/1380
* Document use_structured_outputs_internally with version added by @albertvillanova in https://github.com/huggingface/smolagents/pull/1388
* Fix rendering of version added in docs by @albertvillanova in https://github.com/huggingface/smolagents/pull/1389
* Fix broken link in agentic RAG examples page by @vksx in https://github.com/huggingface/smolagents/pull/1363

## Maintenance 🏗️
* Bump dev version: v1.17.0.dev0 by @albertvillanova in https://github.com/huggingface/smolagents/pull/1336
* Remove deprecated from_hf_api methods by @albertvillanova in https://github.com/huggingface/smolagents/pull/1351

## New Contributors
* @FlorianVal made their first contribution in https://github.com/huggingface/smolagents/pull/1344
* @vksx made their first contribution in https://github.com/huggingface/smolagents/pull/1363
* @akseljoonas made their first contribution in https://github.com/huggingface/smolagents/pull/1346
* @SaiDunoyer made their first contribution in https://github.com/huggingface/smolagents/pull/1379

**Full Changelog**: https://github.com/huggingface/smolagents/compare/v1.16.1...v1.17.0