With reports circulating about Apple developing a privacy-focused AI agent capable of running multi-step tasks on a Mac, many users are already preparing their systems for agent-style workflows. This practical guide shows you how to set up and run a local AI agent on your Mac today using free, open tools. You will create a persistent assistant that can run shell commands, process files, and handle repeated tasks without sending your data to the cloud. The approach works on current macOS versions and remains useful even after future Apple agent features arrive. Everything stays under your control, which aligns with the privacy emphasis Apple has long promoted.
What You Need
- A Mac running macOS 13 Ventura or later (Apple Silicon preferred for speed)
- At least 16 GB of RAM (32 GB recommended for larger models)
- 20 GB or more of free disk space
- Terminal app (built into macOS)
- Administrator access on your account
- Optional: Homebrew package manager for easier installs
AnAI agentis a program that can plan and execute multiple steps toward a goal, rather than answering a single question. In this guide we build a lightweight local version that uses a language model running entirely on your machine.
Step-by-Step Guide
Step 1: Install Homebrew and Ollama
Homebrew is the standard package manager for Mac. It simplifies installing command-line tools. Ollama is the tool that downloads and runs large language models locally.
Open Terminal and run these commands one at a time:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install ollama
ollama serve
Leave the final command running in its own Terminal window. It starts the local model server. In a new Terminal window, pull a capable model:
ollama pull llama3.1:8b
The 8-billion-parameter model is a good balance of speed and quality for most Macs. Larger models exist if you have more RAM.
Step 2: Create a Simple Agent Script
We will write a short Python script that turns the model into an agent capable of running shell commands when appropriate. First install Python dependencies:
brew install python
pip3 install ollama
Create a new file namedlocal_agent.pyin your home folder with this content:
import ollama
import subprocess
import json
def run_command(cmd):
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
return result.stdout + result.stderr
except Exception as e:
return str(e)
system_prompt = """You are a helpful local Mac agent. When a task needs a shell command, respond with ONLY a JSON object like {"command": "the command here"}. Otherwise answer normally. Never run destructive commands without explicit user confirmation in the conversation."""
print("Local Mac Agent ready. Type 'exit' to quit.")
messages = [{"role": "system", "content": system_prompt}]
while True:
user_input = input("\nYou: ")
if user_input.lower() == "exit":
break
messages.append({"role": "user", "content": user_input})
response = ollama.chat(model="llama3.1:8b", messages=messages)
reply = response["message"]["content"]
messages.append({"role": "assistant", "content": reply})
try:
data = json.loads(reply)
if "command" in data:
print("Running:", data["command"])
output = run_command(data["command"])
print("Output:", output)
messages.append({"role": "user", "content": "Command output: " + output})
followup = ollama.chat(model="llama3.1:8b", messages=messages)
print("Agent:", followup["message"]["content"])
messages.append({"role": "assistant", "content": followup["message"]["content"]})
continue
except:
pass
print("Agent:", reply)
Save the file. This script keeps conversation history and can execute safe shell commands when the model decides one is needed.
Step 3: Run and Test Your Agent
In Terminal, navigate to the folder containing the script and start it:
python3 local_agent.py
Try these practical prompts:
- “List the largest files in my Downloads folder”
- “Create a new folder on my Desktop called ProjectNotes and add a text file with today’s date”
- “Show me the last 10 entries from the system log”
- “Summarize the contents of any .txt files in my Documents folder”
The agent will either answer directly or propose and run a command, then interpret the result. Because everything runs locally, no data leaves your Mac.
Step 4: Make the Agent Persist Across Sessions
For repeated use, create a simple launch script. Save the following asstart_agent.commandin your home folder:
#!/bin/bash
cd ~
source ~/.zshrc 2>/dev/null || true
python3 local_agent.py
Make it executable:
chmod +x start_agent.command
Double-click the file in Finder to launch the agent in a new Terminal window. You can also add it to Login Items under System Settings > General if you want it available quickly after restart.
Step 5: Strengthen Privacy and Permission Controls
Upcoming macOS updates (including changes expected in macOS 27.3) will add clearer warnings when third-party tools request broad system access. Your local agent already avoids those risks because it never requests Accessibility or full-disk access by default.
Still, follow these habits:
- Review System Settings > Privacy & Security regularly
- Grant Terminal or Python only the specific folders it needs
- Never paste API keys or passwords into the agent conversation
- Keep the system prompt’s safety rules intact
If you later experiment with cloud agents, the same permission mindset will help you evaluate the warnings Apple is adding.
Step 6: Extend the Agent with Useful Tools
You can expand capabilities without leaving the local environment. Install a couple of extra utilities:
brew install jq ffmpeg
Then update the system prompt to mention available tools. Example additions:
- Use
jqto parse JSON files - Use
ffmpegfor quick media conversions - Use built-in
osascriptfor simple AppleScript automation
Test with a prompt such as: “Convert the newest video in my Downloads folder to a smaller MP4 suitable for email.” The agent can chain the necessary commands while staying on-device.
Common Mistakes
- Forgetting to keep Ollama running— The model server must stay active. Check with
ollama list. - Running destructive commands— The script includes a safety note in the prompt. Always review proposed commands before they execute.
- Insufficient RAM— The 8B model needs roughly 8–10 GB free. Close other heavy apps or switch to a smaller model such as
phi3. - Permission errors on files— If the agent cannot read a folder, grant Terminal access under System Settings > Privacy & Security > Files and Folders.
- Outdated Python packages— Run
pip3 install --upgrade ollamaif chat calls fail.
Final Check
Confirm your setup is solid with this short checklist:
- Ollama is running and
ollama listshows llama3.1:8b - The Python script starts without errors
- A test command such as “list files in Desktop” produces real output
- No unexpected network connections appear when the agent is idle (check Activity Monitor)
- You can quit cleanly by typing “exit”
If all items pass, your local Mac agent is ready for daily use.
Summary
You now have a working local AI agent that can plan and execute practical tasks on your Mac while keeping data private. The same pattern—local model plus controlled command execution—scales to more advanced workflows as your needs grow. Continue by adding custom tools, refining the system prompt, or connecting the agent to folders you work in every day. As Apple’s own agent features mature, the habits you build here (clear permissions, local-first design, and explicit safety rules) will transfer directly. Start with one repeated task you currently do by hand, hand it to the agent, and refine from there.

