Repository navigation
feat: pass captured tool declarations to ADK judges #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
krisztianfekete
merged 3 commits into
agentevals-dev:main
from
erauner12:feature/tool-definitions-app-details
Nov 4, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| """Captured tool declarations reach ADK judges without changing exported eval sets.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| from agentevals.adk_bridge import invocation_to_dict, to_adk_invocation | ||
| from agentevals.builtin_metrics import _enrich_app_details | ||
| from agentevals.genai.model import LlmCall, ToolCall, Turn | ||
| from agentevals.otel.model import SpanRef | ||
|
|
||
| REF = SpanRef("trace", "turn") | ||
|
|
||
|
|
||
| def _call(definitions, agent_name=None): | ||
| return LlmCall(ref=REF, operation="chat", agent_name=agent_name, tool_definitions=definitions) | ||
|
|
||
|
|
||
| def test_captured_tools_include_uncalled_tools_and_keep_first_definition(): | ||
| schema = {"type": "object", "properties": {"query": {"type": "string"}}} | ||
| definitions = [ | ||
| {"type": "function", "name": "search", "description": "Search the available evidence.", "parameters": schema}, | ||
| {"type": "function", "name": "lookup", "description": "Look up an item.", "parameters": {}}, | ||
| ] | ||
| turn = Turn( | ||
| ref=REF, | ||
| agent_name="researcher", | ||
| llm_calls=[ | ||
| _call(definitions), | ||
| _call( | ||
| [ | ||
| {"type": "function", "name": "search", "description": "Changed", "parameters": {}}, | ||
| {"type": "function", "name": "finish"}, | ||
| ] | ||
| ), | ||
| ], | ||
| tool_calls=[ToolCall(name="search")], | ||
| ) | ||
|
|
||
| invocation = to_adk_invocation(turn) | ||
|
|
||
| declarations = invocation.app_details.agent_details["researcher"].tool_declarations[0].function_declarations | ||
| assert [declaration.name for declaration in declarations] == ["search", "lookup", "finish"] | ||
| assert declarations[0].description == definitions[0]["description"] | ||
| assert declarations[0].parameters_json_schema == schema | ||
| assert declarations[0].parameters is None | ||
| assert declarations[1].description == definitions[1]["description"] | ||
| assert declarations[1].parameters_json_schema == {} | ||
| assert declarations[2].description is None | ||
| assert declarations[2].parameters_json_schema is None | ||
| assert _enrich_app_details([invocation])[0] is invocation | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "call_agent,turn_agent,expected", [("worker", "root", "worker"), (None, "root", "root"), (None, None, "agent")] | ||
| ) | ||
| def test_tool_agent_name_falls_back_to_turn_then_agent(call_agent, turn_agent, expected): | ||
| turn = Turn(ref=REF, agent_name=turn_agent, llm_calls=[_call([{"type": "function", "name": "search"}], call_agent)]) | ||
|
|
||
| assert list(to_adk_invocation(turn).app_details.agent_details) == [expected] | ||
|
|
||
|
|
||
| def test_agents_keep_separate_tools_and_do_not_include_system_instructions(): | ||
| first = _call([{"type": "function", "name": "lookup", "description": "Search documents."}], "researcher") | ||
| first.system_instructions = [{"type": "text", "content": "Private instructions."}] | ||
| second = _call([{"type": "function", "name": "lookup", "description": "Search billing records."}], "billing") | ||
|
|
||
| invocation = to_adk_invocation(Turn(ref=REF, llm_calls=[first, second])) | ||
|
|
||
| agents = invocation.app_details.agent_details | ||
| assert list(agents) == ["researcher", "billing"] | ||
| assert agents["researcher"].tool_declarations[0].function_declarations[0].description == "Search documents." | ||
| assert agents["billing"].tool_declarations[0].function_declarations[0].description == "Search billing records." | ||
| assert all(details.instructions == "" for details in agents.values()) | ||
| assert "app_details" not in invocation_to_dict(invocation) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "calls", | ||
| [ | ||
| [], | ||
| [_call([])], | ||
| [ | ||
| _call( | ||
| [ | ||
| {}, | ||
| {"type": "function", "name": ""}, | ||
| {"type": "function", "name": None}, | ||
| {"type": "function", "name": 7}, | ||
| ] | ||
| ) | ||
| ], | ||
| ], | ||
| ) | ||
| def test_missing_or_unusable_definitions_leave_names_only_fallback(calls): | ||
| turn = Turn(ref=REF, llm_calls=calls, tool_calls=[ToolCall(name="search")]) | ||
| invocation = to_adk_invocation(turn) | ||
|
|
||
| assert invocation.app_details is None | ||
| (enriched,) = _enrich_app_details([invocation]) | ||
| (declaration,) = enriched.app_details.agent_details["agent"].tool_declarations[0].function_declarations | ||
| assert declaration.name == "search" | ||
| assert declaration.description is None | ||
| assert declaration.parameters_json_schema is None | ||
| assert invocation.app_details is None | ||
|
|
||
|
|
||
| def test_malformed_description_does_not_break_trace_conversion(): | ||
| turn = Turn( | ||
| ref=REF, llm_calls=[_call([{"type": "function", "name": "search", "description": {"unexpected": "object"}}])] | ||
| ) | ||
|
|
||
| (declaration,) = ( | ||
| to_adk_invocation(turn).app_details.agent_details["agent"].tool_declarations[0].function_declarations | ||
| ) | ||
|
|
||
| assert declaration.name == "search" | ||
| assert declaration.description is None | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "definition", | ||
| [ | ||
| {"type": "google_search", "name": "web"}, | ||
| {"type": "custom", "name": "custom"}, | ||
| {"name": "missing_type"}, | ||
| ], | ||
| ) | ||
| def test_only_function_definitions_are_converted(definition): | ||
| turn = Turn(ref=REF, llm_calls=[_call([definition, {"type": "function", "name": "lookup"}])]) | ||
|
|
||
| (declaration,) = ( | ||
| to_adk_invocation(turn).app_details.agent_details["agent"].tool_declarations[0].function_declarations | ||
| ) | ||
|
|
||
| assert declaration.name == "lookup" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.