You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: fix(eval): include ContextProvider and SkillsProvider tools in evaluation definitions - #9401
When running evaluate_agent() (and evaluating metrics like tool_selection and tool_input_accuracy), tool definitions were only extracted from agent.default_options["tools"] and agent.mcp_tools[*].functions. Tools contributed by agent.context_providers (such as SkillsProvider or VectorCollectionContextProvider) were omitted.
As a result, agents equipped with SkillsProvider (load_skill, read_skill_resource, run_skill_script) or other context providers ended up with tools=None (or incomplete tool lists) in the generated EvalItem, breaking evaluator scoring on tool selection and tool input accuracy.
Changes
SkillsProvider.tools: Added @property def tools(self) -> list[FunctionTool] returning the canonical skill tools (load_skill, read_skill_resource, run_skill_script), matching providers like VectorCollectionContextProvider.
_evaluation.py:
Updated _to_eval_item to extract and normalize tools from getattr(agent, "context_providers", []) (tools or get_tools()), deduplicating against existing tools by name.
Updated legacy AgentEvalConverter.extract_tools to also include context provider tools.
Tests:
Added unit test in test_skills.py verifying SkillsProvider.tools.
Added unit tests in test_evaluation.py verifying context provider tool extraction, SkillsProvider integration, and deduplication across both _to_eval_item and AgentEvalConverter.extract_tools.
If a custom provider exposes a single FunctionTool through .tools, this branch calls it instead of collecting its definition. FunctionTool.__call__ invokes the wrapped function, so a synchronous no-argument tool can cause side effects during evaluation; a tool requiring arguments is silently omitted by the exception handler. normalize_tools already accepts single FunctionTool instances. Exclude them from this accessor-call branch and apply the same guard in AgentEvalConverter.extract_tools at line 847. Add regression coverage for both extraction paths to verify the tool is collected without being invoked.
Nithin (@nithin42) Thanks for the contribution and for working through the evaluation edge cases. The team has decided to implement #9160 internally in #9403, so we are closing this overlapping PR to keep a single implementation path.
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
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.
Closes #9160
Description
When running
evaluate_agent()(and evaluating metrics liketool_selectionandtool_input_accuracy), tool definitions were only extracted fromagent.default_options["tools"]andagent.mcp_tools[*].functions. Tools contributed byagent.context_providers(such asSkillsProviderorVectorCollectionContextProvider) were omitted.As a result, agents equipped with
SkillsProvider(load_skill,read_skill_resource,run_skill_script) or other context providers ended up withtools=None(or incomplete tool lists) in the generatedEvalItem, breaking evaluator scoring on tool selection and tool input accuracy.Changes
SkillsProvider.tools: Added@property def tools(self) -> list[FunctionTool]returning the canonical skill tools (load_skill,read_skill_resource,run_skill_script), matching providers likeVectorCollectionContextProvider._evaluation.py:_to_eval_itemto extract and normalize tools fromgetattr(agent, "context_providers", [])(toolsorget_tools()), deduplicating against existing tools by name.AgentEvalConverter.extract_toolsto also include context provider tools.test_skills.pyverifyingSkillsProvider.tools.test_evaluation.pyverifying context provider tool extraction,SkillsProviderintegration, and deduplication across both_to_eval_itemandAgentEvalConverter.extract_tools.