Port .NET PR: https://github.com/microsoft/agent-framework/pull/6672 to Python.
Port .NET PR: #6672 to Python.