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

Function build_test_agent

tests/unittests/telemetry/functional_test_helpers.py:363–387  ·  view source on GitHub ↗

Builds the canonical 1-tool, 2-LLM-turn agent.

(*, failing: bool = False)

Source from the content-addressed store, hash-verified

361
362
363def build_test_agent(*, failing: bool = False) -> Agent:
364 """Builds the canonical 1-tool, 2-LLM-turn agent."""
365 mock_model = MockModel.create(
366 responses=[
367 _make_llm_response(
368 Part.from_function_call(name=TOOL_NAME, args=TOOL_ARGS)
369 ),
370 _make_llm_response(Part.from_text(text=FINAL_TEXT)),
371 ]
372 )
373
374 def some_tool(arg1: str) -> str:
375 """A sample tool."""
376 if failing:
377 raise ValueError("This tool always fails")
378
379 return f"{TOOL_RESULT_PREFIX}{arg1}"
380
381 return Agent(
382 name=AGENT_NAME,
383 description=AGENT_DESCRIPTION,
384 instruction=BASE_INSTRUCTION,
385 model=mock_model,
386 tools=[FunctionTool(some_tool)],
387 )
388
389
390def build_test_runner(*, failing: bool = False) -> TestInMemoryRunner:

Callers 2

build_test_runnerFunction · 0.85
build_test_workflowFunction · 0.85

Calls 3

FunctionToolClass · 0.90
_make_llm_responseFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected