EVEMISSTechnology

Repository guide · overview · v1

huggingface / smolagents

“🤗 smolagents: a barebones library for agents that think in code.” — as described by its authors

  • AI Agents
  • Python
  • Apache-2.0 · open-source license
Original repository
huggingface/smolagents
Source platform
GitHub
Repository owner / organization
huggingface
License
Apache-2.0 · open-source license
Analyzed revision
30bb1161095dbae2271e6bc3cc4c219cc3897a57
Last verified

Newer revision observed; the code this guide cites is unchanged. The default branch moved to c30b115286e0, checked 2026-10-03. A revision diff of 6 changed files found no change in the code regions this guide cites. The guide still describes revision 30bb1161095d; repository-wide counts (files, calls and so on) refer to that revision.

huggingface/smolagents: Repository Overview

Terms used on this page
Entrypoint record
A file the analyzer marks as a place where execution can start. When it carries a __main__ guard excerpt, the file contains an if __name__ == "__main__": block and the excerpt shows what that block calls; without an excerpt, the file was flagged by its name only.
Bounded static execution path
A call chain reconstructed from the source code without running it, stopped after a fixed number of steps. It shows how far the code can be followed on paper, not what happens at run time.
Unresolved boundary
Where a static path stops because the next call goes into an external library or cannot be resolved without running the code. It marks the edge of this analysis, not a defect in the repository.
Static relations
Calls and imports found in the source. "External or unresolved" relations point outside the analyzed files.
Module role
The analyzer's label for a file, inferred from how many calls go in and out (for example core, entry/orchestration, leaf). It describes a position in the call graph, not the authors' design.
Test-like files
Files whose names or locations look like tests. This analysis counts them; it does not run them.
Observed · inferred · author-claimed · unresolved
How each statement is supported: read directly from the analyzed files; derived by the analyzer from them; stated by the repository's authors (metadata, README); or not established by this analysis.
Verified
Two uses on these pages. In an analyzer record ("verified provenance", "a verified entrypoint") it means the record was read directly from the analyzed files, which these guides call observed; for an entrypoint, the __main__ guard text is present. Since the analyzer fix of 2026-10-04, a file that only has an entrypoint-like name such as cli.py or main.py is recorded as inferred; guides analyzed before that still call such a file verified, and it is still only a guess about how the file is used. It does not mean the code was run or tested. "Last verified" is the date the guide last passed the lab's checks against the analysis record of the stated revision; it is not a review of the repository itself.

smolagents is a Python codebase whose GitHub description calls it 'a barebones library for agents that think in code' (maintainer claim). Apache-2.0 licensed; 185 analyzed files across src, examples, docs and tests. Scripts start from per-file __main__ guards; the static call graph centres on local_python_executor.py, models.py and agents.py. Findings are static-only; runtime behavior is not established.

What this repository is

The GitHub description calls this project 'smolagents: a barebones library for agents that think in code' — the maintainers' wording, carried in repository metadata rather than established by analysis. The metadata homepage is https://huggingface.co/docs/smolagents. The code is almost entirely Python: about 988,225 language bytes versus 326 bytes of Makefile. The LICENSE file and the platform metadata agree on Apache-2.0. The analyzed snapshot has 185 files under docs (81), examples (34), src (21), tests (28), .github (10) and 11 at the root. Metadata records release v1.26.0 published 2026-05-29 and 29,313 stars as of 2026-09-14.

How execution starts

There is no single recorded launcher; the eight recorded Python __main__ guard excerpts differ: six call main(), examples/open_deep_research/app.py's recorded guard calls demo.launch(), and examples/smolagents_benchmark/run.py's recorded excerpt is an args-parsing block. Eight files have such guards: src/smolagents/cli.py, src/smolagents/vision_web_browser.py, examples/structured_output_tool.py, examples/open_deep_research/app.py, examples/open_deep_research/run.py, examples/open_deep_research/run_gaia.py, examples/plan_customization/plan_customization.py, and examples/smolagents_benchmark/run.py. Two more, examples/async_agent/main.py and examples/server/main.py, are flagged as likely executable entrypoints by filename heuristic. The recorded static flows stop early at external boundaries: examples/open_deep_research/run.py's guard calls main(), one recorded bounded path for it terminates at the unresolved load_dotenv boundary, and the analyzer's flow record separately shows main -> parse_args -> unresolved parser.parse_args; examples/open_deep_research/app.py's guard path includes create_agent and GradioUI calls and ends at demo.launch(), all external/unresolved; examples/async_agent/main.py reaches Route and Starlette names that also stay unresolved. The analyzer's summary singles out examples/structured_output_tool.py as the apparent main starting place.

