Skip to content

Commit 6e834d3

Browse files
Jacksunweicopybara-github
authored andcommitted
feat(conformance): Skips recording for inner runner of AgentTool in conformance tests
PiperOrigin-RevId: 809252704
1 parent 9be9cc2 commit 6e834d3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/google/adk/cli/plugins/replay_plugin.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,12 @@ async def before_tool_callback(
138138
recording = self._verify_and_get_next_tool_recording_for_agent(
139139
state, agent_name, tool.name, tool_args
140140
)
141-
# Execute the actual tool to get state updates.
142-
await tool.run_async(args=tool_args, tool_context=tool_context)
141+
142+
from google.adk.tools.agent_tool import AgentTool
143+
144+
if not isinstance(tool, AgentTool):
145+
# TODO: support replay requests and responses from AgentTool.
146+
await tool.run_async(args=tool_args, tool_context=tool_context)
143147

144148
logger.debug(
145149
"Verified and replaying tool response for agent %s: tool=%s",

src/google/adk/tools/agent_tool.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,16 @@ async def run_async(
134134
credential_service=tool_context._invocation_context.credential_service,
135135
plugins=list(tool_context._invocation_context.plugin_manager.plugins),
136136
)
137+
138+
state_dict = {
139+
k: v
140+
for k, v in tool_context.state.to_dict().items()
141+
if not k.startswith('_adk') # Filter out adk internal states
142+
}
137143
session = await runner.session_service.create_session(
138144
app_name=self.agent.name,
139145
user_id=tool_context._invocation_context.user_id,
140-
state=tool_context.state.to_dict(),
146+
state=state_dict,
141147
)
142148

143149
last_content = None

0 commit comments

Comments
 (0)