agent-framework-foundry 1.15.0__tar.gz → 1.16.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/PKG-INFO +11 -4
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/README.md +8 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_agent.py +10 -3
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_chat_client.py +40 -8
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_embedding_client.py +17 -1
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/pyproject.toml +8 -4
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/LICENSE +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/__init__.py +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_constants.py +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_feature_usage.py +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_foundry_evals.py +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_memory_provider.py +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_oauth_helpers.py +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_to_prompt_agent.py +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_tools.py +0 -0
- {agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agent-framework-foundry
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.16.0
|
|
4
4
|
Summary: Microsoft Foundry integrations for Microsoft Agent Framework.
|
|
5
5
|
Author-email: Microsoft <af-support@microsoft.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -9,7 +9,6 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
9
9
|
Classifier: Development Status :: 5 - Production/Stable
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -17,8 +16,8 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.15
|
|
18
17
|
Classifier: Typing :: Typed
|
|
19
18
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: agent-framework-core>=1.
|
|
21
|
-
Requires-Dist: agent-framework-openai>=1.
|
|
19
|
+
Requires-Dist: agent-framework-core>=1.24.0,<2
|
|
20
|
+
Requires-Dist: agent-framework-openai>=1.18.0,<2
|
|
22
21
|
Requires-Dist: aiohttp>=3.9,<4
|
|
23
22
|
Requires-Dist: azure-ai-inference>=1.0.0b9,<1.0.0b10
|
|
24
23
|
Requires-Dist: azure-ai-projects>=2.2.0,<2.8.0
|
|
@@ -39,6 +38,14 @@ This package supports `azure-ai-projects>=2.2.0,<2.8.0`. Projects 2.5 and later
|
|
|
39
38
|
`openai>=3.0.0`, so `agent-framework-foundry` requires `agent-framework-openai>=1.14.2`,
|
|
40
39
|
which supports both OpenAI 2.x and 3.x.
|
|
41
40
|
|
|
41
|
+
## Chat client lifecycle
|
|
42
|
+
|
|
43
|
+
Use `async with FoundryChatClient(...)` or `async with FoundryAgent(...)` to release owned connections, or call
|
|
44
|
+
`await client.close()` explicitly when using a chat client without a context manager. Chat clients close their
|
|
45
|
+
derived OpenAI connection, including when a timeout-configured copy shares its transport. They also close the
|
|
46
|
+
project connection if they created it. A supplied `project_client` and credential remain caller-owned; manage the
|
|
47
|
+
credential's context outside the chat client or agent. Cleanup does not delete remote agents or conversations.
|
|
48
|
+
|
|
42
49
|
## Tool ownership for preconfigured Foundry agents
|
|
43
50
|
|
|
44
51
|
`FoundryAgent` connects to a PromptAgent or HostedAgent whose instructions, tool declarations, and tool-selection
|
|
@@ -8,6 +8,14 @@ This package supports `azure-ai-projects>=2.2.0,<2.8.0`. Projects 2.5 and later
|
|
|
8
8
|
`openai>=3.0.0`, so `agent-framework-foundry` requires `agent-framework-openai>=1.14.2`,
|
|
9
9
|
which supports both OpenAI 2.x and 3.x.
|
|
10
10
|
|
|
11
|
+
## Chat client lifecycle
|
|
12
|
+
|
|
13
|
+
Use `async with FoundryChatClient(...)` or `async with FoundryAgent(...)` to release owned connections, or call
|
|
14
|
+
`await client.close()` explicitly when using a chat client without a context manager. Chat clients close their
|
|
15
|
+
derived OpenAI connection, including when a timeout-configured copy shares its transport. They also close the
|
|
16
|
+
project connection if they created it. A supplied `project_client` and credential remain caller-owned; manage the
|
|
17
|
+
credential's context outside the chat client or agent. Cleanup does not delete remote agents or conversations.
|
|
18
|
+
|
|
11
19
|
## Tool ownership for preconfigured Foundry agents
|
|
12
20
|
|
|
13
21
|
`FoundryAgent` connects to a PromptAgent or HostedAgent whose instructions, tool declarations, and tool-selection
|
{agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_agent.py
RENAMED
|
@@ -292,6 +292,8 @@ class RawFoundryAgentChatClient(
|
|
|
292
292
|
tokenizer=tokenizer,
|
|
293
293
|
additional_properties=additional_properties,
|
|
294
294
|
)
|
|
295
|
+
self._owns_client = True
|
|
296
|
+
self._project_client_closed = False
|
|
295
297
|
self.model = "" # Foundry agents resolve model server-side; ignore env vars (issue #7272).
|
|
296
298
|
|
|
297
299
|
@override
|
|
@@ -541,10 +543,15 @@ class RawFoundryAgentChatClient(
|
|
|
541
543
|
|
|
542
544
|
return transformed
|
|
543
545
|
|
|
546
|
+
@override
|
|
544
547
|
async def close(self) -> None:
|
|
545
|
-
"""Close
|
|
546
|
-
|
|
547
|
-
await
|
|
548
|
+
"""Close owned OpenAI and project connections, not the supplied credential."""
|
|
549
|
+
try:
|
|
550
|
+
await super().close()
|
|
551
|
+
finally:
|
|
552
|
+
if self._should_close_client and not self._project_client_closed:
|
|
553
|
+
await self.project_client.close()
|
|
554
|
+
self._project_client_closed = True
|
|
548
555
|
|
|
549
556
|
|
|
550
557
|
class _FoundryAgentChatClient(
|
|
@@ -187,6 +187,7 @@ class RawFoundryChatClient(
|
|
|
187
187
|
compaction_strategy: CompactionStrategy | None = None,
|
|
188
188
|
tokenizer: TokenizerProtocol | None = None,
|
|
189
189
|
additional_properties: dict[str, Any] | None = None,
|
|
190
|
+
timeout: float | None = None,
|
|
190
191
|
) -> None:
|
|
191
192
|
"""Initialize a raw Microsoft Foundry chat client.
|
|
192
193
|
|
|
@@ -207,6 +208,8 @@ class RawFoundryChatClient(
|
|
|
207
208
|
compaction_strategy: Optional per-client compaction override.
|
|
208
209
|
tokenizer: Optional tokenizer for compaction strategies.
|
|
209
210
|
additional_properties: Additional properties stored on the client instance.
|
|
211
|
+
timeout: HTTP timeout in seconds for requests. When not provided, the
|
|
212
|
+
OpenAI SDK default is used (connect: 5s, total: 600s).
|
|
210
213
|
"""
|
|
211
214
|
foundry_settings = load_settings(
|
|
212
215
|
FoundrySettings,
|
|
@@ -255,9 +258,13 @@ class RawFoundryChatClient(
|
|
|
255
258
|
if owns_project_client:
|
|
256
259
|
openai_kwargs["http_client"] = create_foundry_feature_usage_http_client()
|
|
257
260
|
|
|
261
|
+
openai_client = project_client.get_openai_client(**openai_kwargs)
|
|
262
|
+
if timeout is not None:
|
|
263
|
+
openai_client = openai_client.with_options(timeout=timeout)
|
|
264
|
+
|
|
258
265
|
super().__init__(
|
|
259
266
|
model=resolved_model,
|
|
260
|
-
async_client=
|
|
267
|
+
async_client=openai_client,
|
|
261
268
|
default_headers=default_headers,
|
|
262
269
|
instruction_role=instruction_role,
|
|
263
270
|
compaction_strategy=compaction_strategy,
|
|
@@ -265,6 +272,20 @@ class RawFoundryChatClient(
|
|
|
265
272
|
additional_properties=additional_properties,
|
|
266
273
|
)
|
|
267
274
|
self.project_client = project_client
|
|
275
|
+
self._owns_project_client = owns_project_client
|
|
276
|
+
self._project_client_closed = False
|
|
277
|
+
# get_openai_client creates an independent connection, even for an injected project.
|
|
278
|
+
self._owns_client = True
|
|
279
|
+
|
|
280
|
+
@override
|
|
281
|
+
async def close(self) -> None:
|
|
282
|
+
"""Close owned OpenAI and project connections, not the supplied credential."""
|
|
283
|
+
try:
|
|
284
|
+
await super().close()
|
|
285
|
+
finally:
|
|
286
|
+
if self._owns_project_client and not self._project_client_closed:
|
|
287
|
+
await self.project_client.close()
|
|
288
|
+
self._project_client_closed = True
|
|
268
289
|
|
|
269
290
|
@override
|
|
270
291
|
async def _prepare_options(
|
|
@@ -807,10 +828,16 @@ class RawFoundryChatClient(
|
|
|
807
828
|
if isinstance(approval_mode, str):
|
|
808
829
|
mcp["require_approval"] = "always" if approval_mode == "always_require" else "never"
|
|
809
830
|
else:
|
|
831
|
+
# Both keys can be supplied together ("and/or" per the docstring), so build
|
|
832
|
+
# one combined mapping instead of letting the second assignment overwrite
|
|
833
|
+
# the first, which silently dropped the always-approval tool list.
|
|
834
|
+
require_approval: dict[str, Any] = {}
|
|
810
835
|
if always_require := approval_mode.get("always_require_approval"):
|
|
811
|
-
|
|
836
|
+
require_approval["always"] = {"tool_names": always_require}
|
|
812
837
|
if never_require := approval_mode.get("never_require_approval"):
|
|
813
|
-
|
|
838
|
+
require_approval["never"] = {"tool_names": never_require}
|
|
839
|
+
if require_approval:
|
|
840
|
+
mcp["require_approval"] = require_approval
|
|
814
841
|
|
|
815
842
|
return mcp
|
|
816
843
|
|
|
@@ -951,15 +978,16 @@ class RawFoundryChatClient(
|
|
|
951
978
|
Older supported SDK releases can still import this client; calling this
|
|
952
979
|
factory on those releases raises ``ImportError`` with upgrade guidance.
|
|
953
980
|
"""
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
981
|
+
from azure.ai.projects import models
|
|
982
|
+
|
|
983
|
+
computer_tool_cls = getattr(models, "ComputerTool", None)
|
|
984
|
+
if computer_tool_cls is None:
|
|
957
985
|
raise ImportError(
|
|
958
986
|
"FoundryChatClient.get_computer_tool() requires ComputerTool from azure-ai-projects>=2.3.0. "
|
|
959
987
|
"Upgrade azure-ai-projects to >=2.3.0 to use this tool."
|
|
960
|
-
)
|
|
988
|
+
)
|
|
961
989
|
|
|
962
|
-
return
|
|
990
|
+
return computer_tool_cls()
|
|
963
991
|
|
|
964
992
|
@staticmethod
|
|
965
993
|
@experimental(feature_id=ExperimentalFeature.FOUNDRY_PREVIEW_TOOLS)
|
|
@@ -1129,6 +1157,7 @@ class FoundryChatClient(
|
|
|
1129
1157
|
additional_properties: dict[str, Any] | None = None,
|
|
1130
1158
|
middleware: (Sequence[ChatAndFunctionMiddlewareTypes] | None) = None,
|
|
1131
1159
|
function_invocation_configuration: FunctionInvocationConfiguration | None = None,
|
|
1160
|
+
timeout: float | None = None,
|
|
1132
1161
|
) -> None:
|
|
1133
1162
|
"""Initialize a Foundry chat client.
|
|
1134
1163
|
|
|
@@ -1149,6 +1178,8 @@ class FoundryChatClient(
|
|
|
1149
1178
|
additional_properties: Additional properties stored on the client instance.
|
|
1150
1179
|
middleware: Optional sequence of middleware.
|
|
1151
1180
|
function_invocation_configuration: Optional function invocation configuration.
|
|
1181
|
+
timeout: HTTP timeout in seconds for requests. When not provided, the
|
|
1182
|
+
OpenAI SDK default is used (connect: 5s, total: 600s).
|
|
1152
1183
|
"""
|
|
1153
1184
|
super().__init__(
|
|
1154
1185
|
project_endpoint=project_endpoint,
|
|
@@ -1165,4 +1196,5 @@ class FoundryChatClient(
|
|
|
1165
1196
|
additional_properties=additional_properties,
|
|
1166
1197
|
middleware=middleware,
|
|
1167
1198
|
function_invocation_configuration=function_invocation_configuration,
|
|
1199
|
+
timeout=timeout,
|
|
1168
1200
|
)
|
|
@@ -22,6 +22,7 @@ from agent_framework import (
|
|
|
22
22
|
load_settings,
|
|
23
23
|
)
|
|
24
24
|
from agent_framework._telemetry import IS_TELEMETRY_ENABLED, USER_AGENT_KEY, get_user_agent, mark_feature_used
|
|
25
|
+
from agent_framework.exceptions import IntegrationInvalidResponseException
|
|
25
26
|
from agent_framework.observability import EmbeddingTelemetryLayer
|
|
26
27
|
from azure.ai.inference.aio import EmbeddingsClient, ImageEmbeddingsClient
|
|
27
28
|
from azure.ai.inference.models import ImageEmbeddingInput
|
|
@@ -428,7 +429,22 @@ class RawFoundryEmbeddingClient(
|
|
|
428
429
|
for item in sorted(openai_response.data, key=lambda value: value.index):
|
|
429
430
|
original_idx = text_items[item.index][0]
|
|
430
431
|
if encoding == "base64" and isinstance(item.embedding, str):
|
|
431
|
-
|
|
432
|
+
# base64.b64decode raises binascii.Error for bad padding/alphabet and
|
|
433
|
+
# UnicodeEncodeError for non-ASCII input; both are ValueError subclasses.
|
|
434
|
+
try:
|
|
435
|
+
raw = base64.b64decode(item.embedding)
|
|
436
|
+
except ValueError as exc:
|
|
437
|
+
raise IntegrationInvalidResponseException(
|
|
438
|
+
f"The base64 embedding returned for input index {original_idx} could not be "
|
|
439
|
+
f"decoded: {exc}"
|
|
440
|
+
) from exc
|
|
441
|
+
if len(raw) % 4 != 0:
|
|
442
|
+
# struct.unpack would fail with a bare "unpack requires a buffer of N bytes",
|
|
443
|
+
# which says nothing about which input broke or why.
|
|
444
|
+
raise IntegrationInvalidResponseException(
|
|
445
|
+
f"The base64 embedding returned for input index {original_idx} decoded to "
|
|
446
|
+
f"{len(raw)} bytes, which is not a multiple of the 4 bytes a float32 value occupies."
|
|
447
|
+
)
|
|
432
448
|
vector = list(struct.unpack(f"<{len(raw) // 4}f", raw))
|
|
433
449
|
else:
|
|
434
450
|
vector = [float(value) for value in item.embedding]
|
|
@@ -4,7 +4,7 @@ description = "Microsoft Foundry integrations for Microsoft Agent Framework."
|
|
|
4
4
|
authors = [{ name = "Microsoft", email = "af-support@microsoft.com"}]
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.16.0"
|
|
8
8
|
license-files = ["LICENSE"]
|
|
9
9
|
urls.homepage = "https://aka.ms/agent-framework"
|
|
10
10
|
urls.source = "https://github.com/microsoft/agent-framework/tree/main/python"
|
|
@@ -15,7 +15,6 @@ classifiers = [
|
|
|
15
15
|
"Development Status :: 5 - Production/Stable",
|
|
16
16
|
"Intended Audience :: Developers",
|
|
17
17
|
"Programming Language :: Python :: 3",
|
|
18
|
-
"Programming Language :: Python :: 3.10",
|
|
19
18
|
"Programming Language :: Python :: 3.11",
|
|
20
19
|
"Programming Language :: Python :: 3.12",
|
|
21
20
|
"Programming Language :: Python :: 3.13",
|
|
@@ -24,14 +23,19 @@ classifiers = [
|
|
|
24
23
|
"Typing :: Typed",
|
|
25
24
|
]
|
|
26
25
|
dependencies = [
|
|
27
|
-
"agent-framework-core>=1.
|
|
28
|
-
"agent-framework-openai>=1.
|
|
26
|
+
"agent-framework-core>=1.24.0,<2",
|
|
27
|
+
"agent-framework-openai>=1.18.0,<2",
|
|
29
28
|
"aiohttp>=3.9,<4",
|
|
30
29
|
"azure-ai-inference>=1.0.0b9,<1.0.0b10",
|
|
31
30
|
"azure-ai-projects>=2.2.0,<2.8.0",
|
|
32
31
|
"httpx>=0.28,<1",
|
|
33
32
|
]
|
|
34
33
|
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
test = [
|
|
36
|
+
"agent-framework-ag-ui>=1.7.1,<2",
|
|
37
|
+
]
|
|
38
|
+
|
|
35
39
|
[tool.uv]
|
|
36
40
|
prerelease = "if-necessary"
|
|
37
41
|
environments = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/_tools.py
RENAMED
|
File without changes
|
{agent_framework_foundry-1.15.0 → agent_framework_foundry-1.16.0}/agent_framework_foundry/py.typed
RENAMED
|
File without changes
|