Repository structure and connected modules

The analyzer treats docs, src and tests as subsystem-like top-level directories; examples and .github complete the layout. By resolved static call degree, the most connected module is src/smolagents/local_python_executor.py at 195 incoming and 190 outgoing calls. The analyzer labels such modules 'service/core candidate' from call degree plus entrypoint membership — an inference, not runtime evidence. Next are src/smolagents/models.py (60 in / 66 out), src/smolagents/utils.py (56 in / 8 out) and src/smolagents/agents.py (16 in / 80 out); agents.py's outgoing-heavy profile suggests it calls widely across the codebase. Among examples, examples/open_deep_research/scripts/mdconvert.py is the most connected (30 in / 29 out); in the test tree, tests/test_agents.py reaches 89 in / 89 out.

Dependencies and tests

Dependency records exist only for the examples' two requirements.txt manifests: four records for examples/async_agent (smolagents, starlette, anyio, uvicorn) and 39 for examples/open_deep_research — from anthropic >=0.37.1, transformers >=4.46.0 and torch >=2.2.2 through pandas, Pillow, pypdf and many format-processing or domain libraries. Several records carry no version at all, and torch and python-pptx each appear twice in the open_deep_research manifest. pyproject.toml dependency tables were not parsed, so the core package's own dependencies are not established here. Install, run and build inference is partial, and installation commands are not verified. The tests tree holds 28 test-like files, including tests/conftest.py. tests/test_agents.py is heavily connected (89 in / 89 out) and defines fake model stand-ins such as FakeToolCallModel and FakeCodeModel.

A first reading order

A workable first pass: (1) README.md and pyproject.toml — both analyzer-flagged project-level important files — for the self-description and packaging metadata; (2) LICENSE, which carries the Apache-2.0 text; (3) the agent classes in src/smolagents/agents.py (MultiStepAgent, ToolCallingAgent, CodeAgent) together with the tool layer in src/smolagents/tools.py (Tool, tool decorator, ToolCollection, load_tool); (4) src/smolagents/local_python_executor.py, the most connected module; (5) one runnable example — examples/open_deep_research/run.py or examples/structured_output_tool.py — read next to its __main__ guard; (6) a final look at where static paths terminate at unresolved external boundaries.

Notable symbols

Symbols worth opening early: src/smolagents/agents.py defines MultiStepAgent, ToolCallingAgent and CodeAgent plus RunResult and PromptTemplates. src/smolagents/models.py centres on ChatMessage, ChatMessageToolCall and ChatMessageStreamDelta, with agglomerate_stream_deltas merging stream deltas. src/smolagents/tools.py exposes the Tool class, a tool decorator, ToolCollection, load_tool and launch_gradio_demo. src/smolagents/local_python_executor.py provides safer_eval, safer_func, check_safer_result, InterpreterError, ExecutionTimeoutError and a timeout helper. Those names suggest a deliberately restricted code-execution layer — an inference from naming, not a security assessment. src/smolagents/remote_executors.py defines RemotePythonExecutor alongside E2BExecutor, DockerExecutor, ModalExecutor and BlaxelExecutor. examples/open_deep_research/scripts/mdconvert.py defines DocumentConverter plus converters for HTML, PDF, DOCX, XLSX, PPTX, YouTube and Wikipedia content. src/smolagents/utils.py collects agent error types (AgentError, AgentMaxStepsError) with parse_json_blob and extract_code_from_text.

Limits of this analysis

Everything above comes from static analysis; no code was executed and no installation command was verified. Of 7,633 recorded static relations, 6,888 are external or unresolved and 745 resolve locally. Reflection, runtime dependency injection, dynamic imports, monkey-patching, generated code, framework runtime wiring and dynamic dispatch are not resolved by the analyzer. Dependency records cover only requirements-style manifests — pyproject.toml dependency tables were not parsed — so the core package's dependencies are unknown here. README claim extraction is line-based and may capture code lines, so any README-derived statement should be treated as an author claim at best. What the agents actually do when run is not established by this packet.

