8000 don't send content with empty text to LLM · GeekyprogrammerEJ/adk-python@d387ab0 · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit d387ab0

Browse files
seanzhougooglecopybara-github
authored andcommitted
don't send content with empty text to LLM
PiperOrigin-RevId: 753869699
1 parent 6c0a0d6 commit 
8000
d387ab0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/google/adk/flows/llm_flows/contents.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
from __future__ import annotations
1616

1717
import copy
18-
from typing import AsyncGenerator
19-
from typing import Generator
20-
from typing import Optional
18+
from typing import AsyncGenerator, Generator, Optional
2119

2220
from google.genai import types
2321
from typing_extensions import override
@@ -202,8 +200,14 @@ def _get_contents(
202200
# Parse the events, leaving the contents and the function calls and
203201
# responses from the current agent.
204202
for event in events:
205-
if not event.content or not event.content.role:
206-
# Skip events without content, or generated neither by user nor by model.
203+
if (
204+
not event.content
205+
or not event.content.role
206+
or not event.content.parts
207+
or event.content.parts[0].text == ''
208+
):
209+
# Skip events without content, or generated neither by user nor by model
210+
# or has empty text.
207211
# E.g. events purely for mutating session states.
208212
continue
209213
if not _is_event_belongs_to_branch(current_branch, event):

0 commit comments

Comments
 (0)
0