Feature/add ai collector - #2061
Merged
Merged
Conversation
Adds an AiCollector (and provider) in the style of PennantCollector, showing each laravel/ai agent invocation as a single entry with the prompt, instructions, model/provider, tool calls and token usage. The provider only registers when Laravel\Ai\AiManager exists, so apps without laravel/ai are unaffected. laravel/ai is added to require-dev only. Tool calls are buffered per invocationId and folded into the entry recorded on AgentPrompted. Prompt/response/tool bodies are truncated at 20k chars; the 'ai.values' option disables body collection for sensitive prompts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Covers provider registration (guarded on laravel/ai), folding buffered tool calls into the matching invocation, per-invocation buffer consumption, the 'values' toggle omitting prompt/response/tool bodies, and body truncation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
build/report.junit.xml is generated by PHPUnit (phpunit.xml.dist logging) and should not be committed. Remove it from tracking and ignore it, consistent with the existing /build/phpstan and /build/docs entries. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Removed step to remove incompatible PHP dependencies for version 8.2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
AiCollectorforlaravel/aiagent runsAdds an
AiCollector(and provider) that shows eachlaravel/aiagent invocation in the debug bar as a single entry: prompt, instructions, model/provider, tool calls and token usage. Built in the same style as the existingPennantCollector.How it works
ToolInvokedfires during a run andAgentPromptedat the end; tool calls are buffered byinvocationIdand folded into the entry recorded onAgentPrompted(AgentStreamedis handled identically).Laravel\Ai\AiManagerexists — apps withoutlaravel/aiare unaffected, just likePennantCollectorProviderguards onFeatureManager.JsonVariableListWidget/HtmlVariableListWidget/VariableListWidget, chosen the same way asSessionCollector/RouteCollector.Configuration
Set
'values' => falsefor metadata only (agent, model, provider, usage, attachment count), handy when prompts are sensitive or large.laravel/aiis added torequire-devonly — never a hardrequire.Tests
AiCollectorTest(5 tests): provider registration, folding tool calls into the matching invocation, per-invocation buffer consumption, thevaluestoggle, and truncation.Caveat
Debugbar captures data per HTTP request, so you only see AI runs for synchronous calls (
QUEUE_CONNECTION=syncor inline); for queued jobs a Telescope watcher fits better.