# example tiny local agent by A.I. Christianson, founder of gobii.ai, builder of ra-aid.ai## to run: uv run --with 'smolagents[mlx-lm]' --with ddgs smol.py 'how much free disk space do I have?'fromsmolagentsimportCodeAgent,MLXModel,toolfromsubprocessimportrunimportsys@tooldefwrite_file(path:str,content:str)->str:"""Write text. Args: path (str): File path. content (str): Text to write. Returns: str: Status. """try:open(path,"w",encoding="utf-8").write(content)returnf"saved:{path}"exceptExceptionase:returnf"error:{e}"@tooldefsh(cmd:str)->str:"""Run a shell command. Args: cmd (str): Command to execute. Returns: str: stdout+stderr. """try:r=run(cmd,shell=True,capture_output=True,text=True)returnr.stdout+r.stderrexceptExceptionase:returnf"error:{e}"if__name__=="__main__":iflen(sys.argv)<2:print("usage: python agent.py 'your prompt'");sys.exit(1)common="use cat/head to read files, use rg to search, use ls and standard shell commands to explore."agent=CodeAgent(model=MLXModel(model_id="mlx-community/Qwen3-Coder-30B-A3B-Instruct-4bit-dwq-v2",max_tokens=8192,trust_remote_code=True),tools=[write_file,sh],add_base_tools=True,)print(agent.run(" ".join(sys.argv[1:])+" "+common))
Warning
LINK
You are about to visit a link which has been flagged with the above content warnings. Do you wish to continue?