mistralM

Docs

sideBar

What an agent is

An agent is a model and a harness, configured with instructions and capabilities such as tools, connectors and skills.

An agent is a model and a harness. The model decides the next step. The harness runs the agent loop: it sends the conversation to the model and calls the tools the model picks. You configure the agent with instructions and capabilities: tools, connectors and MCP servers, and skills. It can work on a computer, its environment, and it records its work in a session. You define it once, with agents.Agent(...).

This agent reviews payments that a bank's transaction monitoring system flags. It reads the alert and opens a case file when the payment looks suspicious. Its two tools stand in for your bank's systems:

from mistralai import agents

ALERTS = {
    "4711": "Payment of 9,800 EUR from account FR76-3000-4471 to a beneficiary added 3 minutes earlier, "
    "right after a password reset. Flagged: new beneficiary, amount just under 10,000 EUR.",
}

@agents.tool(annotations=agents.ToolAnnotations(read_only_hint=True))
async def get_alert(alert_id: str) -> str:
    """Get a transaction monitoring alert: the payment and why it was flagged."""
    return ALERTS[alert_id]  # read it from your monitoring system

@agents.tool
async def open_case(alert_id: str, summary: str, evidence: list[str]) -> str:
    """Open a case file on a suspicious payment, with the evidence. Returns the case id."""
    return f"CASE-{alert_id}"  # create it in your case system

payment_reviewer = agents.Agent(
    model="mistral-large-4",
    name="payment-reviewer",
    instructions=(
        "Review the alert. Collect the context. If the payment is suspicious, open a case file. "
        "Reply in one sentence."
    ),
    tools=[get_alert, open_case],
)

Give it one alert with agent.run(). Save this next to reviewer.py, set MISTRAL_API_KEY, and run uv run python main.py:

import asyncio

from mistralai import agents

from reviewer import payment_reviewer

async def main() -> None:
    state = await payment_reviewer.run("Review transaction monitoring alert 4711.")
    if isinstance(state, agents.Completed):
        print(state.text)
        print([call.name for call in state.tool_calls])

asyncio.run(main())

Output:

Alert 4711 flags a suspicious 9,800 EUR payment from account FR76-3000-4471 to a beneficiary added just 3 minutes earlier right after a password reset (amount just under the 10,000 EUR threshold), so I opened case file **CASE-4711** with the full evidence.
['client.get_alert', 'client.open_case']

The model read the alert, judged the payment suspicious and opened a case; the SDK ran each tool call it asked for. state is the turn's record; Turns and the turn record shows what it holds.

What happens in a turn

A turn is the work the agent does to answer one message. The core concepts take part in it, and each can run in a different place:

MODELdecides the next stepharnessruns the agent loopENVIRONMENTa sandbox>_>_>_>_tools the harness callstoolMCPconnectorSESSIONthe record of whathappened: turns, entries01user messagehas 1042 shipped?02tool callget_order(1042)03tool resultshipped on Monday04agent messageit shipped on Mondayyou
Step 1 of 5. You send a message. The harness records it in the session.Solid arrow: a call out of the harness. Dashed arrow: its answer. Each row is a session entry.

Concept

Role

Where it ran above

harnessRuns the agent loop: sends the conversation to the model, runs the tool calls it picks, and records each step.Your Python process
modelDecides the next step: answer, or call a tool.Mistral's API
sessionThe record of what happened: every message, tool call and result, grouped in turns. See Sessions.The memory of your process
environmentThe computer the agent works on: a sandbox where it runs shell commands and edits files.None: this agent has no environment

The tools, here get_alert and open_case, are not one of these concepts. They are things the agent can call: you set them on the agent, and the harness runs them. Above, they run in your process.

Where it runs

The same agent runs in your process, or deployed with Studio: self-hosted on your own servers with agents serve, or Mistral-managed with agents deploy. In your process the session lives in memory; deployed, Mistral stores it, so it survives a crash and runs in the background. See Run modes.

Next

Configuring the agent: set the model, its instructions and how many steps a turn can take, and see every argument.