| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…ents (microsoft#5173) _clone_chat_agent() was using agent.agent_middleware (agent-level only) instead of agent.middleware (all types), which silently dropped any function middleware registered on the original agent. Changed to use agent.middleware to preserve all middleware types (agent, function, and chat) during cloning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Reviewers: 4 | Confidence: 95% | Result: All clear
Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach
Automated review by moonbox3's agents
Sorry, something went wrong.
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Sorry, something went wrong.
There was a problem hiding this comment.
Fixes a handoff workflow cloning bug where HandoffAgentExecutor._clone_chat_agent() only copied agent-level middleware (agent.agent_middleware) and silently dropped function-level middleware, preventing user @function_middleware from running during handoffs.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/packages/orchestrations/agent_framework_orchestrations/_handoff.py | Fix clone construction to preserve the original agent’s full middleware list. |
| python/packages/orchestrations/tests/test_handoff.py | Adds a regression test for middleware preservation in handoff agent cloning. |
Sorry, something went wrong.
The test used isinstance(m, FunctionMiddleware) which matched _AutoHandoffMiddleware (always appended during build) instead of the user's @function_middleware decorator. Assert directly that tracking_middleware is present in the cloned agent's middleware list. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…lder drops function-level middleware when cloning agents
There was a problem hiding this comment.
Reviewers: 4 | Confidence: 95% | Result: All clear
Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach
Automated review by moonbox3's agents
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Motivation and Context
HandoffAgentExecutor._clone_chat_agent() used agent.agent_middleware (agent-level only) instead of agent.middleware (all types), silently discarding any @function_middleware registered on the original agent so it never executed during handoff workflows.
Fixes #5173
Description
The root cause was in _handoff.py line 290: the clone constructor was passed agent.agent_middleware, which only contains agent-level middleware after categorize_middleware() splits the list during Agent.__init__. The fix changes this to agent.middleware, which holds the full original middleware list including both agent and function middleware. A regression test verifies that function middleware survives the cloning step performed by HandoffBuilder.build().
Contribution Checklist