Skip to content

Updates to support release of version 2.2.0 of azure-ai-projects package#46894

Open
dargilco wants to merge 11 commits into
mainfrom
feature/azure-ai-projects/2.2.0-new
Open

Updates to support release of version 2.2.0 of azure-ai-projects package#46894
dargilco wants to merge 11 commits into
mainfrom
feature/azure-ai-projects/2.2.0-new

Conversation

@dargilco
Copy link
Copy Markdown
Member

@dargilco dargilco commented May 14, 2026

See CHANGELOG.md

dargilco and others added 2 commits May 14, 2026 10:15
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dargilco dargilco marked this pull request as ready for review May 14, 2026 22:26
Copilot AI review requested due to automatic review settings May 14, 2026 22:26
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

Updates azure-ai-projects for the upcoming 2.2.0 release, including new preview tools, API surface renames, and telemetry fixes.

Changes:

  • Fix span recording guards in telemetry instrumentors by correctly calling is_recording() and add tests for non-recording spans.
  • Apply breaking API updates/renames across models/operations (e.g., AgentEndpointConfig, PendingUploadResult, SkillDetails, taxonomy arg rename, remove session isolation_key).
  • Update and add samples demonstrating new features (toolbox tool-search) and update hosted agents/evaluations samples to match renamed APIs.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
sdk/ai/azure-ai-projects/tests/samples/llm_instructions.py Formatting-only change to instruction strings (parenthesized multi-line literals).
sdk/ai/azure-ai-projects/tests/agents/telemetry/test_non_recording_span.py Adds regression tests ensuring instrumentors skip non-recording spans.
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_sessions_crud_async.py Updates session CRUD sample for removal of isolation_key.
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_sessions_crud.py Updates session CRUD sample for removal of isolation_key.
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_session_log_stream_async.py Updates endpoint config type rename (AgentEndpointConfig).
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_session_log_stream.py Updates endpoint config type rename (AgentEndpointConfig).
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_agent_endpoint_async.py Updates endpoint config type rename (AgentEndpointConfig).
sdk/ai/azure-ai-projects/samples/hosted_agents/sample_agent_endpoint.py Updates endpoint config type rename (AgentEndpointConfig).
sdk/ai/azure-ai-projects/samples/hosted_agents/hosted_agents_util.py Updates helper to remove isolation_key usage when creating/deleting sessions.
sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py Updates evaluation taxonomy create call to use taxonomy= parameter.
sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py Updates evaluation taxonomy create call to use taxonomy= parameter.
sdk/ai/azure-ai-projects/samples/agents/sample_toolboxes_with_search_preview_async.py Adds async sample for Toolbox tool-search preview via MCP.
sdk/ai/azure-ai-projects/samples/agents/sample_toolboxes_with_search_preview.py Adds sync sample for Toolbox tool-search preview via MCP.
sdk/ai/azure-ai-projects/cspell.json Adds spelling exceptions and normalizes ordering.
sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_utils.py Fixes is_recording guard to call is_recording() correctly.
sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_responses_instrumentor.py Fixes multiple is_recording guards to call is_recording().
sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_ai_project_instrumentor.py Fixes is_recording guards to call is_recording().
sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_sessions.py Updates session file upload return type rename to SessionFileWriteResult.
sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_datasets.py Updates pending upload type rename to PendingUploadResult.
sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py Applies API surface renames/removals (sessions isolation key removal, taxonomy arg rename, skill result renames, etc.).
sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py Introduces/renames models and tools (e.g., FabricIQPreviewTool, ToolboxSearchPreviewTool, AgentEndpointConfig, target config renames).
sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py Updates enums (adds MCP protocol/tool types, removes isolation key source enum).
sdk/ai/azure-ai-projects/azure/ai/projects/models/init.py Re-exports updated/renamed models and enums.
sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_sessions_async.py Async session file upload return type rename to SessionFileWriteResult.
sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_datasets_async.py Async pending upload type rename to PendingUploadResult.
sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py Async operations updated for the same API renames/removals as sync operations.
sdk/ai/azure-ai-projects/assets.json Bumps assets tag reference.
sdk/ai/azure-ai-projects/apiview-properties.json Updates APIView type map for renamed/new models.
sdk/ai/azure-ai-projects/CHANGELOG.md Adds 2.2.0 entry describing new features, breaking changes, and telemetry fix.
sdk/ai/azure-ai-projects/.github/skills/azure-ai-projects-emit-from-typespec/SKILL.md Adds internal skill documentation for emitting SDK from TypeSpec.
sdk/ai/azure-ai-projects/.github/skills/README.md Adds README for using the local Copilot skills workflow.

Comment on lines 881 to +897
@@ -898,10 +894,7 @@ def build_beta_agents_delete_session_request(
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

# Construct headers
_headers["x-session-isolation-key"] = _SERIALIZER.header("isolation_key", isolation_key, "str")

return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)
Comment on lines +5365 to 5368
self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any
) -> _models.AgentSessionResource:
"""Creates a new session for an agent endpoint. The endpoint resolves the backing agent version
from ``version_indicator`` and enforces session ownership using the provided isolation key for
Comment on lines +24 to +33
def _make_non_recording_span():
"""Return a mock AbstractSpan wrapping a non-recording OTel span.

