Managed Agents

Note

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

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)
Output
Hello! How can I help you today?

The Quickstart gives the agent a tool and chats with it in your terminal.

Core concepts

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:

ConceptWhat it isWhere it runsTo choose, see
modelDecides the next step: answer, or call a toolMistral's API, or behind your own gatewayWhat an agent is
harnessRuns the agent loop: calls the model, runs the tools the model picks, and records each stepYour process, or your deployment in Studio, self-hosted or Mistral-managedRun modes
sessionThe 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 itIn memory in your process, or stored by Mistral once you deploySessions
environmentThe computer the agent works on: a sandbox where it runs shell commands and edits files. By default an agent has noneA sandbox on Mistral, on the machine that runs the harness, or where you host itEnvironment

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.

YOUR LAPTOPyour Python processYOUR SERVERS MISTRAL your appmodelharness, tools>_environmentsession
Step 1 of 4. You try the agent on your laptop. The harness and your tools run in your Python process, and the session in memory. If the agent has an environment, its sandbox runs in a Docker container. The model runs on Mistral's API.Bands: the model. Orange squares: the harness at work. Dark square: the environment. Rows: the session.

One turn goes like this:

  1. You send a message to a session.
  2. The harness sends the conversation to the model.
  3. The model answers, or picks a tool to call.
  4. The harness runs the tool and sends the result to the model. Steps 3 and 4 repeat until the model answers.
  5. 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 BANK'S MONITORINGMr Le Chonk€9,800 transferto a new accountsends alert 4711sent twice: reviewed onceTHE ANALYST'S APPTHE AGENT ASKS TO OPEN A CASE€9,800 to a new beneficiaryin the UAE, 8.5× his largestpayment in 12 months.ApproveDenyshows what the agent asksthe analyst approvesthe review is backSESSIONalert 4711TURNworkingwaiting for a persondone1monitoringreview alert 47112agent readsthe alert3agent readsthe account history4agent readsthe KYC profile5agent readsthe sanctions lists6agent readsnews on the receiver7agent asksopen a case: waits8analystapproves9case openedCASE-471110agentits review
Step 1 of 5. The bank's monitoring flags Mr Le Chonk's €9,800 transfer to a new account and sends alert 4711 to the payment review agent. One alert, one session.

The Suspicious payment review example builds an agent like this one, with the bank's systems faked by tools.

Why use Managed Agents

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

Where the harness runs

MODELMistral's API>_IN YOUR PROCESSagents.Agent(...), agents chatDEPLOYED WITH STUDIOagents serve, agents deploy
Step 1 of 6. The same agent in two places, calling the same model. Left, in your process: the harness, your tools and the session all live in your program. Right, deployed with Studio, self-hosted or managed by Mistral: the session is stored apart from the process that runs the agent.Orange squares: the harness at work (grey when it stops). Rows: the session.
You wantStart it withWho runs the harnessWhat happens to the session
To develop, script or testagents.Agent(...) in your code, or agents chatYour programIt lives in your process and ends with it
Production, with tools that must run inside your networkagents serveYou, on your own serversMistral stores it; it survives a crash
Production, with nothing to hostagents deployMistralMistral stores it; it survives a crash

Deploy the agent in Deploy your agent. Run modes compares the three modes.

Where to start

Where to start

If you want toStart here
Build and chat with a first agent, step by stepQuickstart
Deploy it to Mistral and call it from your appDeploy your agent
Step through a turn: answer its approvals, then let it continueStep through a session
Watch a turn's events while you steer itBuild a session app
Define the agent: its tools, connectors, skills, secrets, guardrails and environmentWhat an agent is
Get a typed object backStructured output
Split a job across child agentsSubagents
Hold a conversation across turnsSessions
Choose which tool calls need an approvalApprovals
Choose where the harness runsRun modes
Move code from the Agents and Conversations API (client.beta.agents)Move from the Agents API

Found a problem? Tell us in Feedback.