Skip to content

Streaming model breaks profiler data collection #1121

@TimoBakx

Description

@TimoBakx

When using a streaming agent, and using the profiler, gathering the data for the profiler fails due to the content being a generator at $call['result'] = $result->getContent() in Symfony\AI\AiBundle\Profiler\DataCollector on line 156.

This results (in my case using a custom Symfony command with --profiler and -vvv):

In FileProfilerStorage.php line 164:
                                               
  [Exception]                                  
  Serialization of 'Generator' is not allowed  
                                               

Exception trace:
  at /vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:164
 serialize() at /vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php:164
 Symfony\Component\HttpKernel\Profiler\FileProfilerStorage->write() at /vendor/symfony/http-kernel/Profiler/Profiler.php:97
 Symfony\Component\HttpKernel\Profiler\Profiler->saveProfile() at /vendor/symfony/framework-bundle/EventListener/ConsoleProfilerListener.php:151
 Symfony\Bundle\FrameworkBundle\EventListener\ConsoleProfilerListener->profile() at /vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115
 Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke() at /vendor/symfony/event-dispatcher/EventDispatcher.php:206
 Symfony\Component\EventDispatcher\EventDispatcher->callListeners() at /vendor/symfony/event-dispatcher/EventDispatcher.php:56
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:126
 Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch() at /vendor/symfony/console/Application.php:1121
 Symfony\Component\Console\Application->doRunCommand() at /vendor/symfony/framework-bundle/Console/Application.php:123
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /vendor/symfony/console/Application.php:356
 Symfony\Component\Console\Application->doRun() at /vendor/symfony/framework-bundle/Console/Application.php:77
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /vendor/symfony/console/Application.php:195
 Symfony\Component\Console\Application->run() at /vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /vendor/autoload_runtime.php:32
 require_once() at /bin/console:17

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions