Skip to content

Commit b0b0761

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Allow skipping thoughts output from the subagent wrapping in AgentTool
Hereby we can allow a root agent to directly get the non-thoughts subagent response. PiperOrigin-RevId: 794787686
1 parent 52284b1 commit b0b0761

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/google/adk/tools/agent_tool.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ class AgentTool(BaseTool):
4949
skip_summarization: Whether to skip summarization of the agent output.
5050
"""
5151

52-
def __init__(self, agent: BaseAgent, skip_summarization: bool = False):
52+
def __init__(
53+
self,
54+
agent: BaseAgent,
55+
skip_summarization: bool = False,
56+
skip_thoughts: bool = False,
57+
):
5358
self.agent = agent
5459
self.skip_summarization: bool = skip_summarization
60+
self.skip_thoughts: bool = skip_thoughts
5561

5662
super().__init__(name=agent.name, description=agent.description)
5763

@@ -155,7 +161,14 @@ async def run_async(
155161

156162
if not last_event or not last_event.content or not last_event.content.parts:
157163
return ''
158-
merged_text = '\n'.join(p.text for p in last_event.content.parts if p.text)
164+
if self.skip_thoughts:
165+
merged_text = '\n'.join(
166+
p.text for p in last_event.content.parts if (p.text and not p.thought)
167+
)
168+
else:
169+
merged_text = '\n'.join(
170+
p.text for p in last_event.content.parts if p.text
171+
)
159172
if isinstance(self.agent, LlmAgent) and self.agent.output_schema:
160173
tool_result = self.agent.output_schema.model_validate_json(
161174
merged_text

0 commit comments

Comments
 (0)