import os from smolagents import Agent, DuckDuckGoSearchTool from smolagents.models import OpenAIServerModel def build_agent(): model = OpenAIServerModel( model_id="gpt-4o-mini", api_key=os.environ["OPENAI_API_KEY"], ) tools = [ DuckDuckGoSearchTool(), ] agent = Agent( model=model, tools=tools, max_steps=6, system_prompt=( "You are a careful research agent. " "Use search tools when factual information is required. " "If unsure, search first. " "Return concise final answers only." ), ) return agent