You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BuiltInCodeExecutor emits an empty final event before every model reply #7878
Describe the Bug:
With code_executor=BuiltInCodeExecutor(), every model reply is preceded by an empty event. That event has no content and no actions, but is_final_response() returns True for it, and it's stored in the session.
The built-in branch of the code execution response processor (flows/llm_flows/extensions/_code_execution.py) always yields an Event(actions=event_actions). It does so even when the response had no image to save as an artifact, in which case event_actions is empty.
is_final_response() documents that "Application and UI layers can rely on this helper to detect a complete, user-facing response". So a run loop that stops at the first final response returns nothing. This is what #4138 ran into: "only get a empty data event when running in my custom runner". The reporter closed it by no longer stopping at is_final_response(), but the empty event is still emitted on main.
Steps to Reproduce:
Create an LlmAgent with code_executor=BuiltInCodeExecutor().
Have the model answer with plain text, so there's no image.
Iterate runner.run_async(...) and print each event's content and is_final_response().
Expected Behavior:
Only the model's reply is emitted. An extra event appears only when it carries an artifact_delta for a saved image.
Thanks for the report and fix, @adityasingh2400. we confirmed this on main and checked #7879 locally. Text-only replies no longer get the empty final event, and image artifacts are still saved. The regression test fails on main and passes with the fix, and no other tests broke.
The PR is currently under review and will get merged once approved.
Activity
sanketpatil06 commentedon Nov 3, 2026
Thanks for the report and fix, @adityasingh2400. we confirmed this on
mainand checked #7879 locally. Text-only replies no longer get the empty final event, and image artifacts are still saved. The regression test fails onmainand passes with the fix, and no other tests broke.The PR is currently under review and will get merged once approved.
fix: emit no empty event from BuiltInCodeExecutor