Skip to content

Smolagents (HuggingFace) integration

Astrocyte memory as code-centric tools for HuggingFace Smolagents.

Module: astrocyte.integrations.smolagents Pattern: Tool protocol — name, description, inputs schema, output_type, forward() Framework dependency: smolagents (optional)

Terminal window
pip install astrocyte smolagents
from astrocyte import Astrocyte
from astrocyte.integrations.smolagents import astrocyte_smolagent_tools
brain = Astrocyte.from_config("astrocyte.yaml")
tools = astrocyte_smolagent_tools(brain, bank_id="user-123")
from smolagents import CodeAgent, HfApiModel
agent = CodeAgent(tools=tools, model=HfApiModel())
# The agent writes Python code that calls:
# memory_retain(content="...", tags="pref,ui")
# memory_recall(query="...", max_results=5)
# memory_reflect(query="...")

Each tool is an AstrocyteSmolTool instance implementing the smolagents Tool protocol:

FieldDescription
nameTool identifier (e.g., "memory_retain")
descriptionWhat the tool does (used by the agent)
inputsDict of parameter schemas
output_typeReturn type ("string")
forward(**kwargs)Async execution method
__call__(**kwargs)Sync fallback

astrocyte_smolagent_tools(brain, bank_id, *, include_reflect=True, include_forget=False)

Section titled “astrocyte_smolagent_tools(brain, bank_id, *, include_reflect=True, include_forget=False)”

Returns list[AstrocyteSmolTool].