mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Save output in state via output_key only when the event is authored by current agent
PiperOrigin-RevId: 776640671
This commit is contained in:
committed by
Copybara-Service
parent
09e487df3c
commit
20279d9a50
@@ -431,12 +431,22 @@ class LlmAgent(BaseAgent):
|
||||
|
||||
def __maybe_save_output_to_state(self, event: Event):
|
||||
"""Saves the model output to state if needed."""
|
||||
# skip if the event was authored by some other agent (e.g. current agent
|
||||
# transferred to another agent)
|
||||
if event.author != self.name:
|
||||
logger.debug(
|
||||
'Skipping output save for agent %s: event authored by %s',
|
||||
self.name,
|
||||
event.author,
|
||||
)
|
||||
return
|
||||
if (
|
||||
self.output_key
|
||||
and event.is_final_response()
|
||||
and event.content
|
||||
and event.content.parts
|
||||
):
|
||||
|
||||
result = ''.join(
|
||||
[part.text if part.text else '' for part in event.content.parts]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user