Skip to content

Commit 7ac2d25

Browse files
committed
move FoundryToolClientConfiguration
1 parent eafe8cc commit 7ac2d25

File tree

3 files changed

+37
-83
lines changed

3 files changed

+37
-83
lines changed

sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/tools/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from azure.ai.agentserver.core.tools._exceptions import ToolInvocationError
1313
from azure.ai.agentserver.core.tools._models import FoundryTool, FoundryToolSource, ResolvedFoundryTool, UserInfo
14-
from azure.ai.agentserver.core.tools._to_be_deleted import FoundryToolClientConfiguration
14+
from azure.ai.agentserver.core.tools._configuration import FoundryToolClientConfiguration
1515
from azure.ai.agentserver.core.tools.operations._foundry_connected_tools import FoundryConnectedToolsOperations
1616
from azure.ai.agentserver.core.tools.operations._foundry_hosted_mcp_tools import FoundryMcpToolsOperations
1717
from azure.ai.agentserver.core.utils._credential import AsyncTokenCredentialAdapter
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ---------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# ---------------------------------------------------------
4+
from azure.core.configuration import Configuration
5+
from azure.core.credentials_async import AsyncTokenCredential
6+
from azure.core.pipeline import policies
7+
8+
from azure.ai.agentserver.core.context._package_metadata import get_current_app
9+
10+
11+
class FoundryToolClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
12+
"""Configuration for Azure AI Tool Client.
13+
14+
Manages authentication, endpoint configuration, and policy settings for the
15+
Azure AI Tool Client. This class is used internally by the client and should
16+
not typically be instantiated directly.
17+
18+
:param credential:
19+
Azure TokenCredential for authentication.
20+
:type credential: ~azure.core.credentials.TokenCredential
21+
"""
22+
23+
def __init__(self, credential: "AsyncTokenCredential"):
24+
super().__init__()
25+
26+
self.retry_policy = policies.AsyncRetryPolicy()
27+
self.logging_policy = policies.NetworkTraceLoggingPolicy()
28+
self.request_id_policy = policies.RequestIdPolicy()
29+
self.http_logging_policy = policies.HttpLoggingPolicy()
30+
self.user_agent_policy = policies.UserAgentPolicy(
31+
base_user_agent=get_current_app().as_user_agent("FoundryToolClient"))
32+
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(
33+
credential, "https://ai.azure.com/.default"
34+
)
35+
self.redirect_policy = policies.AsyncRedirectPolicy()

sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/tools/_to_be_deleted.py

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# ---------------------------------------------------------
44
# mypy: ignore-errors
5-
from typing import Any, Dict, List, Mapping, Optional, Tuple
6-
7-
from azure.core.configuration import Configuration
8-
from azure.core.credentials_async import AsyncTokenCredential
9-
from azure.core.pipeline import policies
10-
11-
from azure.ai.agentserver.core.context._package_metadata import get_current_app
12-
from azure.ai.agentserver.core.tools._models import FoundryTool
5+
from typing import Any, Dict, Mapping, Optional, Tuple
136

147

158
class MetadataMapper:
@@ -190,77 +183,3 @@ def _normalize_input(
190183
return {}
191184

192185

193-
class ToolConfigurationParser:
194-
"""Parses and processes tool configuration.
195-
196-
This class handles parsing and categorizing tool configurations into
197-
remote tools (MCP/A2A) and named MCP tools.
198-
199-
:param List[Mapping[str, Any]] tools_config:
200-
List of tool configurations to parse. Can be None.
201-
"""
202-
203-
def __init__(self, tools_definitions: Optional[List[Any]] = None):
204-
"""Initialize the parser.
205-
206-
:param tools_definitions: List of tool configurations (can be dicts or ToolDefinition objects), or None.
207-
:type tools_definitions: Optional[List[Any]]
208-
"""
209-
# Convert dictionaries to ToolDefinition objects if needed
210-
self._tools_definitions = []
211-
for tool_def in (tools_definitions or []):
212-
if isinstance(tool_def, dict):
213-
# Convert dict to ToolDefinition
214-
tool_type = tool_def.get("type")
215-
if tool_type:
216-
self._tools_definitions.append(FoundryTool(type=tool_type, **{k: v for k, v in tool_def.items() if k != "type"}))
217-
elif isinstance(tool_def, FoundryTool):
218-
self._tools_definitions.append(tool_def)
219-
220-
self._remote_tools: List[FoundryTool] = []
221-
self._named_mcp_tools: List[FoundryTool] = []
222-
self._parse_tools_config()
223-
224-
def _parse_tools_config(self) -> None:
225-
"""Parse tools configuration into categorized lists.
226-
227-
Separates tool configurations into remote tools (MCP/A2A types) and
228-
named MCP tools based on the 'type' field in each configuration.
229-
"""
230-
for tool_definition in self._tools_definitions:
231-
tool_type = tool_definition.type.lower()
232-
if tool_type in ["mcp", "a2a"]:
233-
self._remote_tools.append(tool_definition)
234-
else:
235-
self._named_mcp_tools.append(tool_definition)
236-
237-
238-
class FoundryToolClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
239-
"""Configuration for Azure AI Tool Client.
240-
241-
Manages authentication, endpoint configuration, and policy settings for the
242-
Azure AI Tool Client. This class is used internally by the client and should
243-
not typically be instantiated directly.
244-
245-
:param credential:
246-
Azure TokenCredential for authentication.
247-
:type credential: ~azure.core.credentials.TokenCredential
248-
"""
249-
250-
def __init__(self, credential: "AsyncTokenCredential"):
251-
super().__init__()
252-
253-
# Initialize tool configuration parser
254-
self.tool_config = ToolConfigurationParser(None)
255-
256-
self.retry_policy = policies.AsyncRetryPolicy()
257-
self.logging_policy = policies.NetworkTraceLoggingPolicy()
258-
self.request_id_policy = policies.RequestIdPolicy()
259-
self.http_logging_policy = policies.HttpLoggingPolicy()
260-
self.user_agent_policy = policies.UserAgentPolicy(
261-
base_user_agent=get_current_app().as_user_agent("FoundryToolClient"))
262-
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(
263-
credential, "https://ai.azure.com/.default"
264-
)
265-
self.redirect_policy = policies.AsyncRedirectPolicy()
266-

0 commit comments

Comments
 (0)