MCPcopy Index your code
hub / github.com/google/adk-python / test_no_schema_args_handling

Function test_no_schema_args_handling

tests/unittests/tools/test_agent_tool.py:1455–1533  ·  view source on GitHub ↗

AgentTool.run_async handles fallback schema cases properly. - Non-'request' args are serialized as JSON. - 'request' key is kept as plain text (backward compatibility). - Empty string 'request' is correctly preserved instead of evaluating to false.

(monkeypatch, args, expected_text)

Source from the content-addressed store, hash-verified

1453)
1454@mark.asyncio
1455async def test_no_schema_args_handling(monkeypatch, args, expected_text):
1456 """AgentTool.run_async handles fallback schema cases properly.
1457
1458 - Non-'request' args are serialized as JSON.
1459 - 'request' key is kept as plain text (backward compatibility).
1460 - Empty string 'request' is correctly preserved instead of evaluating to
1461 false.
1462 """
1463 captured = {}
1464
1465 async def _empty_async_generator():
1466 if False:
1467 yield None
1468
1469 class StubRunner:
1470
1471 def __init__(
1472 self,
1473 *,
1474 app_name: str,
1475 agent,
1476 artifact_service,
1477 session_service,
1478 memory_service,
1479 credential_service,
1480 plugins,
1481 ):
1482 del artifact_service, memory_service, credential_service
1483 self.agent = agent
1484 self.session_service = session_service
1485 self.plugin_manager = PluginManager(plugins=plugins)
1486 self.app_name = app_name
1487
1488 def run_async(
1489 self,
1490 *,
1491 user_id: str,
1492 session_id: str,
1493 invocation_id=None,
1494 new_message=None,
1495 state_delta=None,
1496 run_config=None,
1497 ):
1498 captured['new_message'] = new_message
1499 return _empty_async_generator()
1500
1501 async def close(self):
1502 pass
1503
1504 monkeypatch.setattr('google.adk.runners.Runner', StubRunner)
1505
1506 tool_agent = Agent(name='tool_agent', model='test-model')
1507 agent_tool = AgentTool(agent=tool_agent)
1508 root_agent = Agent(name='root_agent', model='test-model', tools=[agent_tool])
1509
1510 session_service = InMemorySessionService()
1511 session = await session_service.create_session(
1512 app_name='test_app', user_id='user'

Callers

nothing calls this directly

Calls 9

create_sessionMethod · 0.95
run_asyncMethod · 0.95
AgentToolClass · 0.90
InvocationContextClass · 0.90
PluginManagerClass · 0.90
RunConfigClass · 0.90

Tested by

no test coverage detected