翻篇收录说明
翻篇网页快照

How do multi-step agents work? · Hugging Face

https://huggingface.co/docs/smolagents/conceptual_guides/react

最近抓取:2026-12-01 11:09:34(北京时间)

最近内容变化:2026-12-01 11:09:34(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

We’re on a journey to advance and democratize artificial intelligence through open source and open science.

正文摘录

smolagents documentation How do multi-step agents work? smolagents 🏡 View all docsAWS Trainium & InferentiaAccelerateBitsandbytesCLIChat UIDataset viewerDatasetsDeploying on AWSDiffusersGoogle CloudGoogle TPUsGradioHubHub Python LibraryHuggingface.jsInference Endpoints (dedicated)Inference ProvidersKernelsLeRobotLeaderboardsLightevalMicrosoft AzureOpenEnvOptimumPEFTReachy MiniSafetensorsSentence TransformersTRLTasksText Embeddings InferenceTokenizersTrackioTransformersTransformers.jsXetsmolagentstimm Search documentation mainv1.26.0v1.25.0v1.24.0v1.23.0v1.22.0v1.21.2v1.20.0v1.19.0v1.18.0v1.17.0v1.16.1v1.15.0v1.14.0v1.13.0v1.12.0v1.11.0v1.10.0v1.9.2v1.8.1v1.7.0v1.6.0v1.5.1v1.4.1v1.3.0v1.2.2v1.1.0v0.1.3 ENHIKOZH Join the Hugging Face community and get access to the augmented documentation experience Collaborate on models, datasets and Spaces Faster examples with accelerated inference Switch between documentation themes Sign Up to get started Copy page How do multi-step agents work? The ReAct framework (Yao et al., 2022) is currently the main approach to building agents. The name is based on the concatenation of two words, “Reason” and “Act.” Indeed, agents following this architecture will solve their task in as many steps as needed, each step consisting of a Reasoning step, then an Action step where it formulates tool calls that will bring it closer to solving the task at hand. All agents in smolagents are based on singular MultiStepAgent class, which is an abstraction of ReAct framework. On a basic level, this class performs actions on a cycle of following steps, where existing variables and knowledge is incorporated into the agent logs like below: Initialization: the system prompt is stored in a SystemPromptStep, and the user query is logged into a TaskStep . While loop (ReAct loop): Use agent.write_memory_to_messages() to write the agent logs into a list of LLM-readable chat messages. Send these messages to a Model object to get its completion. Parse the completion to get the action (a JSON blob for ToolCallingAgent, a code snippet for CodeAgent). Execute the action and logs result into memory (an ActionStep). At the end of each step, we run all callback functions defined in agent.step_callbacks . Optionally, when planning is activated, a plan can be periodically revised and stored in a PlanningStep . This includes feeding facts about the task at hand to the memory. For a CodeAgent, it looks like the figure below. Here is a video overview of how that works: We implement two versions of agents: CodeAgent generates its tool calls as Python code snippets. ToolCallingAgent writes its tool calls as JSON, as is common in many frameworks. Depending on your needs, either approach can be used. For instance, web browsing often requires waiting after each page interaction, so JSON tool calls can fit well. Read Open-source LLMs as LangChain Agents blog post to learn more about multi-step agents. Update on GitHub ←🤖 What are agents? Self-correcting Text-to-SQL→