Repository navigation
Python: fix tools from context providers - #9403
sophia-ramsey wants to merge 3 commits into
Conversation
Code coverage overviewLanguages: Python Python / code-coverage/python
View coverage of the 8 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
🟡 Changes recommended
Serialization and supported streaming/client paths can still lose or misrepresent tool definitions.
4 open findings
What changed in this PR
Addresses #9160 by capturing run-specific tool definitions for evaluation, including tools supplied by context providers.
Changes:
- Captures schema-only tool snapshots and preserves them through serialization.
- Adds an explicit
tools=evaluation override and loop aggregation support. - Adds regression tests and documents snapshot behavior.
| File | Description |
|---|---|
python/packages/core/tests/core/test_evaluation.py |
Tests tool discovery, overrides, and serialization. |
python/packages/core/AGENTS.md |
Documents evaluation snapshots. |
python/packages/core/agent_framework/_types.py |
Stores and restores tool schemas. |
python/packages/core/agent_framework/_harness/_loop.py |
Aggregates definitions across loop iterations. |
python/packages/core/agent_framework/_evaluation.py |
Uses captured definitions and explicit overrides. |
python/packages/core/agent_framework/_agents.py |
Captures tools during execution. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (2 commit(s)): 813d7c0994f1, 36a84a8608a6
Model: gpt-5.6-sol
Overview
The change captures run-specific tool declarations with deep-copied, JSON-validated schemas, restores them as non-executable tools, and carries them through normal response serialization and loop aggregation. Per-run capture, malformed-metadata validation, explicit overrides, and broad streaming/non-streaming tests are strong guardrails. Three serialization and lifecycle gaps remain: empty snapshots are erased, same-name progressive replacements retain stale schemas, and update-only streaming round trips omit the snapshots.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
3 verified findings remained after source verification (3 medium) across 2 files. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/_agents.py, python/packages/core/agent_framework/_types.py
36a84a8 to
c1acc93
Compare

Motivation & Context
The agent evaluation previously omitted tools injected by context providers, causing Foundry tool-selection and tool-input-accuracy evaluators to return null scores because tool definitions were missing. This change captures the tool definitions available during execution and preserves schema-only snapshots across response serialization, so they remain available for evaluation. It supports evaluating agents with dynamically provided tools, both immediately after execution and from saved responses. Tool snapshots are preserved through streaming reconstruction, approval continuations, and loops.
Description & Review Guide
tools=override.tools=was not explicitly required to resolve this issue, but it seemed like it would improve the developer experience. Similarly, responseadditional_propertiesmetadata now containsagent_framework.evaluationwith version and tools (which can include an empty"tools": []).Related Issue
Fixes #9160
AI Assistance
AI assistance details: Used copilot with GPT-6.1 Sol for solution planning, design evaluation, implementation, and testing.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.