[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DQ2JS4Z060PYTFVTJQGQVA":3,"skill-same:01M7DQ2JS4Z060PYTFVTJQGQVA":53},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":46},"01M7DQ2JS4Z060PYTFVTJQGQVA","sentry-setup-ai-monitoring",null,"Setup Sentry AI Agent Monitoring in any project. Use when asked to monitor LLM calls, track AI agents, track conversations, or instrument OpenAI\u002FAnthropic\u002FVercel AI\u002FLangChain\u002FGoogle GenAI\u002FPydantic AI\u002FLaravel AI. Detects installed AI SDKs and configures appropriate integrations.","Hazek-dc\u002FPresensiGuru_FaceNet_EMAR","Hazek-dc","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F75208960?v=4","01M7DEQV5B4YGS86A81DYH81DR","Hazek","01M7DEQV5XP4TM0C6NTHXCXCHR",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fsentry-setup-ai-monitoring\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: sentry-setup-ai-monitoring\ndescription: Setup Sentry AI Agent Monitoring in any project. Use when asked to monitor LLM calls, track AI agents, track conversations, or instrument OpenAI\u002FAnthropic\u002FVercel AI\u002FLangChain\u002FGoogle GenAI\u002FPydantic AI\u002FLaravel AI. Detects installed AI SDKs and configures appropriate integrations.\nlicense: Apache-2.0\ncategory: feature-setup\nparent: sentry-feature-setup\ndisable-model-invocation: true\n---\n\n> [All Skills](..\u002F..\u002FSKILL_TREE.md) > [Feature Setup](..\u002Fsentry-feature-setup\u002FSKILL.md) > AI Monitoring\n\n# Setup Sentry AI Agent Monitoring\n\nConfigure Sentry to track LLM calls, agent executions, tool usage, and token consumption.\n\n## Invoke This Skill When\n\n- User asks to \"monitor AI\u002FLLM calls\" or \"track OpenAI\u002FAnthropic usage\"\n- User wants \"AI observability\" or \"agent monitoring\"\n- User asks about token usage, model latency, or AI costs\n\n**Important:** The SDK versions, API names, and code samples below are examples. Always verify against [docs.sentry.io](https:\u002F\u002Fdocs.sentry.io) before implementing, as APIs and minimum versions may have changed.\n\n## Prerequisites\n\nAI monitoring requires **tracing enabled** (`tracesSampleRate > 0`).\n\nIf the app has multi-turn chats, set a conversation ID by default anywhere it makes sense to identify a chat session. Sentry uses `gen_ai.conversation.id` to group related AI spans into Conversations. Some integrations infer it automatically, but many setups need to set it explicitly.\n\n## Data Capture Warning\n\n**Prompt and output recording captures user content that is likely PII.** In JavaScript, genAI input\u002Foutput capture is **on by default** (governed by `dataCollection.genAI`); in Python it is enabled via `send_default_pii=True`; in Laravel it is enabled via `SENTRY_SEND_DEFAULT_PII=true`. Before relying on this capture (or per-integration overrides — `recordInputs`\u002F`recordOutputs` in JS, `include_prompts` in Python), confirm:\n\n- The application's privacy policy permits capturing user prompts and model responses\n- Captured data complies with applicable regulations (GDPR, CCPA, etc.)\n- Sentry data retention settings are appropriate for the sensitivity of the data\n\n**Ask the user** whether they want prompt\u002Foutput capture enabled. Do not enable prompt\u002Foutput capture without explicit confirmation. Use `tracesSampleRate: 1.0` only in development; in production, use a lower value or a `tracesSampler` function.\n\n## Detection First\n\n**Always detect installed AI SDKs before configuring:**\n\n```bash\n# JavaScript\ngrep -E '\"(openai|@anthropic-ai\u002Fsdk|ai|@langchain|@google\u002Fgenai)\"' package.json\n\n# Python\ngrep -E '(openai|anthropic|langchain|huggingface)' requirements.txt pyproject.toml 2>\u002Fdev\u002Fnull\n\n# PHP \u002F Laravel\ngrep -E '\"(laravel\u002Fai|openai-php|openai\u002F|anthropic|llm)' composer.json 2>\u002Fdev\u002Fnull\nls artisan 2>\u002Fdev\u002Fnull && echo \"Laravel detected\"\n```\n\n## Sampling Check\n\nAfter detecting AI SDKs, check the current sampling configuration:\n\n```bash\n# JavaScript\ngrep -E 'tracesSampleRate|tracesSampler' sentry.*.config.* instrument.* src\u002Finstrument.* app\u002Finstrument.* 2>\u002Fdev\u002Fnull\n\n# Python\ngrep -E 'traces_sample_rate|traces_sampler' *.py **\u002F*.py 2>\u002Fdev\u002Fnull\n\n# PHP \u002F Laravel\ngrep -E 'SENTRY_TRACES_SAMPLE_RATE|traces_sample_rate|traces_sampler' .env config\u002Fsentry.php 2>\u002Fdev\u002Fnull\n```\n\n**If `tracesSampleRate` \u002F `traces_sample_rate` is below 1.0 AND no `tracesSampler` \u002F `traces_sampler` is configured:**\n\nAsk the user:\n\n> \"Your current sample rate is {rate}. Agent runs are sampled as complete span trees — if the root span is dropped, all child gen_ai spans are lost. For full AI visibility, gen_ai-related transactions should be sampled at 100%. Would you like me to set up a `tracesSampler` that keeps AI traces at 100% while sampling other traffic at your current rate?\"\n\nIf user confirms, read `${SKILL_ROOT}\u002Freferences\u002Fsampling.md` for implementation patterns.\n\n## Supported SDKs\n\n### JavaScript\n\n| Package | Integration | Min Sentry SDK | Auto? |\n|---------|-------------|----------------|-------|\n| `openai` | `openAIIntegration()` | 10.53.0 | Yes |\n| `@anthropic-ai\u002Fsdk` | `anthropicAIIntegration()` | 10.53.0 | Yes |\n| `ai` (Vercel) | `vercelAIIntegration()` | 10.53.0 | Yes* |\n| `@langchain\u002F*` | `langChainIntegration()` | 10.53.0 | Yes |\n| `@langchain\u002Flanggraph` | `langGraphIntegration()` | 10.53.0 | Yes |\n| `@google\u002Fgenai` | `googleGenAIIntegration()` | 10.53.0 | Yes |\n\n*Vercel AI: 10.53.0+ required. Requires `experimental_telemetry` per-call.\n\n### Python\n\nIntegrations auto-enable when the AI package is installed — no explicit registration needed:\n\n| Package | Auto? | Notes |\n|---------|-------|-------|\n| `openai` | Yes | Includes OpenAI Agents SDK |\n| `anthropic` | Yes | |\n| `langchain` \u002F `langgraph` | Yes | |\n| `huggingface_hub` | Yes | |\n| `google-genai` | Yes | |\n| `pydantic-ai` | Yes | |\n| `litellm` | **No** | Requires explicit integration |\n| `mcp` (Model Context Protocol) | Yes | |\n\n### PHP \u002F Laravel\n\n| Package | Integration | Min Sentry SDK | Auto? |\n|---------|-------------|----------------|-------|\n| `laravel\u002Fai` | Laravel AI instrumentation in `sentry\u002Fsentry-laravel` | 4.27.0 | Yes |\n\nLaravel AI support requires Laravel 12.x or later, `sentry\u002Fsentry-laravel` 4.27.0 or later, and tracing enabled.\n\n## JavaScript Configuration\n\n### Node.js — auto-enabled integrations\n\nJust ensure tracing is enabled. Integrations auto-enable when the AI package is installed:\n\n```javascript\nSentry.init({\n  dsn: \"YOUR_DSN\",\n  tracesSampleRate: 1.0, \u002F\u002F Lower in production (e.g., 0.1)\n  \u002F\u002F OpenAI, Anthropic, Google GenAI, LangChain integrations auto-enable in Node.js\n});\n```\n\nTo customize (e.g., enable prompt capture after user confirmation — see Data Capture Warning):\n\n```javascript\nSentry.init({\n  dsn: \"YOUR_DSN\",\n  tracesSampleRate: 1.0,\n  dataCollection: {\n    \u002F\u002F To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:\n    \u002F\u002F https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fconfiguration\u002Foptions\u002F#dataCollection\n    \u002F\u002F userInfo: false,\n    \u002F\u002F httpBodies: [],\n  },\n  integrations: [\n    Sentry.openAIIntegration({\n      \u002F\u002F recordInputs\u002FrecordOutputs default to true (governed by dataCollection.genAI)\n    }),\n  ],\n});\n```\n\n### Cloudflare Workers (no runtime patching)\n\nThe Workers runtime (`workerd`) does not support monkey-patching, so Node.js-style auto-instrumentation does not apply. Workers AI (`env.AI`) is auto-instrumented by `withSentry` (v10.67.0+); `openai`, `@anthropic-ai\u002Fsdk`, `@google\u002Fgenai`, and `ai` need either the build-time Sentry Cloudflare Vite plugin (v10.68.0+, experimental) or manual client wrapping; LangChain\u002FLangGraph are manual-only. Read `${SKILL_ROOT}\u002F..\u002F..\u002Freferences\u002Fsdks\u002Fcloudflare\u002Fai-monitoring.md` for the full setup.\n\n### Browser \u002F Next.js OpenAI (manual wrapping required)\n\nIn browser-side code or Next.js meta-framework apps, auto-instrumentation is not available. Wrap the client manually:\n\n```javascript\nimport OpenAI from \"openai\";\nimport * as Sentry from \"@sentry\u002Fnextjs\"; \u002F\u002F or @sentry\u002Freact, @sentry\u002Fbrowser\n\nconst openai = Sentry.instrumentOpenAiClient(new OpenAI());\n\u002F\u002F Use 'openai' client as normal\n```\n\n### LangChain \u002F LangGraph (auto-enabled)\n\n```javascript\nSentry.init({\n  dsn: \"YOUR_DSN\",\n  tracesSampleRate: 1.0,\n  dataCollection: {\n    \u002F\u002F To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:\n    \u002F\u002F https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fconfiguration\u002Foptions\u002F#dataCollection\n    \u002F\u002F userInfo: false,\n    \u002F\u002F httpBodies: [],\n  },\n  integrations: [\n    Sentry.langChainIntegration(),\n    Sentry.langGraphIntegration(),\n  ],\n});\n```\n\n### Vercel AI SDK\n\nAdd to `sentry.edge.config.ts` for Edge runtime:\n```javascript\nSentry.init({\n  dsn: \"YOUR_DSN\",\n  tracesSampleRate: 1.0,\n  dataCollection: {\n    \u002F\u002F To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:\n    \u002F\u002F https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fconfiguration\u002Foptions\u002F#dataCollection\n    \u002F\u002F userInfo: false,\n    \u002F\u002F httpBodies: [],\n  },\n  integrations: [Sentry.vercelAIIntegration()],\n});\n```\n\nEnable telemetry per-call:\n```javascript\nawait generateText({\n  model: openai(\"gpt-4o\"),\n  prompt: \"Hello\",\n  experimental_telemetry: {\n    isEnabled: true,\n    recordInputs: true,\n    recordOutputs: true,\n  },\n});\n```\n\n## Python Configuration\n\nIntegrations auto-enable — just init with tracing. Only add explicit imports to customize options:\n\n```python\nimport sentry_sdk\n\nsentry_sdk.init(\n    dsn=\"YOUR_DSN\",\n    traces_sample_rate=1.0,  # Lower in production (e.g., 0.1)\n    send_default_pii=True,\n    # Integrations auto-enable when the AI package is installed.\n    # Only specify explicitly to customize (e.g., include_prompts):\n    # integrations=[OpenAIIntegration(include_prompts=True)],\n)\n```\n\n## PHP \u002F Laravel AI Configuration\n\nLaravel AI instrumentation auto-enables when both `sentry\u002Fsentry-laravel` and `laravel\u002Fai` are installed and tracing is active.\n\n```bash\ncomposer require sentry\u002Fsentry-laravel \"^4.27.0\"\ncomposer require laravel\u002Fai\nphp artisan vendor:publish --provider=\"Laravel\\Ai\\AiServiceProvider\"\nphp artisan migrate\n```\n\nEnable tracing in `.env`:\n\n```ini\nSENTRY_TRACES_SAMPLE_RATE=1.0\n```\n\nTo include LLM prompts, tool arguments, and responses after explicit user confirmation, enable PII capture:\n\n```ini\nSENTRY_SEND_DEFAULT_PII=true\n```\n\nSentry treats LLM and tool inputs\u002Foutputs as PII and does not capture them by default. Do not enable `SENTRY_SEND_DEFAULT_PII=true` without confirming the Data Capture Warning above.\n\nThe Laravel integration captures these span types automatically:\n\n| Span op | Purpose |\n|---------|---------|\n| `gen_ai.invoke_agent` | Agent prompt lifecycle |\n| `gen_ai.chat` | AI provider chat requests |\n| `gen_ai.execute_tool` | Laravel AI tool executions |\n| `gen_ai.embeddings` | Embedding generation |\n\nFor detailed Laravel setup, verification, Conversations behavior, and feature flags, read `${SKILL_ROOT}\u002F..\u002F..\u002Freferences\u002Fsdks\u002Fphp\u002Fai-monitoring.md`.\n\n## Manual Instrumentation\n\nUse when no supported SDK is detected. Follow the canonical [Sentry Conventions for `gen_ai.*` attributes](https:\u002F\u002Fgetsentry.github.io\u002Fsentry-conventions\u002Fattributes\u002Fgen_ai\u002F) — the [JS docs](https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fguides\u002Fconnect\u002Fai-agent-monitoring\u002F#manual-instrumentation) may lag behind; do not set attributes marked deprecated in the conventions.\n\n### Span Types\n\n| `op` | Span `name` pattern | Purpose |\n|------|---------------------|---------|\n| `gen_ai.{operation}` (e.g. `gen_ai.chat`, `gen_ai.request`) | `{operation} {model}` (e.g. `chat gpt-4o`) | Individual LLM call |\n| `gen_ai.invoke_agent` | `invoke_agent {agent_name}` | Agent execution lifecycle |\n| `gen_ai.execute_tool` | `execute_tool {tool_name}` | Tool\u002Ffunction call |\n| `gen_ai.handoff` | `handoff from {source} to {target}` | Agent-to-agent transition |\n\nFor LLM-call spans, the `op` follows the pattern `gen_ai.{gen_ai.operation.name}` — use `gen_ai.chat`, `gen_ai.embeddings`, `gen_ai.generate_content`, or `gen_ai.text_completion` where the operation is known. Span attributes only accept primitives; arrays\u002Fobjects must be JSON-stringified.\n\n### Example (JavaScript)\n\n```javascript\nconst inputMessages = [\n  { role: \"user\", parts: [{ type: \"text\", content: \"Tell me a joke\" }] },\n];\n\nawait Sentry.startSpan({\n  op: \"gen_ai.chat\",\n  name: \"chat gpt-4o\",\n  attributes: {\n    \"gen_ai.request.model\": \"gpt-4o\",\n    \"gen_ai.operation.name\": \"chat\",\n    \"gen_ai.input.messages\": JSON.stringify(inputMessages),\n  },\n}, async (span) => {\n  const result = await llmClient.complete(inputMessages);\n\n  const outputMessages = [\n    {\n      role: \"assistant\",\n      parts: [\n        \u002F\u002F Thinking\u002Freasoning content goes in a `reasoning` part, NOT a `text` part.\n        \u002F\u002F Sentry surfaces it separately and filters it out of the Conversations view.\n        { type: \"reasoning\", content: result.reasoning },\n        { type: \"text\", content: result.text },\n      ],\n      finish_reason: result.finishReason,\n    },\n  ];\n  span.setAttribute(\"gen_ai.output.messages\", JSON.stringify(outputMessages));\n  span.setAttribute(\"gen_ai.usage.input_tokens\", result.inputTokens);\n  span.setAttribute(\"gen_ai.usage.output_tokens\", result.outputTokens);\n  return result;\n});\n```\n\n### Key Attributes\n\n**Common (all AI spans):**\n\n| Attribute | Required | Description |\n|-----------|----------|-------------|\n| `gen_ai.request.model` | Yes | Model identifier (e.g., `gpt-4o`, `claude-sonnet-4-6`) |\n| `gen_ai.operation.name` | No | Operation label (`chat`, `embeddings`, `invoke_agent`, `execute_tool`, `handoff`, etc.) |\n| `gen_ai.agent.name` | No | Agent name (set on agent and tool spans) |\n\n**Model config (LLM call spans):**\n\n| Attribute | Description |\n|-----------|-------------|\n| `gen_ai.request.reasoning_effort` | Reasoning effort level for reasoning models (e.g., `low`, `medium`, `high`). Supported values vary by provider. |\n\n**Request \u002F response content (PII — enable only after confirming; see Data Capture Warning above):**\n\n| Attribute | Description |\n|-----------|-------------|\n| `gen_ai.input.messages` | JSON-stringified array of input messages. Each item uses `{role, parts}` where `parts` is `[{type, content}]`; `role` is `\"user\"`, `\"assistant\"`, `\"tool\"`, or `\"system\"`. Common part `type`s: `\"text\"`, `\"reasoning\"`, `\"tool_call\"`, `\"tool_call_response\"` |\n| `gen_ai.output.messages` | JSON-stringified array of response messages (text + tool calls), same shape as inputs |\n\n**Thinking \u002F reasoning messages:** Models with extended thinking (Anthropic `thinking` blocks, Gemini `thought`, DeepSeek `reasoning_content`) produce internal reasoning that isn't part of the user-visible reply. Represent it as a `reasoning` part inside the assistant message — `{\"type\": \"reasoning\", \"content\": \"...\"}` — alongside the user-facing `text` part. Sentry surfaces reasoning parts separately and filters them out of the user-facing Conversations view, so do **not** fold thinking into a `text` part. When previous thinking is fed back into a multi-turn request, include the same `reasoning` parts in the assistant messages within `gen_ai.input.messages`. Record reasoning token counts via `gen_ai.usage.output_tokens.reasoning` (a subset of `gen_ai.usage.output_tokens`).\n| `gen_ai.system_instructions` | System prompt passed to the model |\n| `gen_ai.tool.definitions` | JSON-stringified list of tools available to the model |\n\n**Token usage:**\n\n| Attribute | Description |\n|-----------|-------------|\n| `gen_ai.usage.input_tokens` | Total input tokens — **includes** cached tokens |\n| `gen_ai.usage.input_tokens.cached` | Subset of input tokens served from cache |\n| `gen_ai.usage.input_tokens.cache_write` | Tokens written to cache while processing input |\n| `gen_ai.usage.output_tokens` | Total output tokens — **includes** reasoning tokens |\n| `gen_ai.usage.output_tokens.reasoning` | Subset of output tokens used for reasoning |\n| `gen_ai.usage.total_tokens` | Sum of input + output tokens |\n\n**Tool spans (`gen_ai.execute_tool`):**\n\n| Attribute | Description |\n|-----------|-------------|\n| `gen_ai.tool.name` | Tool identifier |\n| `gen_ai.tool.description` | Human-readable tool description |\n| `gen_ai.tool.call.arguments` | JSON-stringified tool arguments |\n| `gen_ai.tool.call.result` | JSON-stringified tool result |\n\n\n### Token Usage and Cost Calculation\n\nSentry uses token attributes to [calculate model costs](https:\u002F\u002Fdocs.sentry.io\u002Fai\u002Fmonitoring\u002Fagents\u002Fcosts\u002F). **Cached and reasoning tokens are subsets, not separate counts** — `gen_ai.usage.input_tokens` already includes `gen_ai.usage.input_tokens.cached`, and `gen_ai.usage.output_tokens` already includes `gen_ai.usage.output_tokens.reasoning`.\n\nSentry subtracts the cached\u002Freasoning counts from the totals to compute the uncached\u002Fnon-reasoning portion. Reporting a cached or reasoning count greater than its total produces negative costs in the dashboard.\n\nExample — 100 input tokens total, 90 served from cache:\n\n- Correct: `input_tokens = 100`, `input_tokens.cached = 90`\n- Wrong: `input_tokens = 10`, `input_tokens.cached = 90` (cached larger than total → negative cost)\n\nThe same rule applies to `gen_ai.usage.output_tokens` vs. `gen_ai.usage.output_tokens.reasoning`.\n\n## Verification\n\nAfter configuring, make an LLM call and check the Sentry Traces dashboard. AI spans appear with `gen_ai.*` operations showing model, token counts, and latency.\n\n## Conversations\n\nConversations gives a readable, chat-style view of past sessions with your AI agent. It groups spans by `gen_ai.conversation.id` — so whether a user talked across multiple traces or multiple conversations happened inside one trace, you get a timeline of every message, tool call, and response.\n\nWhen the user asks for AI monitoring setup, proactively mention this requirement if the app has multi-turn chats. Without a conversation ID, the agent-monitoring spans still work, but the Conversations view cannot group the session correctly.\n\nFind it at **Explore > Conversations** in Sentry.\n\n### Prerequisites for Conversations\n\n- Tracing enabled with `tracesSampleRate > 0`\n- Gen AI span streaming is on by default — `streamGenAiSpans` defaults to `true` since JS SDK 10.61.0 and `stream_gen_ai_spans` defaults to `True` since Python SDK 2.64.0. This sends AI spans as standalone items, so spans with large inputs\u002Foutputs don't hit transaction payload size limits and get dropped. (The options are available since JS 10.53.0 \u002F Python 2.60.0 if you need to set them explicitly on older SDKs.)\n- **Input and output capture enabled** — Conversations reconstructs the chat from `gen_ai.input.messages` and `gen_ai.output.messages` attributes. In JS this is on by default (via `dataCollection`); in Python, set `send_default_pii=True`; in Laravel, set `SENTRY_SEND_DEFAULT_PII=true`. Without it, conversations appear empty.\n\n### Setting a Conversation ID\n\nSome integrations (OpenAI Agents SDK for Python, OpenAI SDK for Node, Laravel AI agents using `Conversational` + `RemembersConversations`) infer the conversation ID automatically. For all others, set it manually.\n\nUse a short, opaque identifier — alphanumeric characters with dashes or underscores only. Never use a URL, email address, or other free-form text as the conversation ID: Sentry uses it as a URL path segment, and a value containing a slash breaks Conversations for that session.\n\nGood examples:\n- A UUID: `48e35936-82ab-4f1a-beaf-b2fa4273ac5e`\n- A prefixed ID: `conv_5j66UpCpwteGg4YSxUnt7lPYU`, `asst_abc12345`, `sess_987654`\n\n#### JavaScript\n\n```javascript\nimport * as Sentry from \"@sentry\u002Fnode\"; \u002F\u002F or @sentry\u002Fnextjs, @sentry\u002Fnestjs, etc.\n\n\u002F\u002F Set at the start of a conversation\nSentry.setConversationId(\"conv_abc123\");\n\n\u002F\u002F All subsequent AI calls carry gen_ai.conversation.id: \"conv_abc123\"\nawait openai.chat.completions.create({\n  model: \"gpt-5.5\",\n  messages: [{ role: \"user\", content: \"Hello\" }],\n});\n```\n\n#### Python\n\n```python\nimport sentry_sdk.ai\n\n# Set at the start of a conversation\nsentry_sdk.ai.set_conversation_id(\"conv_abc123\")\n\n# All subsequent AI calls carry gen_ai.conversation.id = \"conv_abc123\"\n```\n\nSome integrations infer the conversation ID automatically. For example, the Python OpenAI integration picks it up when you use the `conversation` parameter:\n\n```python\nimport openai\nimport sentry_sdk\n\nsentry_sdk.init(...)\n\nconversation = openai.conversations.create()\nresponse = openai.responses.create(\n    model=\"gpt-5.4\",\n    input=[{\"role\": \"user\", \"content\": \"What are the 5 Ds of dodgeball?\"}],\n    conversation=conversation.id  # automatically sets gen_ai.conversation.id\n)\n```\n\n### User Attribution\n\nThe Conversations view shows a **User** column. To populate it, call `setUser` \u002F `set_user` once per request or session, before any AI calls:\n\n#### JavaScript\n\n```javascript\nimport * as Sentry from \"@sentry\u002Fnode\"; \u002F\u002F or @sentry\u002Fnextjs, @sentry\u002Fnestjs, etc.\n\nSentry.setUser({ id: \"user_123\", email: \"jane@example.com\", username: \"jane\" });\n```\n\n#### Python\n\n```python\nimport sentry_sdk\n\nsentry_sdk.set_user({\"id\": \"user_123\", \"email\": \"jane@example.com\", \"username\": \"jane\"})\n```\n\nAny of `id`, `email`, or `username` is sufficient — Conversations will display whichever fields are present.\n\n### Conversations vs Traces\n\nThese are independent concepts:\n- A single conversation can span **multiple traces** (e.g., user refreshes the page mid-conversation — new trace, same conversation ID)\n- A single trace can contain spans from **different conversations** (e.g., user starts a new chat without refreshing)\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| AI spans not appearing | Verify `tracesSampleRate > 0`, check SDK version |\n| Token counts missing | Some providers don't return tokens for streaming |\n| Negative or wrong costs in dashboard | Cached\u002Freasoning tokens are subsets of totals — see Token Usage and Cost Calculation |\n| Prompts not captured | In JS, genAI capture is on by default — ensure you haven't set `dataCollection: { genAI: { inputs: false } }`, or pass `recordInputs: true` explicitly. In Python, set `send_default_pii=True`; in Laravel, set `SENTRY_SEND_DEFAULT_PII=true`. Use `include_prompts` only for explicit Python overrides |\n| Vercel AI not working | Add `experimental_telemetry` to each call |\n| Laravel AI spans not appearing | Verify `sentry\u002Fsentry-laravel >=4.27.0`, `laravel\u002Fai` is installed, and `SENTRY_TRACES_SAMPLE_RATE > 0` |\n| Conversations view empty | Ensure Gen AI span streaming is enabled (default since JS SDK 10.61.0 \u002F Python SDK 2.64.0), genAI input\u002Foutput capture enabled (on by default in JS via `dataCollection`; `send_default_pii=True` in Python; `SENTRY_SEND_DEFAULT_PII=true` in Laravel), and a conversation ID is set |\n| User column shows \"Unknown\" | Call `Sentry.setUser()` (JS) or `sentry_sdk.set_user()` (Python) once per request or session |\n","> [All Skills](..\u002F..\u002FSKILL_TREE.md) > [Feature Setup](..\u002Fsentry-feature-setup\u002FSKILL.md) > AI Monitoring\n\n# Setup Sentry AI Agent Monitoring\n\nConfigure Sentry to track LLM calls, agent executions, tool usage, and token consumption.\n\n## Invoke This Skill When\n\n- User asks to \"monitor AI\u002FLLM calls\" or \"track OpenAI\u002FAnthropic usage\"\n- User wants \"AI observability\" or \"agent monitoring\"\n- User asks about token usage, model latency, or AI costs\n\n**Important:** The SDK versions, API names, and code samples below are examples. Always verify against [docs.sentry.io](https:\u002F\u002Fdocs.sentry.io) before implementing, as APIs and minimum versions may have changed.\n\n## Prerequisites\n\nAI monitoring requires **tracing enabled** (`tracesSampleRate > 0`).\n\nIf the app has multi-turn chats, set a conversation ID by default anywhere it makes sense to identify a chat session. Sentry uses `gen_ai.conversation.id` to group related AI spans into Conversations. Some integrations infer it automatically, but many setups need to set it explicitly.\n\n## Data Capture Warning\n\n**Prompt and output recording captures user content that is likely PII.** In JavaScript, genAI input\u002Foutput capture is **on by default** (governed by `dataCollection.genAI`); in Python it is enabled via `send_default_pii=True`; in Laravel it is enabled via `SENTRY_SEND_DEFAULT_PII=true`. Before relying on this capture (or per-integration overrides — `recordInputs`\u002F`recordOutputs` in JS, `include_prompts` in Python), confirm:\n\n- The application's privacy policy permits capturing user prompts and model responses\n- Captured data complies with applicable regulations (GDPR, CCPA, etc.)\n- Sentry data retention settings are appropriate for the sensitivity of the data\n\n**Ask the user** whether they want prompt\u002Foutput capture enabled. Do not enable prompt\u002Foutput capture without explicit confirmation. Use `tracesSampleRate: 1.0` only in development; in production, use a lower value or a `tracesSampler` function.\n\n## Detection First\n\n**Always detect installed AI SDKs before configuring:**\n\n```bash\n# JavaScript\ngrep -E '\"(openai|@anthropic-ai\u002Fsdk|ai|@langchain|@google\u002Fgenai)\"' package.json\n\n# Python\ngrep -E '(openai|anthropic|langchain|huggingface)' requirements.txt pyproject.toml 2>\u002Fdev\u002Fnull\n\n# PHP \u002F Laravel\ngrep -E '\"(laravel\u002Fai|openai-php|openai\u002F|anthropic|llm)' composer.json 2>\u002Fdev\u002Fnull\nls artisan 2>\u002Fdev\u002Fnull && echo \"Laravel detected\"\n```\n\n## Sampling Check\n\nAfter detecting AI SDKs, check the current sampling configuration:\n\n```bash\n# JavaScript\ngrep -E 'tracesSampleRate|tracesSampler' sentry.*.config.* instrument.* src\u002Finstrument.* app\u002Finstrument.* 2>\u002Fdev\u002Fnull\n\n# Python\ngrep -E 'traces_sample_rate|traces_sampler' *.py **\u002F*.py 2>\u002Fdev\u002Fnull\n\n# PHP \u002F Laravel\ngrep -E 'SENTRY_TRACES_SAMPLE_RATE|traces_sample_rate|traces_sampler' .env config\u002Fsentry.php 2>\u002Fdev\u002Fnull\n```\n\n**If `tracesSampleRate` \u002F `traces_sample_rate` is below 1.0 AND no `tracesSampler` \u002F `traces_sampler` is configured:**\n\nAsk the user:\n\n> \"Your current sample rate is {rate}. Agent runs are sampled as complete span trees — if the root span is dropped, all child gen_ai spans are lost. For full AI visibility, gen_ai-related transactions should be sampled at 100%. Would you like me to set up a `tracesSampler` that keeps AI traces at 100% while sampling other traffic at your current rate?\"\n\nIf user confirms, read `${SKILL_ROOT}\u002Freferences\u002Fsampling.md` for implementation patterns.\n\n## Supported SDKs\n\n### JavaScript\n\n| Package | Integration | Min Sentry SDK | Auto? |\n|---------|-------------|----------------|-------|\n| `openai` | `openAIIntegration()` | 10.53.0 | Yes |\n| `@anthropic-ai\u002Fsdk` | `anthropicAIIntegration()` | 10.53.0 | Yes |\n| `ai` (Vercel) | `vercelAIIntegration()` | 10.53.0 | Yes* |\n| `@langchain\u002F*` | `langChainIntegration()` | 10.53.0 | Yes |\n| `@langchain\u002Flanggraph` | `langGraphIntegration()` | 10.53.0 | Yes |\n| `@google\u002Fgenai` | `googleGenAIIntegration()` | 10.53.0 | Yes |\n\n*Vercel AI: 10.53.0+ required. Requires `experimental_telemetry` per-call.\n\n### Python\n\nIntegrations auto-enable when the AI package is installed — no explicit registration needed:\n\n| Package | Auto? | Notes |\n|---------|-------|-------|\n| `openai` | Yes | Includes OpenAI Agents SDK |\n| `anthropic` | Yes | |\n| `langchain` \u002F `langgraph` | Yes | |\n| `huggingface_hub` | Yes | |\n| `google-genai` | Yes | |\n| `pydantic-ai` | Yes | |\n| `litellm` | **No** | Requires explicit integration |\n| `mcp` (Model Context Protocol) | Yes | |\n\n### PHP \u002F Laravel\n\n| Package | Integration | Min Sentry SDK | Auto? |\n|---------|-------------|----------------|-------|\n| `laravel\u002Fai` | Laravel AI instrumentation in `sentry\u002Fsentry-laravel` | 4.27.0 | Yes |\n\nLaravel AI support requires Laravel 12.x or later, `sentry\u002Fsentry-laravel` 4.27.0 or later, and tracing enabled.\n\n## JavaScript Configuration\n\n### Node.js — auto-enabled integrations\n\nJust ensure tracing is enabled. Integrations auto-enable when the AI package is installed:\n\n```javascript\nSentry.init({\n  dsn: \"YOUR_DSN\",\n  tracesSampleRate: 1.0, \u002F\u002F Lower in production (e.g., 0.1)\n  \u002F\u002F OpenAI, Anthropic, Google GenAI, LangChain integrations auto-enable in Node.js\n});\n```\n\nTo customize (e.g., enable prompt capture after user confirmation — see Data Capture Warning):\n\n```javascript\nSentry.init({\n  dsn: \"YOUR_DSN\",\n  tracesSampleRate: 1.0,\n  dataCollection: {\n    \u002F\u002F To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:\n    \u002F\u002F https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fconfiguration\u002Foptions\u002F#dataCollection\n    \u002F\u002F userInfo: false,\n    \u002F\u002F httpBodies: [],\n  },\n  integrations: [\n    Sentry.openAIIntegration({\n      \u002F\u002F recordInputs\u002FrecordOutputs default to true (governed by dataCollection.genAI)\n    }),\n  ],\n});\n```\n\n### Cloudflare Workers (no runtime patching)\n\nThe Workers runtime (`workerd`) does not support monkey-patching, so Node.js-style auto-instrumentation does not apply. Workers AI (`env.AI`) is auto-instrumented by `withSentry` (v10.67.0+); `openai`, `@anthropic-ai\u002Fsdk`, `@google\u002Fgenai`, and `ai` need either the build-time Sentry Cloudflare Vite plugin (v10.68.0+, experimental) or manual client wrapping; LangChain\u002FLangGraph are manual-only. Read `${SKILL_ROOT}\u002F..\u002F..\u002Freferences\u002Fsdks\u002Fcloudflare\u002Fai-monitoring.md` for the full setup.\n\n### Browser \u002F Next.js OpenAI (manual wrapping required)\n\nIn browser-side code or Next.js meta-framework apps, auto-instrumentation is not available. Wrap the client manually:\n\n```javascript\nimport OpenAI from \"openai\";\nimport * as Sentry from \"@sentry\u002Fnextjs\"; \u002F\u002F or @sentry\u002Freact, @sentry\u002Fbrowser\n\nconst openai = Sentry.instrumentOpenAiClient(new OpenAI());\n\u002F\u002F Use 'openai' client as normal\n```\n\n### LangChain \u002F LangGraph (auto-enabled)\n\n```javascript\nSentry.init({\n  dsn: \"YOUR_DSN\",\n  tracesSampleRate: 1.0,\n  dataCollection: {\n    \u002F\u002F To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:\n    \u002F\u002F https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fconfiguration\u002Foptions\u002F#dataCollection\n    \u002F\u002F userInfo: false,\n    \u002F\u002F httpBodies: [],\n  },\n  integrations: [\n    Sentry.langChainIntegration(),\n    Sentry.langGraphIntegration(),\n  ],\n});\n```\n\n### Vercel AI SDK\n\nAdd to `sentry.edge.config.ts` for Edge runtime:\n```javascript\nSentry.init({\n  dsn: \"YOUR_DSN\",\n  tracesSampleRate: 1.0,\n  dataCollection: {\n    \u002F\u002F To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:\n    \u002F\u002F https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fconfiguration\u002Foptions\u002F#dataCollection\n    \u002F\u002F userInfo: false,\n    \u002F\u002F httpBodies: [],\n  },\n  integrations: [Sentry.vercelAIIntegration()],\n});\n```\n\nEnable telemetry per-call:\n```javascript\nawait generateText({\n  model: openai(\"gpt-4o\"),\n  prompt: \"Hello\",\n  experimental_telemetry: {\n    isEnabled: true,\n    recordInputs: true,\n    recordOutputs: true,\n  },\n});\n```\n\n## Python Configuration\n\nIntegrations auto-enable — just init with tracing. Only add explicit imports to customize options:\n\n```python\nimport sentry_sdk\n\nsentry_sdk.init(\n    dsn=\"YOUR_DSN\",\n    traces_sample_rate=1.0,  # Lower in production (e.g., 0.1)\n    send_default_pii=True,\n    # Integrations auto-enable when the AI package is installed.\n    # Only specify explicitly to customize (e.g., include_prompts):\n    # integrations=[OpenAIIntegration(include_prompts=True)],\n)\n```\n\n## PHP \u002F Laravel AI Configuration\n\nLaravel AI instrumentation auto-enables when both `sentry\u002Fsentry-laravel` and `laravel\u002Fai` are installed and tracing is active.\n\n```bash\ncomposer require sentry\u002Fsentry-laravel \"^4.27.0\"\ncomposer require laravel\u002Fai\nphp artisan vendor:publish --provider=\"Laravel\\Ai\\AiServiceProvider\"\nphp artisan migrate\n```\n\nEnable tracing in `.env`:\n\n```ini\nSENTRY_TRACES_SAMPLE_RATE=1.0\n```\n\nTo include LLM prompts, tool arguments, and responses after explicit user confirmation, enable PII capture:\n\n```ini\nSENTRY_SEND_DEFAULT_PII=true\n```\n\nSentry treats LLM and tool inputs\u002Foutputs as PII and does not capture them by default. Do not enable `SENTRY_SEND_DEFAULT_PII=true` without confirming the Data Capture Warning above.\n\nThe Laravel integration captures these span types automatically:\n\n| Span op | Purpose |\n|---------|---------|\n| `gen_ai.invoke_agent` | Agent prompt lifecycle |\n| `gen_ai.chat` | AI provider chat requests |\n| `gen_ai.execute_tool` | Laravel AI tool executions |\n| `gen_ai.embeddings` | Embedding generation |\n\nFor detailed Laravel setup, verification, Conversations behavior, and feature flags, read `${SKILL_ROOT}\u002F..\u002F..\u002Freferences\u002Fsdks\u002Fphp\u002Fai-monitoring.md`.\n\n## Manual Instrumentation\n\nUse when no supported SDK is detected. Follow the canonical [Sentry Conventions for `gen_ai.*` attributes](https:\u002F\u002Fgetsentry.github.io\u002Fsentry-conventions\u002Fattributes\u002Fgen_ai\u002F) — the [JS docs](https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fguides\u002Fconnect\u002Fai-agent-monitoring\u002F#manual-instrumentation) may lag behind; do not set attributes marked deprecated in the conventions.\n\n### Span Types\n\n| `op` | Span `name` pattern | Purpose |\n|------|---------------------|---------|\n| `gen_ai.{operation}` (e.g. `gen_ai.chat`, `gen_ai.request`) | `{operation} {model}` (e.g. `chat gpt-4o`) | Individual LLM call |\n| `gen_ai.invoke_agent` | `invoke_agent {agent_name}` | Agent execution lifecycle |\n| `gen_ai.execute_tool` | `execute_tool {tool_name}` | Tool\u002Ffunction call |\n| `gen_ai.handoff` | `handoff from {source} to {target}` | Agent-to-agent transition |\n\nFor LLM-call spans, the `op` follows the pattern `gen_ai.{gen_ai.operation.name}` — use `gen_ai.chat`, `gen_ai.embeddings`, `gen_ai.generate_content`, or `gen_ai.text_completion` where the operation is known. Span attributes only accept primitives; arrays\u002Fobjects must be JSON-stringified.\n\n### Example (JavaScript)\n\n```javascript\nconst inputMessages = [\n  { role: \"user\", parts: [{ type: \"text\", content: \"Tell me a joke\" }] },\n];\n\nawait Sentry.startSpan({\n  op: \"gen_ai.chat\",\n  name: \"chat gpt-4o\",\n  attributes: {\n    \"gen_ai.request.model\": \"gpt-4o\",\n    \"gen_ai.operation.name\": \"chat\",\n    \"gen_ai.input.messages\": JSON.stringify(inputMessages),\n  },\n}, async (span) => {\n  const result = await llmClient.complete(inputMessages);\n\n  const outputMessages = [\n    {\n      role: \"assistant\",\n      parts: [\n        \u002F\u002F Thinking\u002Freasoning content goes in a `reasoning` part, NOT a `text` part.\n        \u002F\u002F Sentry surfaces it separately and filters it out of the Conversations view.\n        { type: \"reasoning\", content: result.reasoning },\n        { type: \"text\", content: result.text },\n      ],\n      finish_reason: result.finishReason,\n    },\n  ];\n  span.setAttribute(\"gen_ai.output.messages\", JSON.stringify(outputMessages));\n  span.setAttribute(\"gen_ai.usage.input_tokens\", result.inputTokens);\n  span.setAttribute(\"gen_ai.usage.output_tokens\", result.outputTokens);\n  return result;\n});\n```\n\n### Key Attributes\n\n**Common (all AI spans):**\n\n| Attribute | Required | Description |\n|-----------|----------|-------------|\n| `gen_ai.request.model` | Yes | Model identifier (e.g., `gpt-4o`, `claude-sonnet-4-6`) |\n| `gen_ai.operation.name` | No | Operation label (`chat`, `embeddings`, `invoke_agent`, `execute_tool`, `handoff`, etc.) |\n| `gen_ai.agent.name` | No | Agent name (set on agent and tool spans) |\n\n**Model config (LLM call spans):**\n\n| Attribute | Description |\n|-----------|-------------|\n| `gen_ai.request.reasoning_effort` | Reasoning effort level for reasoning models (e.g., `low`, `medium`, `high`). Supported values vary by provider. |\n\n**Request \u002F response content (PII — enable only after confirming; see Data Capture Warning above):**\n\n| Attribute | Description |\n|-----------|-------------|\n| `gen_ai.input.messages` | JSON-stringified array of input messages. Each item uses `{role, parts}` where `parts` is `[{type, content}]`; `role` is `\"user\"`, `\"assistant\"`, `\"tool\"`, or `\"system\"`. Common part `type`s: `\"text\"`, `\"reasoning\"`, `\"tool_call\"`, `\"tool_call_response\"` |\n| `gen_ai.output.messages` | JSON-stringified array of response messages (text + tool calls), same shape as inputs |\n\n**Thinking \u002F reasoning messages:** Models with extended thinking (Anthropic `thinking` blocks, Gemini `thought`, DeepSeek `reasoning_content`) produce internal reasoning that isn't part of the user-visible reply. Represent it as a `reasoning` part inside the assistant message — `{\"type\": \"reasoning\", \"content\": \"...\"}` — alongside the user-facing `text` part. Sentry surfaces reasoning parts separately and filters them out of the user-facing Conversations view, so do **not** fold thinking into a `text` part. When previous thinking is fed back into a multi-turn request, include the same `reasoning` parts in the assistant messages within `gen_ai.input.messages`. Record reasoning token counts via `gen_ai.usage.output_tokens.reasoning` (a subset of `gen_ai.usage.output_tokens`).\n| `gen_ai.system_instructions` | System prompt passed to the model |\n| `gen_ai.tool.definitions` | JSON-stringified list of tools available to the model |\n\n**Token usage:**\n\n| Attribute | Description |\n|-----------|-------------|\n| `gen_ai.usage.input_tokens` | Total input tokens — **includes** cached tokens |\n| `gen_ai.usage.input_tokens.cached` | Subset of input tokens served from cache |\n| `gen_ai.usage.input_tokens.cache_write` | Tokens written to cache while processing input |\n| `gen_ai.usage.output_tokens` | Total output tokens — **includes** reasoning tokens |\n| `gen_ai.usage.output_tokens.reasoning` | Subset of output tokens used for reasoning |\n| `gen_ai.usage.total_tokens` | Sum of input + output tokens |\n\n**Tool spans (`gen_ai.execute_tool`):**\n\n| Attribute | Description |\n|-----------|-------------|\n| `gen_ai.tool.name` | Tool identifier |\n| `gen_ai.tool.description` | Human-readable tool description |\n| `gen_ai.tool.call.arguments` | JSON-stringified tool arguments |\n| `gen_ai.tool.call.result` | JSON-stringified tool result |\n\n\n### Token Usage and Cost Calculation\n\nSentry uses token attributes to [calculate model costs](https:\u002F\u002Fdocs.sentry.io\u002Fai\u002Fmonitoring\u002Fagents\u002Fcosts\u002F). **Cached and reasoning tokens are subsets, not separate counts** — `gen_ai.usage.input_tokens` already includes `gen_ai.usage.input_tokens.cached`, and `gen_ai.usage.output_tokens` already includes `gen_ai.usage.output_tokens.reasoning`.\n\nSentry subtracts the cached\u002Freasoning counts from the totals to compute the uncached\u002Fnon-reasoning portion. Reporting a cached or reasoning count greater than its total produces negative costs in the dashboard.\n\nExample — 100 input tokens total, 90 served from cache:\n\n- Correct: `input_tokens = 100`, `input_tokens.cached = 90`\n- Wrong: `input_tokens = 10`, `input_tokens.cached = 90` (cached larger than total → negative cost)\n\nThe same rule applies to `gen_ai.usage.output_tokens` vs. `gen_ai.usage.output_tokens.reasoning`.\n\n## Verification\n\nAfter configuring, make an LLM call and check the Sentry Traces dashboard. AI spans appear with `gen_ai.*` operations showing model, token counts, and latency.\n\n## Conversations\n\nConversations gives a readable, chat-style view of past sessions with your AI agent. It groups spans by `gen_ai.conversation.id` — so whether a user talked across multiple traces or multiple conversations happened inside one trace, you get a timeline of every message, tool call, and response.\n\nWhen the user asks for AI monitoring setup, proactively mention this requirement if the app has multi-turn chats. Without a conversation ID, the agent-monitoring spans still work, but the Conversations view cannot group the session correctly.\n\nFind it at **Explore > Conversations** in Sentry.\n\n### Prerequisites for Conversations\n\n- Tracing enabled with `tracesSampleRate > 0`\n- Gen AI span streaming is on by default — `streamGenAiSpans` defaults to `true` since JS SDK 10.61.0 and `stream_gen_ai_spans` defaults to `True` since Python SDK 2.64.0. This sends AI spans as standalone items, so spans with large inputs\u002Foutputs don't hit transaction payload size limits and get dropped. (The options are available since JS 10.53.0 \u002F Python 2.60.0 if you need to set them explicitly on older SDKs.)\n- **Input and output capture enabled** — Conversations reconstructs the chat from `gen_ai.input.messages` and `gen_ai.output.messages` attributes. In JS this is on by default (via `dataCollection`); in Python, set `send_default_pii=True`; in Laravel, set `SENTRY_SEND_DEFAULT_PII=true`. Without it, conversations appear empty.\n\n### Setting a Conversation ID\n\nSome integrations (OpenAI Agents SDK for Python, OpenAI SDK for Node, Laravel AI agents using `Conversational` + `RemembersConversations`) infer the conversation ID automatically. For all others, set it manually.\n\nUse a short, opaque identifier — alphanumeric characters with dashes or underscores only. Never use a URL, email address, or other free-form text as the conversation ID: Sentry uses it as a URL path segment, and a value containing a slash breaks Conversations for that session.\n\nGood examples:\n- A UUID: `48e35936-82ab-4f1a-beaf-b2fa4273ac5e`\n- A prefixed ID: `conv_5j66UpCpwteGg4YSxUnt7lPYU`, `asst_abc12345`, `sess_987654`\n\n#### JavaScript\n\n```javascript\nimport * as Sentry from \"@sentry\u002Fnode\"; \u002F\u002F or @sentry\u002Fnextjs, @sentry\u002Fnestjs, etc.\n\n\u002F\u002F Set at the start of a conversation\nSentry.setConversationId(\"conv_abc123\");\n\n\u002F\u002F All subsequent AI calls carry gen_ai.conversation.id: \"conv_abc123\"\nawait openai.chat.completions.create({\n  model: \"gpt-5.5\",\n  messages: [{ role: \"user\", content: \"Hello\" }],\n});\n```\n\n#### Python\n\n```python\nimport sentry_sdk.ai\n\n# Set at the start of a conversation\nsentry_sdk.ai.set_conversation_id(\"conv_abc123\")\n\n# All subsequent AI calls carry gen_ai.conversation.id = \"conv_abc123\"\n```\n\nSome integrations infer the conversation ID automatically. For example, the Python OpenAI integration picks it up when you use the `conversation` parameter:\n\n```python\nimport openai\nimport sentry_sdk\n\nsentry_sdk.init(...)\n\nconversation = openai.conversations.create()\nresponse = openai.responses.create(\n    model=\"gpt-5.4\",\n    input=[{\"role\": \"user\", \"content\": \"What are the 5 Ds of dodgeball?\"}],\n    conversation=conversation.id  # automatically sets gen_ai.conversation.id\n)\n```\n\n### User Attribution\n\nThe Conversations view shows a **User** column. To populate it, call `setUser` \u002F `set_user` once per request or session, before any AI calls:\n\n#### JavaScript\n\n```javascript\nimport * as Sentry from \"@sentry\u002Fnode\"; \u002F\u002F or @sentry\u002Fnextjs, @sentry\u002Fnestjs, etc.\n\nSentry.setUser({ id: \"user_123\", email: \"jane@example.com\", username: \"jane\" });\n```\n\n#### Python\n\n```python\nimport sentry_sdk\n\nsentry_sdk.set_user({\"id\": \"user_123\", \"email\": \"jane@example.com\", \"username\": \"jane\"})\n```\n\nAny of `id`, `email`, or `username` is sufficient — Conversations will display whichever fields are present.\n\n### Conversations vs Traces\n\nThese are independent concepts:\n- A single conversation can span **multiple traces** (e.g., user refreshes the page mid-conversation — new trace, same conversation ID)\n- A single trace can contain spans from **different conversations** (e.g., user starts a new chat without refreshing)\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| AI spans not appearing | Verify `tracesSampleRate > 0`, check SDK version |\n| Token counts missing | Some providers don't return tokens for streaming |\n| Negative or wrong costs in dashboard | Cached\u002Freasoning tokens are subsets of totals — see Token Usage and Cost Calculation |\n| Prompts not captured | In JS, genAI capture is on by default — ensure you haven't set `dataCollection: { genAI: { inputs: false } }`, or pass `recordInputs: true` explicitly. In Python, set `send_default_pii=True`; in Laravel, set `SENTRY_SEND_DEFAULT_PII=true`. Use `include_prompts` only for explicit Python overrides |\n| Vercel AI not working | Add `experimental_telemetry` to each call |\n| Laravel AI spans not appearing | Verify `sentry\u002Fsentry-laravel >=4.27.0`, `laravel\u002Fai` is installed, and `SENTRY_TRACES_SAMPLE_RATE > 0` |\n| Conversations view empty | Ensure Gen AI span streaming is enabled (default since JS SDK 10.61.0 \u002F Python SDK 2.64.0), genAI input\u002Foutput capture enabled (on by default in JS via `dataCollection`; `send_default_pii=True` in Python; `SENTRY_SEND_DEFAULT_PII=true` in Laravel), and a conversation ID is set |\n| User column shows \"Unknown\" | Call `Sentry.setUser()` (JS) or `sentry_sdk.set_user()` (Python) once per request or session |\n",{"name":5,"parent":24,"license":15,"category":25,"description":7,"disable-model-invocation":26},"sentry-feature-setup","feature-setup",true,"main","b1e4ffadb4f933bbbcaa03a83f8b9929171ac28b",".agents\u002Fskills\u002Fsentry-setup-ai-monitoring",0,"https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR","https:\u002F\u002Fgithub.com\u002FHazek-dc","2026-10-22 08:36:44",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":26},[36,39,42],{"tool":37,"command":38},"npx","npx skills add Hazek-dc\u002FPresensiGuru_FaceNet_EMAR --skill sentry-setup-ai-monitoring",{"tool":40,"command":41},"bunx","bunx skills add Hazek-dc\u002FPresensiGuru_FaceNet_EMAR --skill sentry-setup-ai-monitoring",{"tool":43,"command":44},"pnpm","pnpm dlx skills add Hazek-dc\u002FPresensiGuru_FaceNet_EMAR --skill sentry-setup-ai-monitoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fsentry-setup-ai-monitoring\u002FSKILL.md",[47],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"references\u002Fsampling.md","REFERENCE","参考文档",3040,"https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fsentry-setup-ai-monitoring\u002Freferences\u002Fsampling.md",[54,62,69,76,83,90],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":58,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7DS6GGYRZAYD33PFPS8Z2T3","testing-best-practices","Laravel test design and review. Use when selecting coverage, naming or structuring tests, choosing assertions or test data, isolating dependencies, testing HTTP or security boundaries, improving suite performance, or reviewing test value. Use framework guidance or search-docs for Pest and PHPUnit syntax.","MIT","https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002Fattendance-web\u002F.claude\u002Fskills\u002Ftesting-best-practices\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":58,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7DS6BC3AW7HTPRHE2TTVKWM","tailwindcss-development","Always invoke when the user's message includes 'tailwind' in any form. Also invoke for: building responsive grid layouts (multi-column card grids, product grids), flex\u002Fgrid page structures (dashboards with sidebars, fixed topbars, mobile-toggle navs), styling UI components (cards, tables, navbars, pricing sections, forms, inputs, badges), adding dark mode variants, fixing spacing or typography, and Tailwind v3\u002Fv4 work. The core use case: writing or fixing Tailwind utility classes in HTML templates (Blade, JSX, Vue). Skip for backend PHP logic, database queries, API routes, JavaScript with no HTML\u002FCSS component, CSS file audits, build tool configuration, and vanilla CSS.","https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002Fattendance-web\u002F.claude\u002Fskills\u002Ftailwindcss-development\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":58,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7DS66GE6B11MYJDVC74HXM4","laravel-best-practices","Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance issues, caching strategies, authorization and security patterns, validation, error handling, queue and job configuration, route definitions, and architectural decisions. Also use for Laravel code reviews and refactoring existing Laravel code to follow best practices. Covers any task involving Laravel backend PHP code patterns.","https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002Fattendance-web\u002F.claude\u002Fskills\u002Flaravel-best-practices\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":58,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7DS5ZW717DMS6P1E90AQCKV","infer-conventions","Use this skill to analyze how a Laravel application is actually written and record its conventions as shared rules. Trigger when the user wants to detect, infer, document, or standardize project conventions or coding style, set up or grow `.ai\u002Frules`, resolve mixed or conflicting patterns (e.g. \"are we using Form Requests or inline validation?\"), or onboard agents and teammates to \"how we do things here\". Covers: a systematic sweep of ~49 Laravel convention dimensions (validation, models, architecture, testing, frontend, database, console), open-ended house-pattern discovery, conflict reporting, and recording rules scoped to the right paths via the Boost `record-rule` MCP tool. Only run this skill when the user explicitly asks for it; never start a sweep as part of another task. Do not use for one-off code review, enforcing formatting a linter already handles, or editing `.ai\u002Frules` files by hand.","https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002Fattendance-web\u002F.claude\u002Fskills\u002Finfer-conventions\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":58,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7DS5W12RGCVJTFQJ1N0GB8E","inertia-react-development","Develops Inertia.js v2 React client-side applications. Activates when creating React pages, forms, or navigation; using \u003CLink>, \u003CForm>, useForm, or router; working with deferred props, prefetching, or polling; or when user mentions React with Inertia, React pages, React forms, or React navigation.","https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002Fattendance-web\u002F.claude\u002Fskills\u002Finertia-react-development\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":58,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7DS5PVDPMPCWSK2RXPDC9BB","deploying-to-cloud","Deploys and manages Laravel applications on Laravel Cloud using the `cloud` CLI. Use when the user wants to deploy an app, ship to Cloud, create or manage applications, environments, databases, caches, object storage, queues, domains, instances, background processes, secrets, compute, scheduled tasks, or Laravel Cloud infrastructure; or check billing, usage, or spend. Triggers on deployment, shipping, Cloud management, environment setup, database provisioning, billing or usage queries, the `cloud` CLI, and Laravel Cloud deployment troubleshooting.","https:\u002F\u002Fgithub.com\u002FHazek-dc\u002FPresensiGuru_FaceNet_EMAR\u002Fblob\u002Fmain\u002Fattendance-web\u002F.claude\u002Fskills\u002Fdeploying-to-cloud\u002FSKILL.md",[],[]]