smolagents purchase research
- Agent pattern:
ToolCallingAgentshortlist - Search surfaces: Shopping, images, and videos
- Saved artifact:
smolagents-purchase-research.md
What you’ll build
A smolagents purchase researcher that combines live listings, visual references, and setup or maintenance demonstrations before recommending a shortlist. Each evidence surface answers a different part of the buying decision.
Default brief: Help a beginner choose a compact espresso machine under USD 700. Recommend no more than three options with tradeoffs, evidence limits, and source URLs.
How the agent works
- Check live listings. Shopping search captures current products, prices, sellers, and availability signals.
- Inspect form and controls. Image search supplies visual references without treating appearance as proof of dimensions.
- Test ownership friction. Video search finds setup and maintenance demonstrations before the agent ranks the shortlist.
Core agent setup
This excerpt keeps the smolagents model, tools, and research guardrails together. The full script also validates credentials, supplies the prompt, and saves the purchase shortlist.
agent = ToolCallingAgent(
model=model,
tools=[
shopping_search(provider="smolagents"),
images_search(provider="smolagents"),
videos_search(provider="smolagents"),
],
instructions=(
"Use all relevant tools, treat listing prices as time-sensitive, "
"and corroborate dimensions rather than inferring them from images."
),
max_steps=8,
)
report = str(agent.run(PROMPT))Run the recipe
Set SERPAPI_API_KEY and OPENAI_API_KEY in the repository-root .env, then run:
uv run --isolated --no-project --with 'serpapi-search-tools[smolagents]' --with python-dotenv cookbook/smolagents/main.pyOptional controls: OPENAI_MODEL, COOKBOOK_PROMPT, and COOKBOOK_OUTPUT_DIR.
Bounded research: The ToolCallingAgent gets eight steps and is instructed to use all relevant surfaces while treating listing prices as time-sensitive.
Inspect the result
The recipe writes cookbook-output/smolagents-purchase-research.md. Expect up to three options with current listing evidence, visual and ownership tradeoffs, evidence limitations, and direct source URLs.
Set COOKBOOK_PROMPT to research a different product, budget, or buyer profile.
SerpApi tools used
shopping_search returns current listings and prices, images_search helps compare form and controls, and videos_search finds setup or maintenance demonstrations. Keeping those signals distinct helps the agent explain price, physical, and ownership tradeoffs in the shortlist.
Framework pattern: The ToolCallingAgent setup follows smolagents’ multiple-tools example and uses SerpApi shopping, image, and video search.