Skip to content

Python: Include constructor tools in agent-hooks startup - #7600

Open
Ruiming Zhao (uuzzrm) wants to merge 2 commits into
microsoft:mainfrom
uuzzrm:codex/issue-7560-tools-registered
Open

Python: Include constructor tools in agent-hooks startup#7600
Ruiming Zhao (uuzzrm) wants to merge 2 commits into
microsoft:mainfrom
uuzzrm:codex/issue-7560-tools-registered

Conversation

@uuzzrm

@uuzzrm Ruiming Zhao (uuzzrm) commented Aug 10, 2026

Copy link
Copy Markdown

Motivation & Context

The agent-hooks agent_startup projection does not report the complete tool set available to an agent run. Constructor-registered tools are stored in the agent's configured default_options["tools"], while run-level tools are supplied separately through the agent context. The projection needs to include both sources so tools_registered matches the tools resolved for the model.

Description & Review Guide

  • What are the major changes? Build the startup projection from configured agent tools plus the selected run-level tool source, using the framework's existing normalization and duplicate-name handling. Add regression coverage for constructor tools combined with run(tools=...), options["tools"], and the named-argument precedence rule.
  • What is the impact of these changes? agent_startup.agent_init.tools_registered now reflects configured tools and the effective run-level tools. A named run(tools=...) value takes precedence over options["tools"], matching Agent._prepare_run_context.
  • What do you want reviewers to focus on? Please check that the projection's source selection and duplicate handling remain aligned with the agent's runtime tool resolution, while preserving the existing fallback for custom agents that expose tools without default_options.

Related Issue

Fixes #7560

Contribution Checklist

  • The code complies with the Microsoft Open Source Code of Conduct.
  • The code complies with the Microsoft Open Source Guidelines.
  • I have performed a self-review of my own code and corrected any misspellings.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • This is not a breaking change.

Copilot AI balanced review requested due to automatic review settings August 10, 2026 16:03
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 10, 2026
@uuzzrm
Ruiming Zhao (uuzzrm) marked this pull request as ready for review August 10, 2026 16:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Includes constructor-registered Python agent tools in agent-hooks startup projections.

Changes:

  • Reads tools from agent default options when absent from run context.
  • Adds regression coverage for constructor tools.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/packages/core/agent_framework/_agent_hooks.py Adds constructor-tool fallback.
python/packages/core/tests/core/test_agent_hooks.py Tests startup tool projection.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/core/agent_framework/_agent_hooks.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: constructor-registered tools missing from agent-hooks agent_startup projection

2 participants