Skip to content

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

Open
Ruiming Zhao (uuzzrm) wants to merge 6 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 6 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 reads agent.tools when no run-level tools are supplied. Agent stores tools passed to its constructor in default_options["tools"], so those tools were omitted from agent_init.tools_registered even though they were available to the run.

Description & Review Guide

  • What are the major changes? Keep the existing run-level projection and custom-agent fallback, but read default_options["tools"] when the agent exposes its configured tools there.
  • What is the impact of these changes? Constructor-registered tools now appear in the startup metadata. Runtime tool resolution and MCP lifecycle handling are unchanged.
  • What do you want reviewers to focus on? Please check the fallback order and the regression test covering an Agent(tools=[...]) run.

Verification

  • pytest packages/core/tests/core/test_agent_hooks.py
  • ruff check packages/core/agent_framework/_agent_hooks.py packages/core/tests/core/test_agent_hooks.py
  • ruff format --check packages/core/agent_framework/_agent_hooks.py packages/core/tests/core/test_agent_hooks.py
  • Pyright on the changed implementation file

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 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
@uuzzrm

Copy link
Copy Markdown
Author

Following up on the constructor/runtime tool-combination feedback: the current head a36f7fe contains the requested handling, and the reported repository checks are successful. Please re-review the current head when convenient.

@uuzzrm

Copy link
Copy Markdown
Author

Synced the existing branch with the latest upstream main in merge commit 8914c52.

The review fix itself is unchanged. The current head retains the startup projection that combines configured constructor tools with the selected run-level source, including options[tools] fallback and run(tools=...) precedence, with regression coverage for each case.

Local verification after the sync is environment-limited: the bundled Python is missing the repository dependency opentelemetry, so collection stops before imports with ModuleNotFoundError. The existing PR CI had validated the focused change; this push has triggered a new CI run for the synced head.

The PR remains open and unmerged, awaiting repository checks and maintainer review.

@uuzzrm

Copy link
Copy Markdown
Author

Updated the branch to a0c1732d5 and synced it with the latest main. I narrowed the change back to the issue's concrete repro: agent_startup now falls back to default_options["tools"] for constructor-registered tools, with a regression test. Runtime tool precedence and MCP lifecycle behavior are intentionally unchanged.

Local verification: full test_agent_hooks.py, Ruff check, Ruff format check, git diff --check, and Pyright on the changed implementation file pass. The repository's fork workflow checks are currently gated by GitHub's action_required approval state, so they have not started jobs yet.

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