smolagents is a HuggingFace library for building LLM-powered agents, with a strong emphasis on 'code agents' that generate and execute Python code as actions. The core architecture consists of a ReAct-style loop (MultiStepAgent), with two main implementations: CodeAgent (writes Python code) and ToolCallingAgent (writes JSON tool calls). Agents are model-agnostic, supporting dozens of backends (OpenAI, LiteLLM, Hugging Face Inference API, local Transformers, vLLM, MLX, Bedrock, etc.) via a clean Model abstraction. Tools are defined as Python classes with typed inputs/outputs and automatic JSON schema generation, or via a simple @tool decorator, and can be shared on the HuggingFace Hub. The library includes a built-in AST-based Python executor (LocalPythonExecutor) for safe agent code execution, though it is explicitly not a security boundary; production use is directed toward sandboxed remote executors (E2B, Docker, Modal, Blaxel). Memory is managed through structured step objects (ActionStep, PlanningStep, TaskStep) with callbacks for customization. Additional features include MCP client integration, Gradio-based interactive UI, CLI tools, telemetry via OpenTelemetry, and serialization with SafeSerializer.