Skip to content

Conversation

@lavaman131
Copy link
Contributor

Motivation and Context

Short Summary

Fixes the warning when using AI Foundry Agents with AzureAIAgentClient:

agent-framework/python/packages/core/agent_framework/_clients.py:704 - WARNING]
When conversation_id is set, store must be True for service-managed threads. Automatically setting store=True.

Detailed Summary

This pull request introduces a minor update to the python/packages/azure-ai/agent_framework_azure_ai/_chat_client.py file to improve type safety and extend functionality. The most notable change is the addition of a new create_agent method, which delegates agent creation to the superclass, and type checking improvements for better developer experience.

Type checking improvements:

  • Added an if TYPE_CHECKING block to import ChatAgent for type hints, improving static analysis and autocompletion without affecting runtime performance.
  • Updated import statements to include TYPE_CHECKING from typing, supporting the new type hinting logic.

Functionality extension:

  • Added a create_agent method to the chat client, allowing agent creation with optional storage and keyword arguments, and delegating the logic to the superclass.

Copilot AI review requested due to automatic review settings October 24, 2025 21:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a warning message that appears when using AI Foundry Agents with AzureAIAgentClient by defaulting to service-managed threads with store=True. The change ensures proper thread management for conversation-based interactions.

Key Changes:

  • Added a create_agent method to AzureAIChatClient that defaults store=True for service-managed threads
  • Improved type safety by adding TYPE_CHECKING imports for better static analysis

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Oct 24, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/azure-ai/agent_framework_azure_ai
   _chat_client.py4218380%244, 249, 280, 282, 356, 429, 529–530, 532, 535, 538–543, 545, 553, 565–567, 571, 574–575, 583–586, 596, 604–609, 616, 624–625, 633–634, 639–640, 644–651, 656–657, 665, 671, 679–681, 684, 742–744, 761, 773–777, 804–806, 809–810, 825, 830, 872–873, 894, 950, 969, 1035–1036, 1038, 1110
TOTAL11653189783% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
1371 98 💤 0 ❌ 0 🔥 26.385s ⏱️

"""
return self.project_client._config.endpoint

def create_agent(self, *, store: bool | None = True, **kwargs: Any) -> "ChatAgent":
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if this is the way, for one, this method lacks all metadata compared to the create_agent method on the BaseClient, so it won't give the right IDE info. It also introduces a difference in creating a agent through this method, vs directly, which I don't like. I'm also not convinced what problem this solves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants