PHPackages                             ryderasking/laravel-ai-trace - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ryderasking/laravel-ai-trace

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ryderasking/laravel-ai-trace
============================

LangSmith-style waterfall tracing for Laravel AI SDK workloads.

1.0.6(2mo ago)111↓90.9%MITPHPPHP ^8.3

Since Apr 1Pushed 2mo agoCompare

[ Source](https://github.com/RyderAsKing/laravel-ai-trace)[ Packagist](https://packagist.org/packages/ryderasking/laravel-ai-trace)[ RSS](/packages/ryderasking-laravel-ai-trace/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (2)Dependencies (22)Versions (8)Used By (0)

Laravel AI Trace
================

[](#laravel-ai-trace)

Laravel AI Trace is a tracing and debugging package for AI workflows built with Laravel AI SDK (`laravel/ai`).

It captures full `trace -> span -> event` lifecycle data with SDK-native hooks so you can inspect execution order, retries, tool calls, streaming milestones, failures, and timing with waterfall-style visibility.

[![Laravel AI Trace dashboard view](dashboard.webp)](dashboard.webp)

The dashboard provides period-based trend cards, a filterable trace explorer, and quick drill-in links for incident investigation and performance triage.

[![Laravel AI Trace trace detail view](trace.webp)](trace.webp)

Compatibility
-------------

[](#compatibility)

- Laravel: `12+` (currently tested on `12.x` and `13.x`)
- PHP: `8.3+`
- Livewire: `3.6+` (including `4.x`)
- Laravel AI SDK (`laravel/ai`): currently validated against `v0.3.2`

How It Works
------------

[](#how-it-works)

Laravel AI Trace subscribes to Laravel AI SDK lifecycle events (for example agent start/end, tool start/end, stream completion, and failover events), then:

1. Correlates each callback to a trace and active span context.
2. Persists traces, spans, and events in relational tables.
3. Deduplicates repeated callbacks inside a configurable TTL window.
4. Applies privacy mode/redaction before storing sensitive content.
5. Serves dashboard/query data through package services.

This package is SDK-native by design. It does not use HTTP fallback instrumentation.

Dashboard Stack
---------------

[](#dashboard-stack)

The dashboard is package-owned UI and uses:

- Livewire components for card rendering, polling, filters, and URL-backed state
- Blade components for layout, cards, tables, and inspector primitives
- Alpine.js + Chart.js for chart interactions and dataset updates
- Tailwind CSS for styling (with compiled package assets)

The design is inspired by Laravel Pulse, but the dashboard does not require a runtime dependency on `laravel/pulse`.

Installation
------------

[](#installation)

1. Install Laravel AI SDK (if not already installed):

```
composer require laravel/ai
```

2. Install Laravel AI Trace:

```
composer require ryderasking/laravel-ai-trace
```

3. Publish package configuration and migrations:

```
php artisan vendor:publish --tag=ai-trace-config
php artisan vendor:publish --tag=ai-trace-migrations
```

4. Run migrations:

```
php artisan migrate
```

5. Optional smoke test:

```
php artisan ai-trace:smoke
```

Dashboard Authorization Setup
-----------------------------

[](#dashboard-authorization-setup)

Dashboard authorization is controlled by the host application via gate.

By default, Laravel AI Trace checks gate `viewAiTrace` (`ai-trace.dashboard.authorization_gate`). Define it in your `AppServiceProvider`:

```
