SentryMartin Linzmayer4 min readintermediate
Building Sentry's Laravel AI Integration
Summary
Sentry added zero‑config Agent Tracing for Laravel AI agents. The integration hooks into Laravel AI events and HTTP request events to create Chat spans for each LLM call, matching requests by provider URL prefix. Updating to sentry‑laravel 4.27 automatically instruments agents without any user code changes.
- Laravel AI emits `PromptingAgent`, `AgentPrompted`, `InvokingTool`, and `ToolInvoked` events, but not per‑LLM‑call events; Sentry works around this by correlating HTTP requests to LLM providers.
- A generic `flexGet` helper was generated by Claude but is unnecessary because Laravel event payloads have well‑defined shapes.
- Zero‑config tracing: simply upgrade to sentry‑laravel 4.27; no additional registration or code changes are required.
- Agent Tracing UI in Sentry Explore shows conversations, durations, costs, tool calls, and lets you inspect tool input/output.
Provides a practical pattern for instrumenting AI agents in PHP ecosystems where runtime patching is limited, and demonstrates how to get fine‑grained observability (per‑LLM‑call spans) without developer friction.
6/10