What this analysis could not establish

The writing model's own notes on the analysis record. Identifiers such as lim_3, exec_* or claim_… name records of that analysis; the claims table cites the same records.

  • A 'readme.md' case-variant was excluded from important files because the path is not in the analyzed inventory, so README coverage in this packet may be incomplete.
  • No dependency records exist for the core src/smolagents package because pyproject.toml dependency tables were not parsed; its runtime requirements are unknown here.
  • 6,888 of 7,633 static relations are external or unresolved, so behavior at boundaries (model APIs, Starlette, Gradio, remote executors) could not be traced.
  • All listed execution paths terminate at unresolved boundaries; what create_agent, GradioUI or demo.launch do at runtime is not established.
  • The analyzer's summary names examples/structured_output_tool.py as the main starting place while ten files carry entrypoint markers; the primary path for a library user is not established.
Claims and evidence — 40 claims, 40 supported by an independent verifier

Every statement above is a claim that cites grounding IDs from the analysis. IDs are internal to the analysis run; the columns show what each claim rests on and how strong that ground is.

Every substantive statement above is a claim bound to grounding IDs of the analyzed revision. Global grounding IDs are namespaced by the analysis run.

Claim Epistemic status Verifier Grounding (global IDs)
c1 Repository metadata describes the project as 'smolagents: a barebones library for agents that think in code' and gives the homepage https://huggingface.co/docs/smolagents; both are author claims carried in metadata. author_claimed supported analysis_c0e49dab7c5999ba:meta_description, analysis_c0e49dab7c5999ba:meta_homepage
c2 Platform metadata records Python as the primary language, with about 988,225 language bytes of Python and 326 bytes of Makefile. observed supported analysis_c0e49dab7c5999ba:meta_primary_language, analysis_c0e49dab7c5999ba:meta_language_bytes
c3 The license is Apache-2.0, with the GitHub-API detection and the repository's LICENSE file in agreement. observed supported analysis_c0e49dab7c5999ba:meta_license, analysis_c0e49dab7c5999ba:important_4
c4 The analyzed snapshot contains 185 files, distributed over docs (81 files), examples (34), src (21), tests (28), .github (10) and 11 at the root. inferred supported analysis_c0e49dab7c5999ba:summary_repository
c5 Platform metadata records the latest release as v1.26.0 published 2026-05-29, and 29,313 stargazers as of 2026-09-14. observed supported analysis_c0e49dab7c5999ba:meta_latest_release, analysis_c0e49dab7c5999ba:meta_stars
c6 Eight files contain a Python __main__ execution guard. Six of the eight recorded guard excerpts call main(); the recorded guard for examples/open_deep_research/app.py calls demo.launch(), and the recorded excerpt for examples/smolagents_benchmark/run.py is an args-parsing block beginning with args = parse_arguments(). observed supported analysis_c0e49dab7c5999ba:py_entry_c3be260bce7b, analysis_c0e49dab7c5999ba:py_entry_3c44d771157e, analysis_c0e49dab7c5999ba:py_entry_77730e8143f6, analysis_c0e49dab7c5999ba:py_entry_eb911c5c2fc4, analysis_c0e49dab7c5999ba:py_entry_9daffde399e1, analysis_c0e49dab7c5999ba:py_entry_66aae1c925b6, analysis_c0e49dab7c5999ba:py_entry_a424b56a044e, analysis_c0e49dab7c5999ba:py_entry_b2d8852474a5
c7 examples/async_agent/main.py and examples/server/main.py are recorded as likely executable entrypoints by filename heuristic, without a recorded __main__ guard excerpt. observed supported analysis_c0e49dab7c5999ba:entry_4, analysis_c0e49dab7c5999ba:entry_8
c8 The examples/open_deep_research/run.py __main__ guard calls main(); one recorded bounded execution path for run.py terminates at the unresolved load_dotenv boundary, and the analyzer's flow record separately shows main -> parse_args -> unresolved parser.parse_args. inferred supported analysis_c0e49dab7c5999ba:py_entry_9daffde399e1, analysis_c0e49dab7c5999ba:exec_908b95280793
c9 In examples/open_deep_research/app.py, the __main__ guard's bounded path includes create_agent, GradioUI and demo.launch(), each recorded as external/unresolved; the guard excerpt ends with demo.launch(). inferred supported analysis_c0e49dab7c5999ba:py_entry_eb911c5c2fc4, analysis_c0e49dab7c5999ba:exec_5beaf01e7396, analysis_c0e49dab7c5999ba:exec_6e6d72c98a2e, analysis_c0e49dab7c5999ba:exec_9cb721a97873
c10 The bounded paths for examples/async_agent/main.py reach the names Route and Starlette and terminate with reason unresolved_boundary. inferred supported analysis_c0e49dab7c5999ba:entry_4, analysis_c0e49dab7c5999ba:exec_fcb626546464, analysis_c0e49dab7c5999ba:exec_4295bbf65082
c11 The analyzer's repository summary names examples/structured_output_tool.py as the apparent main starting place. inferred supported analysis_c0e49dab7c5999ba:summary_repository
c12 Top-level directories docs, src and tests are flagged as likely subsystems. observed supported analysis_c0e49dab7c5999ba:subsys_1, analysis_c0e49dab7c5999ba:subsys_2, analysis_c0e49dab7c5999ba:subsys_3
c13 src/smolagents/local_python_executor.py has the highest recorded static call degree (195 incoming, 190 outgoing); the 'service/core candidate' label derives from static call degree and entrypoint membership and is an inference, not runtime evidence. inferred supported analysis_c0e49dab7c5999ba:role_22
c14 src/smolagents/models.py (60 incoming / 66 outgoing), src/smolagents/utils.py (56 / 8) and src/smolagents/agents.py (16 / 80) are also labeled service/core candidates; agents.py is outgoing-heavy, suggesting it calls widely. inferred supported analysis_c0e49dab7c5999ba:role_24, analysis_c0e49dab7c5999ba:role_30, analysis_c0e49dab7c5999ba:role_18
c15 examples/open_deep_research/scripts/mdconvert.py shows 30 incoming / 29 outgoing calls, and tests/test_agents.py shows 89 incoming / 89 outgoing, the highest degree recorded in the tests tree. inferred supported analysis_c0e49dab7c5999ba:role_6, analysis_c0e49dab7c5999ba:role_32
c16 Dependency records come from requirements-style manifests only: four records list smolagents, starlette, anyio and uvicorn for examples/async_agent, and 39 records cover examples/open_deep_research, including anthropic >=0.37.1, transformers >=4.46.0, torch >=2.2.2, pandas, Pillow and pypdf. observed supported analysis_c0e49dab7c5999ba:dep_1, analysis_c0e49dab7c5999ba:dep_2, analysis_c0e49dab7c5999ba:dep_3, analysis_c0e49dab7c5999ba:dep_4, analysis_c0e49dab7c5999ba:dep_5, analysis_c0e49dab7c5999ba:dep_43, analysis_c0e49dab7c5999ba:dep_17, analysis_c0e49dab7c5999ba:dep_21, analysis_c0e49dab7c5999ba:dep_23, analysis_c0e49dab7c5999ba:dep_28, analysis_c0e49dab7c5999ba:dep_30, analysis_c0e49dab7c5999ba:lim_3
c17 Several open_deep_research records carry no version at all; torch appears twice (pinned >=2.2.2 and unpinned), and python-pptx appears under two spellings (python_pptx and python-pptx). observed supported analysis_c0e49dab7c5999ba:dep_28, analysis_c0e49dab7c5999ba:dep_41, analysis_c0e49dab7c5999ba:dep_25, analysis_c0e49dab7c5999ba:dep_40
c18 pyproject.toml dependency tables were not parsed by the analyzer, so the core package's own dependencies are not established by this packet. observed supported analysis_c0e49dab7c5999ba:lim_3
c19 Install, run and build inference is partial, and installation commands are not verified. observed supported analysis_c0e49dab7c5999ba:lim_2
c20 The repository contains 28 test-like files, including tests/conftest.py. observed supported analysis_c0e49dab7c5999ba:ev_tests_1
c21 tests/test_agents.py is the most connected test module, with 89 incoming and 89 outgoing static calls. inferred supported analysis_c0e49dab7c5999ba:role_32
c22 tests/test_agents.py defines fake model stand-ins such as FakeToolCallModel and FakeCodeModel. observed supported analysis_c0e49dab7c5999ba:py_class_596a0842c3a0, analysis_c0e49dab7c5999ba:py_class_ded274272d1f
c23 Start with README.md and pyproject.toml (both analyzer-flagged project-level important files), then LICENSE; the license text is Apache-2.0. inferred supported analysis_c0e49dab7c5999ba:important_1, analysis_c0e49dab7c5999ba:important_3, analysis_c0e49dab7c5999ba:important_4, analysis_c0e49dab7c5999ba:meta_license
c24 The agent classes MultiStepAgent, ToolCallingAgent and CodeAgent live in src/smolagents/agents.py; src/smolagents/tools.py provides the Tool class, a tool decorator, ToolCollection and load_tool. observed supported analysis_c0e49dab7c5999ba:py_class_377b3e5cef4b, analysis_c0e49dab7c5999ba:py_class_cda34bde19d5, analysis_c0e49dab7c5999ba:py_class_7318d423d2f8, analysis_c0e49dab7c5999ba:py_class_576e2cf1f52c, analysis_c0e49dab7c5999ba:py_func_7108d785c130, analysis_c0e49dab7c5999ba:py_class_caabc5d0564f, analysis_c0e49dab7c5999ba:py_func_c0e6ee7fa306
c25 src/smolagents/local_python_executor.py is the most connected module by static call degree; a runnable example to read next to its guard is examples/open_deep_research/run.py or examples/structured_output_tool.py, both flagged important and guard-bearing. inferred supported analysis_c0e49dab7c5999ba:role_22, analysis_c0e49dab7c5999ba:important_9, analysis_c0e49dab7c5999ba:important_5, analysis_c0e49dab7c5999ba:py_entry_9daffde399e1, analysis_c0e49dab7c5999ba:py_entry_77730e8143f6
c26 Static paths terminate at unresolved external boundaries and most relations are external/unresolved, so a final pass should inspect those call sites. inferred supported analysis_c0e49dab7c5999ba:lim_1, analysis_c0e49dab7c5999ba:exec_908b95280793, analysis_c0e49dab7c5999ba:relation_counts
c27 src/smolagents/agents.py defines MultiStepAgent, ToolCallingAgent, CodeAgent, RunResult and PromptTemplates. observed supported analysis_c0e49dab7c5999ba:py_class_377b3e5cef4b, analysis_c0e49dab7c5999ba:py_class_cda34bde19d5, analysis_c0e49dab7c5999ba:py_class_7318d423d2f8, analysis_c0e49dab7c5999ba:py_class_db4058c4567f, analysis_c0e49dab7c5999ba:py_class_a07a2790aaac
c28 src/smolagents/models.py defines ChatMessage, ChatMessageToolCall, ChatMessageStreamDelta and agglomerate_stream_deltas, which merges stream deltas. observed supported analysis_c0e49dab7c5999ba:py_class_5b888cb21cd8, analysis_c0e49dab7c5999ba:py_class_0f28b35dbb5a, analysis_c0e49dab7c5999ba:py_class_4708b1fa76d7, analysis_c0e49dab7c5999ba:py_func_b16efd283a42
c29 src/smolagents/tools.py defines the Tool class, a tool decorator, ToolCollection, load_tool and launch_gradio_demo. observed supported analysis_c0e49dab7c5999ba:py_class_576e2cf1f52c, analysis_c0e49dab7c5999ba:py_func_7108d785c130, analysis_c0e49dab7c5999ba:py_class_caabc5d0564f, analysis_c0e49dab7c5999ba:py_func_c0e6ee7fa306, analysis_c0e49dab7c5999ba:py_func_6150df2f7414
c30 src/smolagents/local_python_executor.py defines safer_eval, safer_func, check_safer_result, InterpreterError, ExecutionTimeoutError and a timeout helper. observed supported analysis_c0e49dab7c5999ba:py_func_6bdbdb9d9f7f, analysis_c0e49dab7c5999ba:py_func_0089e39298c4, analysis_c0e49dab7c5999ba:py_func_5ee95b854eaf, analysis_c0e49dab7c5999ba:py_class_5b51c766057d, analysis_c0e49dab7c5999ba:py_class_7c71ed817ffa, analysis_c0e49dab7c5999ba:py_func_d616c395bc6f
c31 Names like safer_eval and check_safer_result suggest a restricted code-execution layer; this is an inference from naming, not a security assessment. inferred supported analysis_c0e49dab7c5999ba:py_func_6bdbdb9d9f7f, analysis_c0e49dab7c5999ba:py_func_5ee95b854eaf, analysis_c0e49dab7c5999ba:py_class_7c71ed817ffa
c32 src/smolagents/remote_executors.py defines RemotePythonExecutor alongside E2BExecutor, DockerExecutor, ModalExecutor and BlaxelExecutor. observed supported analysis_c0e49dab7c5999ba:py_class_3d69d3ad9ac2, analysis_c0e49dab7c5999ba:py_class_eaa889a0309f, analysis_c0e49dab7c5999ba:py_class_8c5125503b78, analysis_c0e49dab7c5999ba:py_class_a0955aac8677, analysis_c0e49dab7c5999ba:py_class_5713a7f1e564
c33 examples/open_deep_research/scripts/mdconvert.py defines DocumentConverter and converters named for HTML, PDF, DOCX, XLSX, PPTX, YouTube and Wikipedia content. observed supported analysis_c0e49dab7c5999ba:py_class_94be754f88ca, analysis_c0e49dab7c5999ba:py_class_74db8770821e, analysis_c0e49dab7c5999ba:py_class_08181637f0a3, analysis_c0e49dab7c5999ba:py_class_d768a4b8facd, analysis_c0e49dab7c5999ba:py_class_dcf693fcc130, analysis_c0e49dab7c5999ba:py_class_eda67d9c6fa0, analysis_c0e49dab7c5999ba:py_class_d41b888b7080, analysis_c0e49dab7c5999ba:py_class_dba8499c7b6e
c34 src/smolagents/utils.py defines agent error types such as AgentError and AgentMaxStepsError plus parse_json_blob and extract_code_from_text. observed supported analysis_c0e49dab7c5999ba:py_class_f7a7463ce7af, analysis_c0e49dab7c5999ba:py_class_bd6a1ac2e2fd, analysis_c0e49dab7c5999ba:py_func_9c31752fa99c, analysis_c0e49dab7c5999ba:py_func_1ce389011439
c35 The analysis is static only; nothing was executed and installation commands are not verified. observed supported analysis_c0e49dab7c5999ba:lim_1, analysis_c0e49dab7c5999ba:lim_2
c36 7,633 static relations were recorded: 6,888 are external or unresolved and 745 are local. observed supported analysis_c0e49dab7c5999ba:relation_counts
c37 Reflection, runtime dependency injection, dynamic imports, monkey-patching, generated code, framework runtime wiring and dynamic dispatch are not resolved by this static analysis. observed supported analysis_c0e49dab7c5999ba:lim_1
c38 Dependency records come only from requirements-style manifests (pyproject.toml dependency tables are not parsed), and install/run/build inference is partial. observed supported analysis_c0e49dab7c5999ba:lim_3, analysis_c0e49dab7c5999ba:lim_2
c39 README claim extraction is line-based and may capture code lines; README-derived statements are author claims at best. observed supported analysis_c0e49dab7c5999ba:lim_4
c40 How the agents behave at runtime is not established by this packet; static analysis cannot cover dynamic dispatch, reflection, generated code or framework runtime behavior. unresolved supported analysis_c0e49dab7c5999ba:claim_7c9925f9c8f4, analysis_c0e49dab7c5999ba:lim_1

Sources, rights and disclosure · attribution-license-templates/v0.1

Rights notice. Original repository hosted on GitHub. Repository source code, documentation, names, media, and related project materials remain subject to the rights of their respective authors, contributors, and other rights holders and to applicable repository license terms.

Platform notice. GitHub is the source hosting platform for the linked repository. GitHub and related marks are trademarks of GitHub, Inc. EVEMISS Technology is not affiliated with or endorsed by GitHub unless explicitly stated otherwise.

How this page is produced. This page was produced using revision-aware repository analysis and AI-assisted editorial tooling. Technical claims are tied to the analyzed repository revision and may be revalidated when the source repository changes.

AI-assisted analysis. Reviewed by EVEMISS Technology through human–AI collaborative review. · Report a rights concern · All repository guides