---
title: "Naming Your Agents"
description: "Set the agent name so Sentry can identify, filter, and alert on individual agents in the AI Agents Dashboard."
url: https://docs.sentry.io/ai/monitoring/agents/naming/
---

# Naming Your Agents

Sentry uses the `gen_ai.agent.name` span attribute to identify agents in the [AI Agents Dashboard](https://docs.sentry.io/ai/monitoring/agents/dashboard.md). Without a name, you won't be able to filter for a specific agent, group results by agent, or set up alerts for individual agents.

## [Quick Reference](https://docs.sentry.io/ai/monitoring/agents/naming.md#quick-reference)

| Framework               | Platform | How to Name                                                                                            |
| ----------------------- | -------- | ------------------------------------------------------------------------------------------------------ |
| OpenAI Agents SDK       | Python   | `Agent(name="...")`                                                                                    |
| Pydantic AI             | Python   | `Agent(..., name="...")`                                                                               |
| LangChain               | Python   | `create_agent(model, tools, name="...")`                                                               |
| LangGraph               | Python   | `.compile(name="...")` or `create_react_agent(..., name="...")`                                        |
| Vercel AI SDK           | JS       | `experimental_telemetry: { functionId: "..." }` on `generateText` or `ToolLoopAgent`                   |
| LangGraph               | JS       | `.compile({ name: "..." })` or `createReactAgent({ name: "..." })`                                     |
| LangChain               | JS       | `createAgent({ name: "..." })`                                                                         |
| Mastra                  | JS       | `Agent({ id: "...", name: "..." })`                                                                    |
| .NET (M.E.AI)           | .NET     | `options.Experimental.AgentName = "..."`                                                               |
| Other / raw LLM clients | Any      | [Manual instrumentation](https://docs.sentry.io/ai/monitoring/agents/naming.md#manual-instrumentation) |

## [Framework Integrations](https://docs.sentry.io/ai/monitoring/agents/naming.md#framework-integrations)

Most AI agent frameworks have a built-in name parameter that Sentry picks up automatically.

### [Python](https://docs.sentry.io/ai/monitoring/agents/naming.md#python)

#### [OpenAI Agents SDK](https://docs.sentry.io/ai/monitoring/agents/naming.md#openai-agents-sdk)

The `name` parameter is required by the SDK. Sentry reads it automatically.

```python
from openai import agents

agent = agents.Agent(
    name="Weather Agent",
    instructions="You are a helpful weather assistant.",
    model="gpt-4o-mini",
)
```

[OpenAI Agents integration docs](https://docs.sentry.io/platform-redirect.md?next=%2Fintegrations%2Fopenai-agents%2F)

#### [Pydantic AI](https://docs.sentry.io/ai/monitoring/agents/naming.md#pydantic-ai)

Pass `name` when creating the agent.

```python
from pydantic_ai import Agent

agent = Agent(
    "openai:gpt-4o-mini",
    name="Customer Support Agent",
    system_prompt="You help customers with their questions.",
)
```

[Pydantic AI integration docs](https://docs.sentry.io/platform-redirect.md?next=%2Fintegrations%2Fpydantic-ai%2F)

#### [LangChain](https://docs.sentry.io/ai/monitoring/agents/naming.md#langchain)

Pass `name` to `create_agent`.

```python
from langchain.agents import create_agent
from langchain.chat_models import init_chat_model

model = init_chat_model("gpt-4o-mini", model_provider="openai")
agent = create_agent(model, tools, name="dice_agent")
```

[LangChain integration docs](https://docs.sentry.io/platform-redirect.md?next=%2Fintegrations%2Flangchain%2F)

#### [LangGraph](https://docs.sentry.io/ai/monitoring/agents/naming.md#langgraph)

Pass `name` to `StateGraph.compile()` or `create_react_agent`.

```python
from langgraph.graph import StateGraph

graph = StateGraph(AgentState)
# ... add nodes and edges ...
agent = graph.compile(name="dice_agent")
```

Or with the prebuilt helper:

```python
from langgraph.prebuilt import create_react_agent

agent = create_react_agent(model, tools, name="dice_agent")
```

[LangGraph integration docs](https://docs.sentry.io/platform-redirect.md?next=%2Fintegrations%2Flanggraph%2F)

### [JavaScript / Node.js](https://docs.sentry.io/ai/monitoring/agents/naming.md#javascript--nodejs)

#### [Vercel AI SDK](https://docs.sentry.io/ai/monitoring/agents/naming.md#vercel-ai-sdk)

Set `functionId` in `experimental_telemetry` — Sentry uses this as the agent identifier. This works for both `generateText` and `ToolLoopAgent`:

```javascript
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const result = await generateText({
  model: openai("gpt-4o"),
  prompt: "Tell me a joke",
  experimental_telemetry: {
    isEnabled: true,
    functionId: "joke_agent",
  },
});
```

For the `ToolLoopAgent` class, set `functionId` in the constructor:

```javascript
import { ToolLoopAgent } from "ai";
import { openai } from "@ai-sdk/openai";

const agent = new ToolLoopAgent({
  model: openai("gpt-4o"),
  tools: {
    /* ... */
  },
  experimental_telemetry: {
    isEnabled: true,
    functionId: "weather_agent",
  },
});
```

[Vercel AI SDK integration docs](https://docs.sentry.io/platform-redirect.md?next=%2Fconfiguration%2Fintegrations%2Fvercelai%2F)

#### [LangGraph](https://docs.sentry.io/ai/monitoring/agents/naming.md#langgraph-1)

Pass `name` to `.compile()` or `createReactAgent`.

```javascript
import { StateGraph } from "@langchain/langgraph";

const graph = new StateGraph(AgentState);
// ... add nodes and edges ...
const agent = graph.compile({ name: "weather_agent" });
```

Or with the prebuilt helper:

```javascript
import { createReactAgent } from "@langchain/langgraph/prebuilt";

const agent = createReactAgent({
  llm: model,
  tools: [getWeather],
  name: "weather_agent",
});
```

[LangGraph integration docs](https://docs.sentry.io/platform-redirect.md?next=%2Fconfiguration%2Fintegrations%2Flanggraph%2F)

#### [LangChain](https://docs.sentry.io/ai/monitoring/agents/naming.md#langchain-1)

Pass `name` to `createAgent`.

```javascript
import { createAgent } from "langchain";

const agent = createAgent({
  llm: model,
  tools: [getWeather],
  name: "weather_agent",
});
```

[LangChain integration docs](https://docs.sentry.io/platform-redirect.md?next=%2Fconfiguration%2Fintegrations%2Flangchain%2F)

#### [Mastra](https://docs.sentry.io/ai/monitoring/agents/naming.md#mastra)

Mastra requires both `id` and `name` on the agent definition. The Mastra exporter sends the name to Sentry automatically.

```javascript
const agent = new Agent({
  id: "weather-agent",
  name: "Weather Agent",
  instructions: "You are a helpful weather assistant.",
  model: "openai/gpt-4o",
});
```

[Mastra integration docs](https://docs.sentry.io/platform-redirect.md?next=%2Fai-agent-monitoring%2Fmastra%2F)

### [.NET](https://docs.sentry.io/ai/monitoring/agents/naming.md#net)

Set `AgentName` in the Sentry AI instrumentation options.

```csharp
var client = new OpenAI.Chat.ChatClient("gpt-4o-mini", apiKey)
    .AsIChatClient()
    .AddSentry(options =>
    {
        options.Experimental.AgentName = "WeatherAgent";
    });
```

See the [.NET AI Agents instrumentation docs](https://docs.sentry.io/platforms/dotnet/tracing/instrumentation/ai-agents-module.md) for the full setup.

## [Manual Instrumentation](https://docs.sentry.io/ai/monitoring/agents/naming.md#manual-instrumentation)

For frameworks without built-in naming, or when using raw LLM clients (OpenAI, Anthropic, Google GenAI, LiteLLM), wrap your agent logic in an `invoke_agent` span and set `gen_ai.agent.name`.

### [Python](https://docs.sentry.io/ai/monitoring/agents/naming.md#python-1)

```python
import sentry_sdk

with sentry_sdk.start_span(
    op="gen_ai.invoke_agent",
    name="invoke_agent Weather Agent",
) as span:
    span.set_data("gen_ai.agent.name", "Weather Agent")
    span.set_data("gen_ai.request.model", "gpt-4o-mini")

    result = my_agent.run()

    span.set_data("gen_ai.usage.input_tokens", result.usage.input_tokens)
    span.set_data("gen_ai.usage.output_tokens", result.usage.output_tokens)
```

See [Python manual instrumentation](https://docs.sentry.io/platforms/python/tracing/instrumentation/custom-instrumentation/ai-agents-module.md#invoke-agent-span) for full span attributes.

### [JavaScript](https://docs.sentry.io/ai/monitoring/agents/naming.md#javascript)

```javascript
import * as Sentry from "@sentry/node";

await Sentry.startSpan(
  {
    op: "gen_ai.invoke_agent",
    name: "invoke_agent Weather Agent",
    attributes: {
      "gen_ai.agent.name": "Weather Agent",
      "gen_ai.request.model": "gpt-4o-mini",
    },
  },
  async (span) => {
    const result = await myAgent.run();

    span.setAttribute(
      "gen_ai.usage.input_tokens",
      result.usage.inputTokens,
    );
    span.setAttribute(
      "gen_ai.usage.output_tokens",
      result.usage.outputTokens,
    );
  },
);
```

See [JavaScript manual instrumentation](https://docs.sentry.io/platforms/javascript/guides/node/ai-agent-monitoring.md#invoke-agent-span) for full span attributes.

## [Next Steps](https://docs.sentry.io/ai/monitoring/agents/naming.md#next-steps)

* [AI Agents Dashboard](https://docs.sentry.io/ai/monitoring/agents/dashboard.md) — view and filter agents by name
* [Data Privacy](https://docs.sentry.io/ai/monitoring/agents/privacy.md) — control what data is sent to Sentry
* [Model Costs](https://docs.sentry.io/ai/monitoring/agents/costs.md) — track token usage and estimated costs
