Skip to content

[agentserver] azure-ai-agentserver -core, -invocation, and -responses packages#45925

Open
lusu-msft wants to merge 58 commits intomainfrom
agentserver/invoke-reponses
Open

[agentserver] azure-ai-agentserver -core, -invocation, and -responses packages#45925
lusu-msft wants to merge 58 commits intomainfrom
agentserver/invoke-reponses

Conversation

@lusu-msft
Copy link
Member

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

lusu-msft and others added 30 commits March 17, 2026 13:03
- added type spec model generation
- add model validator generation
- creating a server
* trying

* generate contract models

* add validator generator

* fix model generation

* add more unit tests

* fix conflict

* refined model generation
* trying

* generate contract models

* add validator generator

* fix model generation

* add more unit tests

* fix conflict

* refined model generation

* renamed the pacakge
* create response

* cancel and delete

* fix options
zhiyong-gayang and others added 2 commits March 25, 2026 15:36
… route registration (#45921)

Replace the standalone map_responses_server() function with a class-based
ResponseHandler that plugs into AgentServer, following the same pattern as
InvocationHandler. This enables multi-protocol composition, unified tracing
via TracingHelper, automatic health probes, graceful shutdown delegation,
and the x-platform-server identity header via hosting middleware.

- Add ResponseHandler class with @create_handler decorator pattern
- Integrate hosting's TracingHelper for OTel spans, W3C propagation, baggage
- Fix Starlette 1.0.0 middleware compatibility in hosting _base.py
- Add MultiProtocol sample showing both protocols on one AgentServer
- Update all tests to use AgentServer + ResponseHandler pattern

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* use handler docorator and refining orchestration

* refining orchestration

* refined orchestration

* fixed conflict and handler registration
@lusu-msft lusu-msft requested a review from msyyc as a code owner March 26, 2026 00:10
Copilot AI review requested due to automatic review settings March 26, 2026 00:10
@github-actions github-actions bot added the Hosted Agents sdk/agentserver/* label Mar 26, 2026
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 introduces new AgentServer protocol packages (hosting, invocations, responses) and supporting infrastructure for streaming response events, request validation, and persistence (including a Foundry-backed storage provider).

Changes:

  • Added azure-ai-agentserver-responses with SSE streaming builders, request/response validation, and Foundry storage provider support.
  • Added azure-ai-agentserver-hosting and azure-ai-agentserver-invocations packages with routing, tracing, shutdown/health handling, samples, and tests.
  • Updated dependency constraints in related agentserver packages.

Reviewed changes

Copilot reviewed 114 out of 195 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/streaming/_builders/_function.py Adds streaming builders for function call and function call output items.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/streaming/_builders/_base.py Introduces base builder lifecycle/state guarding and generic output item builder.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/streaming/_builders/init.py Exposes builder types for streaming output items.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/streaming/init.py Exposes streaming helpers (SSE encoding + lifecycle normalization/validation).
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/store/_foundry_settings.py Adds Foundry storage settings and URL construction helper.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/store/_foundry_serializer.py Adds JSON (de)serialization helpers for Foundry storage envelopes.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/store/_foundry_provider.py Implements an async httpx-based Foundry storage provider.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/store/_foundry_errors.py Adds Foundry storage error hierarchy and HTTP error mapping.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/store/_base.py Defines provider protocols for response persistence and stream replay.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/store/init.py Initializes the responses store package.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/errors.py Adds a request validation error type and conversion to generated API error models.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/sdk/models/py.typed Marks generated models package as typed (PEP 561).
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/sdk/models/models/_patch.py Adds handwritten customization enum for response incomplete reasons.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/sdk/models/_utils/init.py Adds generated utils package marker/init.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/sdk/models/_types.py Adds generated union/alias types for models/events.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/sdk/models/_patch.py Adds placeholder customization hook for generated model-only package.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/sdk/models/init.py Creates model-only generated surface re-exporting generated models.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/_patch.py Adds compatibility shim re-exporting patch helpers.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/_models.py Adds compatibility shim re-exporting generated model symbols.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/_enums.py Adds compatibility shim re-exporting generated enum symbols.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/_generated/init.py Adds compatibility re-exports for generated model package layout.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/init.py Defines public runtime model exports for responses package.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_validation.py Adds request parsing/normalization/validation and API error mapping.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_runtime_state.py Adds in-memory execution state store with async locking.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_routing.py Adds Starlette route wiring for responses endpoints and handler registration.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_request_parsing.py Adds identity/input extraction and cursor pagination utilities.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_observability.py Adds span hooks/recording and identity header helpers for observability.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_http_errors.py Adds HTTP JSON error response factories for responses server.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_execution_context.py Adds per-request immutable execution context container for orchestration.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_event_subject.py Adds in-process replayable subject for SSE event broadcasting.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_background.py Adds background execution helpers and background record status refresh.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/init.py Exposes responses hosting public API surface.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/_version.py Adds package version constant for responses package.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/_options.py Adds responses server options and env-based configuration.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/_handlers.py Adds response handler decorator and ResponseContext contract.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/init.py Defines responses package public API exports.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/init.py Adds namespace package init for agentserver in responses distribution.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/init.py Adds namespace package init for azure.ai in responses distribution.
sdk/agentserver/azure-ai-agentserver-responses/azure/init.py Adds namespace package init for azure in responses distribution.
sdk/agentserver/azure-ai-agentserver-responses/Makefile Adds TypeSpec model generation + validator generation tooling.
sdk/agentserver/azure-ai-agentserver-responses/MANIFEST.in Adds packaging manifest for responses distribution.
sdk/agentserver/azure-ai-agentserver-responses/LICENSE Adds MIT license file for responses distribution.
sdk/agentserver/azure-ai-agentserver-langgraph/pyproject.toml Adds an upper bound on langchain-azure-ai dependency.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_session_id.py Adds tests for session-id header resolution and behavior.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_server_routes.py Adds tests for route registration and OpenAPI serving behavior.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_request_limits.py Adds tests asserting request_timeout removal and lack of timeouts.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_multimodal_protocol.py Adds tests for multiple content types, status codes, SSE, and health endpoint.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_invoke.py Adds tests for invocation flow, headers, streaming, and error behavior.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_graceful_shutdown.py Adds tests for lifespan shutdown handling and graceful shutdown timeout behavior.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_get_cancel.py Adds tests for GET/cancel invocation endpoints and error cases.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_decorator_pattern.py Adds tests for decorator registration patterns and default handler behavior.
sdk/agentserver/azure-ai-agentserver-invocations/tests/conftest.py Adds shared fixtures and test agent factories for invocations tests.
sdk/agentserver/azure-ai-agentserver-invocations/samples/simple_invoke_agent/simple_invoke_agent.py Adds a minimal invocations sample agent.
sdk/agentserver/azure-ai-agentserver-invocations/samples/simple_invoke_agent/requirements.txt Adds sample requirements for simple invocations agent.
sdk/agentserver/azure-ai-agentserver-invocations/samples/async_invoke_agent/requirements.txt Adds sample requirements for async invocations agent.
sdk/agentserver/azure-ai-agentserver-invocations/samples/async_invoke_agent/async_invoke_agent.py Adds long-running invocation sample with get/cancel patterns.
sdk/agentserver/azure-ai-agentserver-invocations/pyrightconfig.json Adds pyright configuration for invocations package.
sdk/agentserver/azure-ai-agentserver-invocations/pyproject.toml Adds packaging + lint/typecheck config for invocations distribution.
sdk/agentserver/azure-ai-agentserver-invocations/dev_requirements.txt Adds dev dependencies for invocations package testing/tooling.
sdk/agentserver/azure-ai-agentserver-invocations/cspell.json Adds spelling ignore list and paths for invocations package.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/agentserver/invocations/_version.py Adds package version constant for invocations.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/agentserver/invocations/_constants.py Adds protocol constants for headers and tracing attributes.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/agentserver/invocations/init.py Adds public API exports for invocations package.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/agentserver/init.py Adds namespace package init for agentserver in invocations distribution.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/init.py Adds namespace package init for azure.ai in invocations distribution.
sdk/agentserver/azure-ai-agentserver-invocations/azure/init.py Adds namespace package init for azure in invocations distribution.
sdk/agentserver/azure-ai-agentserver-invocations/README.md Adds invocations package README with usage, concepts, and samples.
sdk/agentserver/azure-ai-agentserver-invocations/MANIFEST.in Adds packaging manifest for invocations distribution.
sdk/agentserver/azure-ai-agentserver-invocations/LICENSE Adds MIT license file for invocations distribution.
sdk/agentserver/azure-ai-agentserver-invocations/CHANGELOG.md Adds initial changelog for invocations distribution.
sdk/agentserver/azure-ai-agentserver-hosting/tests/test_tracing.py Adds tests for tracing enablement/config and baggage parsing.
sdk/agentserver/azure-ai-agentserver-hosting/tests/test_server_routes.py Adds tests for port resolution and unknown-route handling.
sdk/agentserver/azure-ai-agentserver-hosting/tests/test_logger.py Adds tests verifying logger naming and level preservation.
sdk/agentserver/azure-ai-agentserver-hosting/tests/test_health.py Adds tests for /healthy endpoint behavior and removed endpoints.
sdk/agentserver/azure-ai-agentserver-hosting/tests/test_edge_cases.py Adds edge-case tests for logging config, invalid values, and /healthy behavior.
sdk/agentserver/azure-ai-agentserver-hosting/tests/conftest.py Adds shared fixtures for hosting tests.
sdk/agentserver/azure-ai-agentserver-hosting/samples/selfhosted_invocation/selfhosted_invocation.py Adds sample implementing invocations protocol directly with hosting primitives.
sdk/agentserver/azure-ai-agentserver-hosting/samples/selfhosted_invocation/requirements.txt Adds sample requirements for self-hosted invocation sample.
sdk/agentserver/azure-ai-agentserver-hosting/pyrightconfig.json Adds pyright configuration for hosting package.
sdk/agentserver/azure-ai-agentserver-hosting/pyproject.toml Adds packaging + lint/typecheck config for hosting distribution.
sdk/agentserver/azure-ai-agentserver-hosting/dev_requirements.txt Adds dev dependencies for hosting package testing/tooling.
sdk/agentserver/azure-ai-agentserver-hosting/cspell.json Adds spelling ignore list and paths for hosting package.
sdk/agentserver/azure-ai-agentserver-hosting/azure/ai/agentserver/hosting/_version.py Adds package version constant for hosting.
sdk/agentserver/azure-ai-agentserver-hosting/azure/ai/agentserver/hosting/_logger.py Adds logger facade for AgentServer packages.
sdk/agentserver/azure-ai-agentserver-hosting/azure/ai/agentserver/hosting/_errors.py Adds standardized JSON error envelope helper.
sdk/agentserver/azure-ai-agentserver-hosting/azure/ai/agentserver/hosting/_constants.py Adds hosting constants/env vars and defaults.
sdk/agentserver/azure-ai-agentserver-hosting/azure/ai/agentserver/hosting/_config.py Adds configuration resolution helpers (port/logging/tracing/shutdown).
sdk/agentserver/azure-ai-agentserver-hosting/azure/ai/agentserver/hosting/init.py Adds hosting public API exports.
sdk/agentserver/azure-ai-agentserver-hosting/azure/ai/agentserver/init.py Adds namespace package init for agentserver in hosting distribution.
sdk/agentserver/azure-ai-agentserver-hosting/azure/ai/init.py Adds namespace package init for azure.ai in hosting distribution.
sdk/agentserver/azure-ai-agentserver-hosting/azure/init.py Adds namespace package init for azure in hosting distribution.
sdk/agentserver/azure-ai-agentserver-hosting/README.md Adds hosting package README with usage and examples.
sdk/agentserver/azure-ai-agentserver-hosting/MANIFEST.in Adds packaging manifest for hosting distribution.
sdk/agentserver/azure-ai-agentserver-hosting/LICENSE Adds MIT license file for hosting distribution.
sdk/agentserver/azure-ai-agentserver-hosting/CHANGELOG.md Adds initial changelog for hosting distribution.
sdk/agentserver/azure-ai-agentserver-core/pyproject.toml Adds upper bound for Starlette dependency.
sdk/agentserver/azure-ai-agentserver-agentframework/pyproject.toml Adds dependency on opentelemetry semantic conventions for AI.

@@ -0,0 +1,60 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""Public API surface for the Azure AI Agent Server Responses package."""
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The PR description is still the default template (“Please add an informative description...”) and doesn’t explain the changes or link relevant issues/spec PRs. Please update the PR description to summarize the added packages (hosting/invocations/responses), call out any behavioral changes, and link related issues/spec changes.

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +32
class ResponseHandler:
"""Response protocol handler that plugs into an ``AgentServer``.
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

A large amount of new azure-ai-agentserver-responses functionality is introduced (routing, validation, background execution, storage providers, SSE replay), but no tests are included for this package in the diff. Please add unit tests that cover at least: (1) request parsing/validation error mapping, (2) route wiring (create/get/delete/cancel/input_items), and (3) basic provider interaction behavior (e.g., in-memory provider path). This repo already uses pytest extensively for the hosting/invocations packages, so adding similar coverage here should be straightforward.

Copilot uses AI. Check for mistakes.
Comment on lines +106 to +113
return _api_error(
message=f"Response with id '{response_id}' not found.",
code="invalid_request",
param="response_id",
error_type="invalid_request_error",
status_code=404,
headers=headers,
)
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

_not_found returns HTTP 404 but sets the error envelope to code="invalid_request" and error_type="invalid_request_error". This makes 404s indistinguishable from 400s for clients relying on the structured error shape. Consider using code="not_found" and error_type="not_found_error" here (or delegating to build_not_found_error_response) so the payload matches the HTTP status semantics.

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +32
self._events: list[dict[str, Any]] = []
self._subscribers: list[asyncio.Queue[Any]] = []
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Each subscriber gets an unbounded asyncio.Queue, and publish() uses put_nowait() without any backpressure. A slow (or stuck) subscriber can cause unbounded memory growth as events accumulate in its queue, potentially leading to OOM in production. Consider using bounded queues (with a policy to drop/disconnect slow consumers), or implementing backpressure/flow-control so publishers cannot outpace subscribers indefinitely.

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +45
self._events.append(event)
for q in self._subscribers:
q.put_nowait(event)
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Each subscriber gets an unbounded asyncio.Queue, and publish() uses put_nowait() without any backpressure. A slow (or stuck) subscriber can cause unbounded memory growth as events accumulate in its queue, potentially leading to OOM in production. Consider using bounded queues (with a policy to drop/disconnect slow consumers), or implementing backpressure/flow-control so publishers cannot outpace subscribers indefinitely.

Copilot uses AI. Check for mistakes.
Comment on lines +58 to +61
url = f"{self.storage_base_url}{path}?api-version={_encode(_API_VERSION)}"
for key, value in extra_params.items():
url += f"&{key}={_encode(value)}"
return url
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

build_url() manually constructs query strings via string concatenation. This is error-prone (e.g., key names aren’t encoded, path may include a ?, and future params may be list-valued). Consider switching to urllib.parse.urlencode (or httpx.URL.copy_with(params=...)) to build query parameters robustly and consistently.

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +234
agent_reference = _normalize_agent_reference(
parsed_mapping.get("agent_reference") \
if isinstance(parsed_mapping, dict) \
else getattr(parsed, "agent_reference", None)
)
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The use of backslash continuations inside parentheses is unnecessary here and makes the expression harder to read and maintain. Reformatting this conditional expression without backslashes (or assigning the candidate to a local variable first) would improve clarity without changing behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +6
# ---------------------------------------------------------

Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This PR adds a new package (azure-ai-agentserver-responses) with a public API surface, but no CHANGELOG.md for that package is included in the diff (unlike hosting/invocations). Please add a CHANGELOG entry for the initial beta release (features, notable behaviors like SSE/Foundry provider, and any known limitations) to align with Azure SDK release practices.

Suggested change
# ---------------------------------------------------------
# ---------------------------------------------------------
"""Package version information for azure-ai-agentserver-responses.
This module defines the package version for the azure-ai-agentserver-responses
client library.
Initial beta release (1.0.0b1)
------------------------------
- Introduces response models and helpers for Azure AI Agent Server scenarios.
- Supports handling of responses over Server-Sent Events (SSE) streams, enabling
incremental payload consumption by higher-level clients.
- Designed to interoperate with the Azure AI Foundry provider and related
orchestration components.
Known limitations
-----------------
- API surface and wire models are subject to breaking changes in future beta
releases as the agent server protocol stabilizes.
- Not all potential response shapes and error conditions are modeled yet; callers
should be prepared to handle forward-compatible fields.
- This module only exposes the version constant; refer to the package
CHANGELOG.md for detailed release notes when available.
"""

Copilot uses AI. Check for mistakes.
* use handler docorator and refining orchestration

* refining orchestration

* refined orchestration

* fixed conflict and handler registration

* fix replay
* fixed docstirng. refined ResponseContext

* refined context

* add payload helpers

* use dict for contract
* fixed docstirng. refined ResponseContext

* refined context

* add payload helpers

* use dict for contract

* fix inmemory

* fix helper and sample
DEFAULT_PORT = 8088

# Logging
AGENT_LOG_LEVEL = "AGENT_LOG_LEVEL"

Choose a reason for hiding this comment

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

AGENT_LOG_LEVEL is not part of the container spec.


# Graceful shutdown
AGENT_GRACEFUL_SHUTDOWN_TIMEOUT = "AGENT_GRACEFUL_SHUTDOWN_TIMEOUT"
DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT = 30

Choose a reason for hiding this comment

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

AGENT_GRACEFUL_SHUTDOWN_TIMEOUT , DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT are not part of the container spec.

@@ -0,0 +1,40 @@
"""Simple invoke agent example.

Choose a reason for hiding this comment

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

Align to samples here that show various patterns devs can implement using invocations api shape.
https://github.com/Azure/azure-sdk-for-net/tree/31d388bf24969ce009e7de0b7d0c539517f74ee5/sdk/agentserver/Azure.AI.AgentServer.Invocations/samples

@lusu-msft lusu-msft changed the title [agentserver] azure-ai-agentserver -hosting, -invocation, and -responses packages [agentserver] azure-ai-agentserver -core, -invocation, and -responses packages Mar 26, 2026
Copy link
Contributor

Copilot AI commented Mar 26, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pypi.org
    • Triggering command: /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/pip pip install isodate -q (dns block)
  • scanning-api.github.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Member

@pvaneck pvaneck left a comment

Choose a reason for hiding this comment

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

Let's also add a CHANGELOG.md file with a ## 1.0.0b1 (Unreleased) section.

- `TracingHelper` for OpenTelemetry tracing with Azure Monitor and OTLP exporters.
- Auto-enable tracing when Application Insights or OTLP endpoint is configured.
- W3C Trace Context propagation and `leaf_customer_span_id` baggage re-parenting.
- `error_response()` utility for standard error envelope responses.
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the actual API is ErrorResponse.create(). Same with AgentLogger.get() for get_logger(). A module-level function instead of a class with a single static method is probably preferred in Python. Did you get feedback regarding this?

- W3C Trace Context propagation and `leaf_customer_span_id` baggage re-parenting.
- `error_response()` utility for standard error envelope responses.
- `get_logger()` for library-scoped logging.
- `StructuredLogFilter` and `LogScope` for per-request structured logging.
Copy link
Member

Choose a reason for hiding this comment

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

These two don't exist in the code base.

### Features Added

First version
- Renamed package from `azure-ai-agentserver-hosting` to `azure-ai-agentserver-core`.
Copy link
Member

Choose a reason for hiding this comment

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

Don't think this line is necessary. Will just need to add details to a breaking changes section regarding the new APIs.

You can talk to your agent using azure-ai-project sdk.
Protocol packages (e.g. `azure-ai-agentserver-invocations`) plug into `AgentHost` by calling `register_routes()` to add their endpoints.

### Environment variables
Copy link
Member

Choose a reason for hiding this comment

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

Should FOUNDRY_PROJECT_ARM_ID or FOUNDRY_AGENT_SESSION_ID also be added to this table?

_conn_str = _config.resolve_appinsights_connection_string(application_insights_connection_string)
_otlp_endpoint = _config.resolve_otlp_endpoint()
_tracing_on = bool(_conn_str or _otlp_endpoint)
self._tracing: Optional[TracingHelper] = (
Copy link
Member

Choose a reason for hiding this comment

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

Consider wrapping the TracingHelper instantiation in a try/except if we want this to be non-fatal if tracing setup fails for some reason (maybe emitting a warning and setting self._tracing = None).

"azure-identity>=1.15.0",
"httpx>=0.27",
"isodate>=0.6.1",
"starlette>=1.0.0rc1,<2.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

Should we unify the starlette dependency versions with the one in agentserver-core for consistency? Looks like 1.0.0 was also released recently.

from starlette.applications import Starlette
from starlette.responses import JSONResponse
from azure.ai.agentserver.responses import ResponseEventStream
from azure.ai.agentserver.responses.hosting import map_responses_server
Copy link
Member

Choose a reason for hiding this comment

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

map_responses_server appears to no longer exist. What should this be instead?

@@ -0,0 +1,59 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""Public API surface for the Azure AI Agent Server Responses package."""
Copy link
Member

Choose a reason for hiding this comment

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

Need to also ensure we set __version__ here.

from ._version import VERSION

__version__ = VERSION

self._credential = credential
self._settings = settings or FoundryStorageSettings.from_env()
self._owns_client = http_client is None
self._http_client = http_client if http_client is not None else httpx.AsyncClient()
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to not use azure.core.AsyncPipelineClient instead of raw httpx? This would enable retrying, logging, auth, etc.


from azure.ai.agentserver.core import AgentHost
from azure.ai.agentserver.responses._response_context import ResponseContext
from azure.ai.agentserver.responses.models._generated.sdk.models._types import InputParam
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, we don't use any private imports in the samples. Can we use only public imports in all the sample files?

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

Labels

Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants