Managed Agents
Managed Agents and the Agents SDK are in public preview. Their API, behavior, and limits can change during the preview, and an update can require changes to your code.
Managed Agents runs autonomous agents. An agent works on its own for hours or days, picks up where it stopped after a crash, and runs many sessions in parallel, while you stay in control of what it can reach and do.
You define the agent: its model and instructions, its tools, connectors and skills, its environment, and which tool calls need a person's approval. The Agents SDK (mistralai-agents) drives the model and tool loop and records every step in a session.
Running an agent on your computer is easy. Running it in production also takes:
- durable execution, so a task survives a crash and keeps running after your app exits
- infrastructure to run it, and an environment for each session that needs shell or file access
- secrets for the systems its tools call, kept out of your code
- traces, and a record of every step to audit later
Managed Agents provides all of these. You run the agent in your process while you build, then deploy it with Studio: self-hosted on your servers (agents serve), or Mistral-managed (agents deploy).
For a single model request without an agent loop, use Chat completions. For a process with explicit steps, retries and branching, use Workflows.
Hello world
Install the SDK, set MISTRAL_API_KEY, then run this file with uv run python main.py:
import asyncio
from mistralai import agents
agent = agents.Agent(model="mistral-large-4")
result = asyncio.run(agent.run("Say hello"))
print(result.text)The Quickstart gives the agent a tool and chats with it in your terminal.
Core concepts
An agent is a model and a harness. A session records what the agent does, and the environment is the computer it works on:
| Concept | What it is | Where it runs | To choose, see |
|---|---|---|---|
| model | Decides the next step: answer, or call a tool | Mistral's API, or behind your own gateway | What an agent is |
| harness | Runs the agent loop: calls the model, runs the tools the model picks, and records each step | Your process, or your deployment in Studio, self-hosted or Mistral-managed | Run modes |
| session | The record of what happened: one entry per message, tool call and result. Entries are grouped in turns. A turn runs from your message to the agent's answer, and a message sent meanwhile joins it | In memory in your process, or stored by Mistral once you deploy | Sessions |
| environment | The computer the agent works on: a sandbox where it runs shell commands and edits files. By default an agent has none | A sandbox on Mistral, on the machine that runs the harness, or where you host it | Environment |
The agent can also use your tools, MCP servers and connectors: you list them on the agent, and the harness calls them when the model picks one.
One turn goes like this:
- You send a message to a session.
- The harness sends the conversation to the model.
- The model answers, or picks a tool to call.
- The harness runs the tool and sends the result to the model. Steps 3 and 4 repeat until the model answers.
- The answer comes back to you as the turn's result.
Everything that happens is recorded in a session, and the session provides a bidirectional channel. Your systems, applications and users can interact with a session live, or inspect it later.
Here is a payment review agent at a bank. It reads the alert, the account history, the KYC profile, the sanctions lists and the news on its own, then waits for an analyst before it opens a case:
The Suspicious payment review example builds an agent like this one, with the bank's systems faked by tools.
Why use Managed Agents
Wherever the agent runs, you get:
- Stateful sessions. The session keeps every message, tool call and result, so a follow-up sees the earlier work.
- Control. You add a message to a running turn or interrupt it, and you choose which tool calls need approval, answered by your code or by a person.
- Environments. With a sandbox hosted by Mistral, each session runs its shell commands in its own container, off your servers.
When you deploy with Studio, self-hosted or Mistral-managed, you also get:
- Durable, background execution. A task can run for days. By default, a session ends after 24 hours, or after 4 hours idle, when no turn runs or the turn only waits for you; you can raise both limits. If the machine running it crashes, the turn continues from its last finished model call or tool call, and your app can exit and come back for the result. Mistral stores the session, so you host no database.
- Approvals that outlive your app. The turn waits for the answer, one hour by default, even while your app is closed.
- Tracing. Each turn is a trace in Mistral Studio, with one span per model call and tool call. It needs no setup.
Where the harness runs
| You want | Start it with | Who runs the harness | What happens to the session |
|---|---|---|---|
| To develop, script or test | agents.Agent(...) in your code, or agents chat | Your program | It lives in your process and ends with it |
| Production, with tools that must run inside your network | agents serve | You, on your own servers | Mistral stores it; it survives a crash |
| Production, with nothing to host | agents deploy | Mistral | Mistral stores it; it survives a crash |
Deploy the agent in Deploy your agent. Run modes compares the three modes.
Where to start
| If you want to | Start here |
|---|---|
| Build and chat with a first agent, step by step | Quickstart |
| Deploy it to Mistral and call it from your app | Deploy your agent |
| Step through a turn: answer its approvals, then let it continue | Step through a session |
| Watch a turn's events while you steer it | Build a session app |
| Define the agent: its tools, connectors, skills, secrets, guardrails and environment | What an agent is |
| Get a typed object back | Structured output |
| Split a job across child agents | Subagents |
| Hold a conversation across turns | Sessions |
| Choose which tool calls need an approval | Approvals |
| Choose where the harness runs | Run modes |
Move code from the Agents and Conversations API (client.beta.agents) | Move from the Agents API |
Found a problem? Tell us in Feedback.