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
fix(flows): detect thought-only and whitespace turns as empty content
When models return turns that contain only reasoning thoughts
(parts with thought=True) or whitespace text with finish_reason=STOP
after tool execution or under streaming, BaseLlmFlow previously
treated them as complete final responses because parts was not empty.
This caused the agent loop to silently terminate without answering the
user or surfacing an error.
- Add has_meaningful_content(llm_response) helper in _finalizer.py
to verify if an LLM response contains actionable content (tools, code,
data, or non-thought non-whitespace text).
- Update apply_empty_response_policy in _model_call.py to stamp
MODEL_RETURNED_NO_CONTENT when an LLM response has finish_reason=STOP
but lacks meaningful content.
- Ensure LiteLlm.generate_content_async streaming always yields a terminal
partial=False response on normal termination even when no content chunks
were emitted.
- Add unit tests covering has_meaningful_content, BaseLlmFlow error events
for thought-only and whitespace-only turns, and LiteLlm empty stream fallback.
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 988479382
0 commit comments