mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-14 09:51:25 -06:00
fix: Concatenate all text Parts from an AgentTool agent's response.
PiperOrigin-RevId: 758424011
This commit is contained in:
parent
d6cf660506
commit
933f01b89f
@ -162,17 +162,17 @@ class AgentTool(BaseTool):
|
|||||||
filename=artifact_name, artifact=artifact
|
filename=artifact_name, artifact=artifact
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if not last_event or not last_event.content or not last_event.content.parts:
|
||||||
not last_event
|
|
||||||
or not last_event.content
|
|
||||||
or not last_event.content.parts
|
|
||||||
or not last_event.content.parts[0].text
|
|
||||||
):
|
|
||||||
return ''
|
return ''
|
||||||
if isinstance(self.agent, LlmAgent) and self.agent.output_schema:
|
if isinstance(self.agent, LlmAgent) and self.agent.output_schema:
|
||||||
|
merged_text = '\n'.join(
|
||||||
|
[p.text for p in last_event.content.parts if p.text]
|
||||||
|
)
|
||||||
tool_result = self.agent.output_schema.model_validate_json(
|
tool_result = self.agent.output_schema.model_validate_json(
|
||||||
last_event.content.parts[0].text
|
merged_text
|
||||||
).model_dump(exclude_none=True)
|
).model_dump(exclude_none=True)
|
||||||
else:
|
else:
|
||||||
tool_result = last_event.content.parts[0].text
|
tool_result = '\n'.join(
|
||||||
|
[p.text for p in last_event.content.parts if p.text]
|
||||||
|
)
|
||||||
return tool_result
|
return tool_result
|
||||||
|
Loading…
Reference in New Issue
Block a user