- Studio
- Managed Agents
- Learn
What an agent is
What an agent is
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:
Concept | Role | Where it ran above |
|---|---|---|
| harness | Runs the agent loop: sends the conversation to the model, runs the tool calls it picks, and records each step. | Your Python process |
| model | Decides the next step: answer, or call a tool. | Mistral's API |
| session | The record of what happened: every message, tool call and result, grouped in turns. See Sessions. | The memory of your process |
| environment | The 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.