Skip to content

Conversation

@camilleislasse
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
Docs? no
Issues Fix #1121
License MIT

Summary

Fix serialization error when using streaming models with the profiler.

When using a streaming agent, the DataCollector tries to serialize a Generator object which PHP doesn't allow. This happens when the stream hasn't been consumed before the profiler collects data.

Error:

Serialization of 'Generator' is not allowed

Fix:
Return null instead of the raw Generator when the stream hasn't been consumed. The actual content is only available after the stream is iterated, so there's nothing to display anyway.

  • If stream is consumed → profiler shows the accumulated content (via resultCache)
  • If stream is not consumed → profiler shows null instead of crashing

@carsonbot carsonbot added Status: Needs Review Bug Something isn't working labels Dec 17, 2025
@carsonbot carsonbot changed the title [AiBundle] Fix profiler serialization error with unconsumed streams [AI Bundle] Fix profiler serialization error with unconsumed streams Dec 17, 2025
@carsonbot carsonbot changed the title [AI Bundle] Fix profiler serialization error with unconsumed streams Fix profiler serialization error with unconsumed streams Dec 17, 2025
@camilleislasse
Copy link
Contributor Author

camilleislasse commented Dec 17, 2025

need #1177 for phpstan

@OskarStark
Copy link
Contributor

Rebase unlocked

@camilleislasse camilleislasse force-pushed the fix/profiler-streaming-serialization branch from f64a1c6 to de45e71 Compare December 17, 2025 16:40
@OskarStark OskarStark added the AI Bundle Issues & PRs about the AI integration bundle label Dec 18, 2025
@carsonbot carsonbot changed the title Fix profiler serialization error with unconsumed streams [AI Bundle] Fix profiler serialization error with unconsumed streams Dec 18, 2025
@OskarStark OskarStark closed this Dec 18, 2025
@OskarStark OskarStark reopened this Dec 18, 2025
@OskarStark
Copy link
Contributor

Can you please rebase? Thanks

@camilleislasse camilleislasse force-pushed the fix/profiler-streaming-serialization branch from de45e71 to 1b4605c Compare December 18, 2025 12:51
@OskarStark OskarStark force-pushed the fix/profiler-streaming-serialization branch from 1b4605c to 92fe6af Compare December 19, 2025 16:56
@OskarStark
Copy link
Contributor

Thanks for fixing this bug @camilleislasse.

@OskarStark OskarStark merged commit ca467d3 into symfony:main Dec 19, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Bundle Issues & PRs about the AI integration bundle Bug Something isn't working Status: Reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming model breaks profiler data collection

4 participants