* ``span_instance.is_recording()`` returns ``False``
* ``span_instance.is_recording`` (the property/method) also returns ``False``
so the guard correctly skips writes.
* Any call to ``add_event``, ``set_status``, ``record_exception`` or
``set_attribute`` raises ``AssertionError``, catching any code path
that fails to check ``is_recording()`` properly.
"""

class ToolboxSearchPreviewTool(Tool, discriminator="toolbox_search_preview"):
"""A tool for searching over the agent's toolbox. When present, deferred tools are hidden from
``tools/list`` and only discoverable via ``search_tools`` queries at runtime.

from dotenv import load_dotenv

from azure.core.exceptions import ResourceNotFoundError
Comment on lines +75 to +125
toolbox_version = project_client.beta.toolboxes.create_version(
name=TOOLBOX_NAME,
description=f"Toolbox with `{INNER_MCP_LABEL}` MCP server and tool search enabled.",
tools=[inner_mcp_tool, ToolboxSearchPreviewTool()],
)
print(f"Created toolbox `{TOOLBOX_NAME}` (version {toolbox_version.version}).")

toolbox_mcp_url = f"{endpoint}/toolboxes/{TOOLBOX_NAME}/versions/{toolbox_version.version}/mcp?api-version=v1"
token = credential.get_token("https://ai.azure.com/.default").token

toolbox_mcp_tool = MCPTool(
server_label=TOOLBOX_MCP_LABEL,
server_url=toolbox_mcp_url,
authorization=token,
headers={"Foundry-Features": "Toolboxes=V1Preview"},
require_approval="never",
)

agent = project_client.agents.create_version(
agent_name="MyAgent",
definition=PromptAgentDefinition(
model=os.environ["FOUNDRY_MODEL_NAME"],
instructions=(
"Always use the toolbox search tool to answer questions and perform tasks. "
"Use `tool_search` to discover a relevant tool, then `call_tool` "
"with the tool name returned by the search."
),
tools=[toolbox_mcp_tool],
),
)
print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version}).")

response = openai_client.responses.create(
input="What is my username in Github profile?",
extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}},
)

for item in response.output:
if item.type == "mcp_approval_request":
print(f"server_label={item.server_label}, name={item.name}")
elif item.type == "mcp_list_tools":
print(f"server_label={item.server_label}, tools={[t.name for t in (item.tools or [])]}")
elif item.type == "mcp_call":
print(f"server_label={item.server_label}, name={item.name}, error={item.error}")
else:
print()

print(f"Response: {response.output_text}")

project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version)
print(f"Agent version {agent.version} deleted.")
Comment on lines +68 to +126

inner_mcp_tool = MCPTool(
server_label=INNER_MCP_LABEL,
server_url=INNER_MCP_URL,
require_approval="never",
project_connection_id=os.environ["MCP_PROJECT_CONNECTION_ID"],
)

toolbox_version = await project_client.beta.toolboxes.create_version(
name=TOOLBOX_NAME,
description=f"Toolbox with `{INNER_MCP_LABEL}` MCP server and tool search enabled.",
tools=[inner_mcp_tool, ToolboxSearchPreviewTool()],
)
print(f"Created toolbox `{TOOLBOX_NAME}` (version {toolbox_version.version}).")

toolbox_mcp_url = f"{endpoint}/toolboxes/{TOOLBOX_NAME}/versions/{toolbox_version.version}/mcp?api-version=v1"
token = (await credential.get_token("https://ai.azure.com/.default")).token

toolbox_mcp_tool = MCPTool(
server_label=TOOLBOX_MCP_LABEL,
server_url=toolbox_mcp_url,
authorization=token,
headers={"Foundry-Features": "Toolboxes=V1Preview"},
require_approval="never",
)

agent = await project_client.agents.create_version(
agent_name="MyAgent",
definition=PromptAgentDefinition(
model=os.environ["FOUNDRY_MODEL_NAME"],
instructions=(
"Always use the toolbox search tool to answer questions and perform tasks. "
"Use `tool_search` to discover a relevant tool, then `call_tool` "
"with the tool name returned by the search."
),
tools=[toolbox_mcp_tool],
),
)
print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version}).")

response = await openai_client.responses.create(
input="What is my username in Github profile?",
extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}},
)

for item in response.output:
if item.type == "mcp_approval_request":
print(f"server_label={item.server_label}, name={item.name}")
elif item.type == "mcp_list_tools":
print(f"server_label={item.server_label}, tools={[t.name for t in (item.tools or [])]}")
elif item.type == "mcp_call":
print(f"server_label={item.server_label}, name={item.name}, error={item.error}")
else:
print()

print(f"Response: {response.output_text}")

await project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version)
print(f"Agent version {agent.version} deleted.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants