Run AI agents locally with privacy, low latency, and offline access. Dive into how MLX advancements and Mac hardware make powerful agentic workflows possible entirely on-device. You’ll explore code agents such as OpenCode, see how they integrate into Xcode, learn techniques for multi-Mac scaling, and discover how to integrate tools seamlessly — without ever leaving your machine.
00:00 - Introduction 00:32 - The chat and agentic loop 02:42 - Local agentic AI stack 04:36 - Setting up your own agent 05:39 - Making agents fast 06:53 - Concurrency and distributed inference 09:20 - More examples 13:01 - Next steps
This video explains how to build and run agentic AI workflows locally on Apple Silicon using the MLX framework. It details the transition from simple chat interfaces to agentic loops—where AI can use tools, run commands, and iterate on tasks—all while keeping data on the local machine to eliminate cloud costs and privacy concerns.
Hi, I'm Angelos, an engineer on the MLX team. Today I'm going to show you how to build and run
agentic AI workflows entirely on your Mac using MLX. No cloud, no API keys, just your hardware
doing the work. Over the past year, AI agents have gone from research prototypes to everyday
productivity tools. But before we talk about agents, let's look at what we had before.
Here's a chat experience you're familiar with. You send a prompt to that language model.
The model sends a response back. If you need to act on that response, run a command, check a file,
or fix an error, that's on you. But now you're talking to an agent. The agent talks to the model
to decide what to do. Then it calls tools to actually do it. Running commands, reading files,
hitting APIs, it observes the results and goes back to the model to figure out the next step.
User to agent, agent to model, agent to tools. This is the agentic loop, and it keeps cycling
until your task is done. What makes this particularly exciting on Apple Silicon
is that the entire loop can run locally. Your data stays on your machine, AI is available anywhere,
at any time, and there are no usage costs. Let me now show you what this looks like in practice.
Here, I have an agent running locally on my Mac. On my screen, you can see the setup. On the left,
MLX running the model, and on the right, the open code agent I'm interacting with.
I asked it to fetch the recent pull request from our MLX repository,
summarize the changes, and identify anything that needs my attention. The model reasons about the
requests, call the GitHub CLI to fetch PR data, reads through the diffs, and produces a concise
summary. All of this is happening locally. The model runs on my hardware, and only the Git commands
reach the network. Well, it seems like I have a lot of work to do after finishing this video.
Now that you've seen what's possible, let me walk you through how we'll get there today.
We'll start by introducing the local agentic AI stack, the four layers that make all of this work,
from MLX at the foundation all the way up to the agent. Then, I'll show you step-by-step how to
set up your own local agent. After that, we'll look at how MLX gets the most out of your hardware
to make agents fast. And finally, we'll go through more live demos, including building a SwiftUI app
from scratch and fixing a bug in Xcode. Let's start with the stack. The stack that powers local
agentic AI on the Mac has four layers. Let me walk you through each one, starting from the bottom.
At the bottom is MLX, our open-source array framework purpose-built for Apple Silicon.
It handles all the low-level computation, metal acceleration, and memory management.
This is the foundation everything else is built on. One level up, we have the language model layer.
MLX LLM provides everything you need to load, run, quantize, and fine-tune large language models.
It supports thousands of models from Hugging Face and gives you both CLI tools and a Python API.
If you saw our sessions last year, this is what we covered in depth.
But to serve an agent, we need something more, a persistent server with a standard API.
That's where MLX LLM Server comes in. This is an OpenAI-compatible HTTP server that exposes your
local model through a standard API. It supports structural tool calling so the model can invoke
functions reliably and the reasoning models that can analyze complex problems step-by-step before
It's a drop-in replacement for any Cloud LLM API.
And at the top of the stack, we have the agent itself. This can be any framework or tool that
speaks the OpenAI chat completion protocol. Xcode, OpenCode, PyAgent, a custom script,
or anything else. Because MLX LLM Server provides a standard interface,
any agent framework works out of the box. And it's not just us building on this stack.
Several popular apps and tools build on MLX and MLX LLM.
Olama, LM Studio, and VLLM are just a few of the most popular ones.
The ecosystem is broad and growing. And if you're using one of these tools,
chances are you are already running on MLX. So that's the stack. Let me now show you how to
set everything up yourself. It only takes three steps to go from zero to a fully locally agentic
workflow. Step one, install MLX LLM. A single pip install gets you everything you need.
Step two, start the server. Run MLX LLM Server with a model that supports tool calling.
Starting with a small model to test your setup is always a good idea.
The server starts up, loads the model, and is ready to accept requests on localhost.
Step three, point your agent at the local server. In most agent frameworks,
you just set the base URL to your local server's address and you're done. The agent doesn't know
or care that the model is running on your Mac rather than in the cloud.
Let me show you a concrete example. Here's the configuration for OpenCode. We define a local
provider. In particular, we set the URL to localhost and set the model name the server expects.
We also tell OpenCode to use this local model for everything. That's it. Now every interaction
runs through your local model. Now that we have an agent talking to MLX, let's look at how MLX
gets the most out of your hardware and addresses the key challenges of running agents locally.
The first challenge is prompt processing. In an agentic workflow, every time the model receives
tool output, it has to process all that new context before it can reason about the next step.
This happens over and over throughout the agentic loop and it adds up fast.
Agentic sessions usually comprise hundreds of thousands of tokens and most of those
are not generated. The M5 chip introduces dedicated neural accelerators and MLX can
target them for exactly this kind of work. Specifically, neural accelerators make matrix
multiplication four times faster on M5 compared to M4. And with a specialized multiplication
and attention kernels in MLX, this translates almost exactly to prompt processing speedup.
Reducing prompt processing time means your agents can read your code base or process tool results
almost four times faster. And the best part, taking advantage of neural accelerators requires
no spatial arguments or code changes on your part. MLX selects the best kernel for the available
hardware and it just works. Let's now talk about the second challenge, concurrency. In practice,
agents rarely work alone. The common pattern is for an agent to spawn several sub-agents,
each tackling a different part of the problem in parallel. One might be reading documentation,
another searching code, and a third writing tests, all at the same time. That means multiple requests
hitting your local model simultaneously. MLX LLM server handles this with continuous batching.
Instead of processing requests one at a time, it dynamically groups incoming requests into batches
and processes them together on the GPU. New requests can join a batch in progress without
waiting for the current one to finish. The result is that your sub-agents don't stall waiting in a
queue. They all get served concurrently, which keeps the entire agentic workflow moving.
Finally, the third challenge is model size. Sometimes a single machine, even one with 512
gigabytes of RAM, just isn't enough because the model is too large to fit in memory. The most
recent DeepSeq model, for instance, has a whopping 1.6 trillion parameters and requires more than
800 gigabytes of memory just for the weights. MLX's distributed support lets you spread the
model across multiple MACs connected over Thunderbolt or Ethernet. For agents, this is powerful in two
ways. First, it lets you run much larger, more capable models that wouldn't fit on a single
machine. Second, it parallelizes prompt processing across devices, which directly speeds up the
agentic loop since the model can process tool results faster. Setting up distributed inference
with MLXLM server is fairly straightforward. You launch the server using MLXLaunch and a
host file that contains information about the nodes and the type of connection. The model is
automatically started across all available devices and everything else just works. Starting with
macOS 26.2, we have support for Thunderbolt RDMA, which provides low latency, high bandwidth
communication over Thunderbolt. As a result, distributed inference with MLX has seen significant
speedups, up to three times with four nodes. To learn how to set up your MACs for distributed
inference with MLX, check out our session Explore Distributed Inference and Training with MLX.
Remember our PR summary demo from earlier? That was a simple read and report task. Let's now push
things further and see what happens when we ask an agent to write an entire project from scratch
and then fix a bug in an existing one. In this demo, I'm going to ask the agent to build a small
SwiftUI application from scratch. I have started with a blank Xcode project and I'm asking the
agent to build a drawing app for the iPad. And off it goes. The agent first looks at the current
directory to find out the existing project structure, makes a plan to guide its implementation,
and gets on to writing the code. Using an agent means we don't need to copy anything or even build
the project. The agent writes the file, then builds the app, fixing any errors it encounters along the
way. And here we are. The model is done. It only took a couple of minutes to create the first version
of the app. At the same time, I have the project open in Xcode and I'm launching the app in the
simulator. Let's have a look at what the agent created. It seems that we have a fully functional
drawing app. That's really nice for something that was built in two minutes. With agentic coding,
however, we can keep iterating until we are happy with the result. For instance, I prefer rounded
end caps. I think they look much better. Let's ask the agent to add them. The agent will edit the code
and recompile the app until it compiles without errors. Let's test the new version. We now have
rounded end caps. This is cool indeed. It is even more cool that all of this happened locally.
The model ran through MLXLM server on this Mac and the agent used standard development tools
like Xcode Build to verify and build its work. For our final demo, let's look at something that
integrates directly with your development environment. Here, I have the same drawing
app project open in Xcode. Let's connect Xcode to our already running MLX server.
We open the settings and navigate to the intelligence tab. We click on add chat provider
and select a locally hosted provider. We set the port to 8080 or whichever port we selected when
launching our MLX server and we're done. Now Xcode can talk to our local model. I have introduced
the bug to our previously working app and now we can ask the model to fix it. Within seconds, it
identifies the bug and inspects the code around it. Finally, it writes a fix and we can now build and
run our app. This shows how a locally running agent can integrate with your existing development
workflow in Xcode, reading project files, understanding build errors, and making targeted fixes.
Local AI means your code never leaves your Mac. Today, we showed you the full stack for running
agentic AI locally on your Mac, from MLX all the way up to the agent, and how neural accelerators,
continuous batching, and distributed inference make it fast. To get started, install MLXLM,
launch the server, and point your favorite agent at it. Everything we showed today is open source
and available right now. Thank you for watching and I'm excited to see what you build with locally
agentic AI on the Mac.