Skip to content

[agentserver] azure-ai-agentserver-responses package#46052

Open
ankitbko wants to merge 90 commits intomainfrom
agentserver/responses
Open

[agentserver] azure-ai-agentserver-responses package#46052
ankitbko wants to merge 90 commits intomainfrom
agentserver/responses

Conversation

@ankitbko
Copy link
Copy Markdown
Member

@ankitbko ankitbko commented Apr 1, 2026

Description

Split from PR #45925 for independent review of the azure-ai-agentserver-responses package.

This PR builds on the core+invocations changes in #45925 and adds the responses protocol implementation including:

  • Hosting: Starlette-based ASGI routing, request validation, background execution, SSE streaming
  • Storage: Foundry storage provider using azure.core.AsyncPipelineClient, in-memory provider for testing
  • Streaming: Response event stream builders for messages, function calls, reasoning
  • Models: TypeSpec-generated models with validation

Dependencies


Carried-over review threads from #45925

The following unresolved review threads were moved from the original PR. They all target code in this package.

Code fixes needed (copilot-reviewer)

File Issue
_http_errors.py _not_found returns 404 but uses code="invalid_request" — should use code="not_found" and error_type="not_found_error"
_handlers.py response_handler validates parameter count but does not validate handler is async def or returns AsyncIterable
_foundry_serializer.py serialize_create_request calls .as_dict() unconditionally — breaks if a dict is passed instead of a model
_base.py ResponseProviderProtocol docstrings specify KeyError but Foundry provider raises FoundryResourceNotFoundError (2 threads, duplicate)
_runtime_state.py O(n²) history concatenation via [*A, *history] — use deque or accumulate-then-concat
_event_subject.py Unbounded asyncio.Queue per subscriber with no backpressure — can cause OOM (2 threads, duplicate)
_foundry_settings.py build_url() uses manual string concatenation — switch to urllib.parse.urlencode
_request_parsing.py Unnecessary backslash continuations inside parentheses — reformat for clarity

Design/architecture (johanste)

File Issue
_routing.py Routing/hosting restructure — see comment. johanste proposes ResponseHandler should inherit from AgentHost to be the host entry point
samples/GetStarted/app.py Samples should not need to import anything from core
samples/GetStarted/app.py ResponseHandler should be the "host" — users should not need AgentHost directly

Samples (RaviPidaparthi)

File Issue
samples/README.md Need more samples: Tier 1/2/3 experience, OpenAI client integration. Reference: .NET samples

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 13 commits March 31, 2026 00:26
The latest opentelemetry-sdk added _on_ending to the SpanProcessor
interface, causing AttributeError at runtime. Add the required no-op
method to fix compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…_id resolution and stamping)

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/40114cbe-e583-4912-abc7-75c551a7e12c

Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
… private imports, simplify model access in samples

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/40114cbe-e583-4912-abc7-75c551a7e12c

Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
…n hint priority, add invalid header test

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/40114cbe-e583-4912-abc7-75c551a7e12c

Co-authored-by: ankitbko <3169316+ankitbko@users.noreply.github.com>
* update otel

* refined readme

* updated model validator

* fix model
…cing dupe protection

Thread 17: Replace ErrorResponse.create() with create_error_response() and
AgentLogger.get() with get_logger() module-level functions. Updated all call
sites across core, invocations, and responses packages.

Thread 18: Added Breaking Changes section to CHANGELOG.md documenting the API
renames, removed constants, and health endpoint rename.

Thread 21: Added module-level sentinel flags to _setup_trace_export,
_setup_log_export, _setup_otlp_trace_export, and _setup_otlp_log_export to
prevent duplicate exporters across multiple TracingHelper instantiations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ider

Migrated FoundryStorageProvider from raw httpx.AsyncClient to
azure.core.AsyncPipelineClient, gaining built-in retry, logging,
distributed tracing, and bearer-token authentication via
AsyncBearerTokenCredentialPolicy.

- Removed manual _auth_headers() — handled by pipeline policy
- Removed http_client constructor parameter — pipeline is internal
- Updated _foundry_errors.py to use azure.core.rest.HttpResponse
- Removed httpx from pyproject.toml dependencies
- Updated all unit tests to mock send_request instead of httpx methods

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CreateResponse always has a model attribute, so the defensive
getattr is unnecessary boilerplate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Responses package has been split into a separate PR on the
agentserver/responses branch for independent review and iteration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added the Hosted Agents sdk/agentserver/* label Apr 1, 2026
@ankitbko ankitbko changed the base branch from agentserver/invoke-reponses to main April 1, 2026 11:12
Ankit Sinha and others added 3 commits April 1, 2026 13:40
…langgraph from main

These packages were inadvertently removed in an earlier commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ly (#46069)

Add set_current_span/detach_context to TracingHelper so the invoke_agent
span is attached as the active OTel context span. This ensures child spans
created by framework handlers are parented under invoke_agent instead of
appearing as siblings.

- TracingHelper.set_current_span() attaches the span to context
- TracingHelper.detach_context() restores the previous context
- InvocationHandler propagates span_token through both streaming and
  non-streaming cleanup paths
- Added test_span_parenting.py to verify parent-child relationship

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: set OTel span as current context for proper parent-child span relationships

The responses handler creates the OTel span via start_request_span() which
uses start_span() internally - a detached span not set as the active context.
This causes child spans from user handler code (e.g. Agent Framework) to appear
as separate root spans instead of children.

Use set_current_span() after creating the span so downstream code sees it as
the active parent. Detach the context when streaming completes or in the
finally block for non-streaming paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: rename span operation from create_response to invoke_agent

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: use agent name in span name instead of model name

The span name is now 'invoke_agent {name}:{version}' matching the
pattern used by Microsoft Agent Framework.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 03:23
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

This PR introduces the new azure-ai-agentserver-responses package (split out for independent review) and concurrently refactors packaging/hosting infrastructure across the agentserver repo (core + invocations), including significant removals of the previous langgraph/agentframework adapters and samples.

Changes:

  • Added Responses server hosting primitives (execution context, replayable SSE event subject, ResponseContext, and server options) plus public exports and packaging metadata.
  • Refactored azure-ai-agentserver-core and introduced azure-ai-agentserver-invocations protocol package with updated packaging metadata, new tests, and new samples.
  • Removed the LangGraph and Agent Framework adapter packages’ code/tests/samples and associated metadata files from the repo.

Reviewed changes

Copilot reviewed 196 out of 325 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_execution_context.py New per-request execution context object for Responses orchestration.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_event_subject.py New in-process replay subject for SSE event broadcasting.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/init.py Public exports for hosting/routing/validation helpers.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/_version.py Defines the package version constant.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/_response_context.py Adds ResponseContext runtime object for handlers + history/input access.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/_options.py Adds strongly-typed server options + env parsing/validation.
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/init.py Public API surface exports for responses package.
sdk/agentserver/azure-ai-agentserver-responses/MANIFEST.in Ensures py.typed is packaged for responses.
sdk/agentserver/azure-ai-agentserver-responses/CHANGELOG.md Adds responses package changelog entry for initial beta.
sdk/agentserver/azure-ai-agentserver-langgraph/tests/unit_tests/test_langgraph_request_converter.py Removed LangGraph adapter unit tests (package removal).
sdk/agentserver/azure-ai-agentserver-langgraph/tests/conftest.py Removed LangGraph adapter test harness (package removal).
sdk/agentserver/azure-ai-agentserver-langgraph/tests/init.py Removed LangGraph adapter tests package marker.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/simple_react_agent/requirements.txt Removed LangGraph sample dependency list.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/simple_react_agent/main.py Removed LangGraph sample agent entrypoint.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/simple_react_agent/.env-template Removed LangGraph sample env template.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/simple_agent_with_redis_checkpointer/requirements.txt Removed LangGraph Redis sample dependencies.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/simple_agent_with_redis_checkpointer/main.py Removed LangGraph Redis sample entrypoint.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/simple_agent_with_redis_checkpointer/README.md Removed LangGraph Redis sample docs.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/simple_agent_with_redis_checkpointer/.env-template Removed LangGraph Redis env template.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/mcp_simple/requirements.txt Removed LangGraph MCP sample dependencies.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/mcp_simple/mcp_simple.py Removed LangGraph MCP sample script.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/mcp_simple/README.md Removed LangGraph MCP sample docs.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/mcp_simple/.env-template Removed LangGraph MCP env template.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/mcp_apikey/requirements.txt Removed LangGraph MCP API-key sample dependencies.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/mcp_apikey/mcp_apikey.py Removed LangGraph MCP API-key sample script.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/mcp_apikey/README.md Removed LangGraph MCP API-key sample docs.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/mcp_apikey/.env-template Removed LangGraph MCP API-key env template.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/custom_state/requirements.txt Removed LangGraph custom state sample dependencies.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/custom_state/README.md Removed LangGraph custom state sample docs.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/custom_state/.env-template Removed LangGraph custom state env template.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agentic_rag/workflow.py Removed LangGraph agentic RAG sample workflow.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agentic_rag/tools/retriever_tool.py Removed LangGraph agentic RAG retriever tool.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agentic_rag/requirements.txt Removed LangGraph agentic RAG dependencies.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agentic_rag/nodes/rewrite_question.py Removed LangGraph agentic RAG node.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agentic_rag/nodes/generate_query_or_respond.py Removed LangGraph agentic RAG node.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agentic_rag/nodes/generate_answer.py Removed LangGraph agentic RAG node.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agentic_rag/edges/grade_documents.py Removed LangGraph agentic RAG edge logic.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agentic_rag/.env-template Removed LangGraph agentic RAG env template.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agent_calculator/requirements.txt Removed LangGraph calculator sample dependencies.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agent_calculator/langgraph_agent_calculator.py Removed LangGraph calculator sample implementation.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agent_calculator/README.md Removed LangGraph calculator sample docs.
sdk/agentserver/azure-ai-agentserver-langgraph/samples/agent_calculator/.env-template Removed LangGraph calculator env template.
sdk/agentserver/azure-ai-agentserver-langgraph/mypy.ini Removed LangGraph package mypy config.
sdk/agentserver/azure-ai-agentserver-langgraph/cspell.json Removed LangGraph package spell config.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/utils.py Removed LangGraph adapter model utilities.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/response_event_generators/response_stream_event_generator.py Removed LangGraph stream event generator impl.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/response_event_generators/response_output_text_event_generator.py Removed LangGraph output text generator impl.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/response_event_generators/response_function_call_argument_event_generator.py Removed LangGraph function-call generator impl.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/response_event_generators/response_event_generator.py Removed LangGraph generator base classes.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/response_event_generators/response_content_part_event_generator.py Removed LangGraph content part generator impl.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/response_event_generators/item_resource_helpers.py Removed LangGraph item resource helper impl.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/response_event_generators/item_content_helpers.py Removed LangGraph item content helper impl.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/response_event_generators/init.py Removed LangGraph event generator exports.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/langgraph_stream_response_converter.py Removed LangGraph stream response converter.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/langgraph_state_converter.py Removed LangGraph state converter interfaces.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/langgraph_response_converter.py Removed LangGraph non-stream response converter.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/langgraph_request_converter.py Removed LangGraph request converter.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/models/init.py Removed LangGraph model exports.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/langgraph.py Removed LangGraph adapter runtime.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/agentserver/langgraph/init.py Removed LangGraph package init/export surface.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/ai/init.py Removed LangGraph namespace marker.
sdk/agentserver/azure-ai-agentserver-langgraph/azure/init.py Removed LangGraph namespace marker.
sdk/agentserver/azure-ai-agentserver-langgraph/README.md Removed LangGraph package readme.
sdk/agentserver/azure-ai-agentserver-langgraph/CHANGELOG.md Removed LangGraph package changelog.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_session_id.py New tests for session ID resolution + headers.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_server_routes.py New tests for route registration + OpenAPI route behavior.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_request_limits.py New tests ensuring request timeout feature is removed.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_invoke.py New tests for invoke dispatch, streaming, headers, errors.
sdk/agentserver/azure-ai-agentserver-invocations/tests/test_get_cancel.py New tests for GET/cancel flows and error behavior.
sdk/agentserver/azure-ai-agentserver-invocations/samples/streaming_invoke_agent/streaming_invoke_agent.py Added SSE streaming sample agent.
sdk/agentserver/azure-ai-agentserver-invocations/samples/streaming_invoke_agent/requirements.txt Added minimal requirements for streaming invocation sample.
sdk/agentserver/azure-ai-agentserver-invocations/samples/simple_invoke_agent/simple_invoke_agent.py Added minimal JSON invoke sample agent.
sdk/agentserver/azure-ai-agentserver-invocations/samples/simple_invoke_agent/requirements.txt Added minimal requirements for simple invoke sample.
sdk/agentserver/azure-ai-agentserver-invocations/samples/multiturn_invoke_agent/requirements.txt Added requirements for multi-turn invoke sample.
sdk/agentserver/azure-ai-agentserver-invocations/samples/multiturn_invoke_agent/multiturn_invoke_agent.py Added multi-turn session demo sample agent.
sdk/agentserver/azure-ai-agentserver-invocations/samples/async_invoke_agent/requirements.txt Added requirements for async invoke sample.
sdk/agentserver/azure-ai-agentserver-invocations/pyrightconfig.json Updated pyright settings and exclusions.
sdk/agentserver/azure-ai-agentserver-invocations/pyproject.toml Renamed/re-scoped the project to invocations + updated build tooling flags.
sdk/agentserver/azure-ai-agentserver-invocations/dev_requirements.txt Added dev requirements for invocations package testing/tooling.
sdk/agentserver/azure-ai-agentserver-invocations/cspell.json Added spell checker config for invocations package.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/agentserver/invocations/_version.py Added invocations version constant.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/agentserver/invocations/_constants.py Added protocol constants for invocations.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/agentserver/invocations/init.py Added invocations public package surface and docs.
sdk/agentserver/azure-ai-agentserver-invocations/azure/ai/agentserver/init.py Adjusted namespace path init.
sdk/agentserver/azure-ai-agentserver-invocations/MANIFEST.in Updated typed marker inclusion for invocations package.
sdk/agentserver/azure-ai-agentserver-invocations/LICENSE Normalized license text formatting.
sdk/agentserver/azure-ai-agentserver-invocations/CHANGELOG.md Added invocations package changelog for initial beta.
sdk/agentserver/azure-ai-agentserver-core/tests/test_server_routes.py Added core tests for port resolution and 404 behavior.
sdk/agentserver/azure-ai-agentserver-core/tests/test_logger.py Added tests ensuring logger behavior is stable.
sdk/agentserver/azure-ai-agentserver-core/tests/test_health.py Added tests for readiness endpoint behavior.
sdk/agentserver/azure-ai-agentserver-core/tests/test_edge_cases.py Added tests for log level behaviors and edge cases.
sdk/agentserver/azure-ai-agentserver-core/tests/env-template Removed legacy env template.
sdk/agentserver/azure-ai-agentserver-core/samples/simple_mock_agent/requirements.txt Removed legacy sample requirements.
sdk/agentserver/azure-ai-agentserver-core/samples/simple_mock_agent/custom_mock_agent_test.py Removed legacy sample code.
sdk/agentserver/azure-ai-agentserver-core/samples/selfhosted_invocation/selfhosted_invocation.py Added “tier 3” self-hosting invocation sample.
sdk/agentserver/azure-ai-agentserver-core/samples/selfhosted_invocation/requirements.txt Added requirements for self-hosted invocation sample.
sdk/agentserver/azure-ai-agentserver-core/samples/mcp_simple/requirements.txt Removed legacy MCP sample requirements.
sdk/agentserver/azure-ai-agentserver-core/samples/bilingual_weekend_planner/run.sh Removed legacy runner script.
sdk/agentserver/azure-ai-agentserver-core/samples/bilingual_weekend_planner/requirements.txt Removed legacy weekend planner deps.
sdk/agentserver/azure-ai-agentserver-core/samples/bilingual_weekend_planner/README.md Removed legacy weekend planner docs.
sdk/agentserver/azure-ai-agentserver-core/samples/bilingual_weekend_planner/.env.sample Removed legacy env sample.
sdk/agentserver/azure-ai-agentserver-core/pyrightconfig.json Updated pyright exclusions.
sdk/agentserver/azure-ai-agentserver-core/pyproject.toml Updated project metadata, deps, and build tool flags.
sdk/agentserver/azure-ai-agentserver-core/doc/azure.ai.agentserver.core.server.rst Removed legacy Sphinx docs.
sdk/agentserver/azure-ai-agentserver-core/doc/azure.ai.agentserver.core.server.common.rst Removed legacy Sphinx docs.
sdk/agentserver/azure-ai-agentserver-core/doc/azure.ai.agentserver.core.server.common.id_generator.rst Removed legacy Sphinx docs.
sdk/agentserver/azure-ai-agentserver-core/doc/azure.ai.agentserver.core.rst Removed legacy Sphinx docs.
sdk/agentserver/azure-ai-agentserver-core/dev_requirements.txt Updated dev requirements to align with new test stack.
sdk/agentserver/azure-ai-agentserver-core/cspell.json Updated spell checker config for core package.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/server/common/id_generator/id_generator.py Removed legacy ID generator interface.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/server/common/id_generator/foundry_id_generator.py Removed legacy Foundry ID generator implementation.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/server/common/agent_run_context.py Removed legacy AgentRunContext implementation.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/models/projects/_patch_evaluations.py Removed legacy generated patch customizations.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/models/projects/_patch.py Removed legacy generated patch entrypoint.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/models/openai/init.py Removed OpenAI SDK re-export module.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/models/_create_response.py Removed legacy CreateResponse TypedDict.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/models/init.py Removed legacy models package exports.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/logger.py Removed legacy logging/configure module.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/constants.py Removed legacy constants module.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/_version.py Updated core version to 2.0.0b1.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/_logger.py Added lightweight logger facade get_logger().
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/_errors.py Added standardized error response envelope builder.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/_constants.py Added new constants enum for env vars/defaults.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/init.py Reworked core public API surface and removed implicit logging side-effects.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/init.py Adjusted namespace path init.
sdk/agentserver/azure-ai-agentserver-core/azure/ai/init.py Adjusted namespace path init.
sdk/agentserver/azure-ai-agentserver-core/azure/init.py Adjusted namespace path init.
sdk/agentserver/azure-ai-agentserver-core/MANIFEST.in Removed doc packaging include; kept samples/tests.
sdk/agentserver/azure-ai-agentserver-core/LICENSE Normalized license text formatting.
sdk/agentserver/azure-ai-agentserver-core/CHANGELOG.md Added core 2.0.0b1 changelog with features + breaking changes.
sdk/agentserver/azure-ai-agentserver-agentframework/tests/unit_tests/test_agent_framework_input_converter.py Removed Agent Framework adapter tests (package removal).
sdk/agentserver/azure-ai-agentserver-agentframework/tests/conftest.py Removed Agent Framework adapter test harness.
sdk/agentserver/azure-ai-agentserver-agentframework/tests/init.py Removed Agent Framework tests package marker.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/workflow_agent_simple/requirements.txt Removed Agent Framework samples dependencies.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/workflow_agent_simple/.envtemplate Removed Agent Framework sample env template.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/simple_async/requirements.txt Removed Agent Framework sample deps.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/simple_async/minimal_async_example.py Removed Agent Framework sample script.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/simple_async/README.md Removed Agent Framework sample docs.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/simple_async/.envtemplate Removed Agent Framework env template.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/mcp_simple/requirements.txt Removed Agent Framework MCP sample deps.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/mcp_simple/mcp_simple.py Removed Agent Framework MCP sample script.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/mcp_simple/.envtemplate Removed Agent Framework MCP env template.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/mcp_apikey/requirements.txt Removed Agent Framework MCP API-key sample deps.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/mcp_apikey/mcp_apikey.py Removed Agent Framework MCP API-key sample script.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/mcp_apikey/README.md Removed Agent Framework MCP API-key docs.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/mcp_apikey/.envtemplate Removed Agent Framework MCP API-key env template.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/basic_simple/requirements.txt Removed Agent Framework basic sample deps.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/basic_simple/minimal_example.py Removed Agent Framework basic sample script.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/basic_simple/README.md Removed Agent Framework basic sample docs.
sdk/agentserver/azure-ai-agentserver-agentframework/samples/basic_simple/.envtemplate Removed Agent Framework basic env template.
sdk/agentserver/azure-ai-agentserver-agentframework/pyrightconfig.json Removed Agent Framework pyright config.
sdk/agentserver/azure-ai-agentserver-agentframework/pyproject.toml Removed Agent Framework packaging metadata.
sdk/agentserver/azure-ai-agentserver-agentframework/dev_requirements.txt Removed Agent Framework dev requirements.
sdk/agentserver/azure-ai-agentserver-agentframework/cspell.json Removed Agent Framework spell config.
sdk/agentserver/azure-ai-agentserver-agentframework/azure/ai/agentserver/agentframework/models/constants.py Removed Agent Framework adapter runtime constants.
sdk/agentserver/azure-ai-agentserver-agentframework/azure/ai/agentserver/agentframework/models/agent_id_generator.py Removed Agent Framework adapter helpers.
sdk/agentserver/azure-ai-agentserver-agentframework/azure/ai/agentserver/agentframework/models/agent_framework_input_converters.py Removed Agent Framework input converter impl.
sdk/agentserver/azure-ai-agentserver-agentframework/azure/ai/agentserver/agentframework/agent_framework.py Removed Agent Framework adapter runtime implementation.
sdk/agentserver/azure-ai-agentserver-agentframework/azure/ai/agentserver/agentframework/init.py Removed Agent Framework package init/export surface.
sdk/agentserver/azure-ai-agentserver-agentframework/README.md Removed Agent Framework package readme.
sdk/agentserver/azure-ai-agentserver-agentframework/CHANGELOG.md Removed Agent Framework package changelog.

Comment on lines +52 to +58
self._provider: "ResponseProviderProtocol | None" = provider
self._input_items: list[InputParam] = list(input_items) if input_items is not None else []
self._previous_response_id: str | None = previous_response_id
self.conversation_id: str | None = conversation_id
self._history_limit: int = history_limit
self._input_items_cache: Sequence[OutputItem] | None = None
self._history_cache: Sequence[OutputItem] | None = None
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

_input_items_cache is typed as Sequence[OutputItem], but get_input_items_async() caches and returns InputParam values. This is an internal type mismatch that will confuse type-checkers and can mask real bugs. Change _input_items_cache to Sequence[InputParam] | None.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +34
def __init__(self) -> None:
"""Initialise the subject with an empty event buffer and no subscribers."""
self._events: list[dict[str, Any]] = []
self._subscribers: list[asyncio.Queue[Any]] = []
self._done: bool = False
self._lock: asyncio.Lock = asyncio.Lock()
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

_events (replay buffer) and each subscriber queue are unbounded, so a slow/paused SSE client can cause unbounded memory growth (potential OOM). Consider: (1) bounding the replay buffer (e.g., max events / max bytes), (2) using asyncio.Queue(maxsize=...) for subscribers, and (3) defining an overflow policy (drop subscriber, drop oldest, or apply backpressure) that matches SSE replay semantics.

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +45
async def publish(self, event: dict[str, Any]) -> None:
"""Push a new event to all current subscribers and append it to the replay buffer.

:param event: The normalised event dict (``{"type": str, "payload": dict}``).
:type event: dict[str, Any]
"""
async with self._lock:
self._events.append(event)
for q in self._subscribers:
q.put_nowait(event)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

Publishing while holding _lock and pushing directly into subscriber queues makes it difficult to introduce backpressure later (e.g., switching to await q.put(...) would block under the lock). A safer pattern is: take a snapshot (copy) of the subscriber list + append to _events under the lock, then perform queue writes outside the lock and handle overflow per-subscriber.

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +52
"""Build a ``JSONResponse`` with the standard error envelope.

:param code: Machine-readable error code (e.g. ``"internal_error"``).
:type code: str
:param message: Human-readable error message.
:type message: str
:keyword status_code: HTTP status code for the response.
:paramtype status_code: int
:keyword error_type: Optional error type classification string. When
provided, included as ``"type"`` in the error body.
:paramtype error_type: Optional[str]
:keyword details: Child error objects, each with at least ``code`` and
``message`` keys.
:paramtype details: Optional[list[dict[str, Any]]]
:keyword headers: Extra HTTP headers to include on the response.
:paramtype headers: Optional[dict[str, str]]
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The docstring uses :paramtype which is not a standard Sphinx field and likely won’t render as intended. Replace with :type status_code: int (and similarly for the keyword-only fields) or use a consistent :keyword ...: / :type ...: pattern throughout.

Copilot uses AI. Check for mistakes.
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

Programming Language :: Python :: 3.14 may not be a valid Trove classifier yet (depending on PyPI’s current classifier set). Invalid classifiers can cause publish/metadata validation failures. Consider removing 3.14 until it’s officially available in Trove classifiers, or gating it behind an explicit decision to support that runtime.

Suggested change
"Programming Language :: Python :: 3.14",

Copilot uses AI. Check for mistakes.
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

Same concern as core: Programming Language :: Python :: 3.14 may not be a valid Trove classifier and can break packaging metadata validation during publish. Consider removing until officially supported.

Suggested change
"Programming Language :: Python :: 3.14",

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +7
## 2.0.0b1 (Unreleased)

### Features Added

First version
- `AgentHost` host framework with health probe (`/readiness`), graceful shutdown, and port binding.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The PR description/title state this is an independent review of the azure-ai-agentserver-responses package, but the diff also includes broad refactors in azure-ai-agentserver-core, introduces azure-ai-agentserver-invocations, and removes large portions of langgraph/agentframework packages. If this scope is intended, please update the PR title/description to match; otherwise, consider splitting these changes so the Responses package review isn’t blocked by unrelated removals/refactors.

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +12
class _ResponseEventSubject:
"""In-process hot observable with replay buffer for SSE event broadcasting.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The Responses hosting changes introduce new concurrency/memory-sensitive behavior (replay buffer + subscriber management) but this PR doesn’t show corresponding unit tests for the new responses package. Add tests that cover: replay-from-cursor behavior, concurrent subscribe/unsubscribe during publish()/complete(), and completion behavior for late subscribers.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +72
from typing import Any

from azure.ai.agentserver.responses.models._generated.sdk.models._types import InputParam

from .._response_context import ResponseContext


class _ExecutionContext: # pylint: disable=too-many-instance-attributes
"""Holds all per-request *input* state for a single create-response call.

Passed between the routing layer and the orchestrator to avoid
large keyword-argument bundles on every internal function call.
All fields are set once at construction and treated as immutable by
the orchestrator. Mutable in-flight state (accumulated events,
background record, captured error) lives in :class:`_PipelineState`
inside the orchestrator methods.
"""

def __init__(
self,
*,
response_id: str,
agent_reference: Any,
model: str | None,
store: bool,
background: bool,
stream: bool,
input_items: list[InputParam],
previous_response_id: str | None,
conversation_id: str | None,
cancellation_signal: asyncio.Event,
span: Any,
parsed: Any,
agent_session_id: str | None = None,
context: ResponseContext | None = None,
) -> None:
self.response_id = response_id
"""The assigned response identifier."""
self.agent_reference = agent_reference
"""Normalized agent reference dictionary."""
self.model = model
"""Model name, or ``None`` if not specified."""
self.store = store
"""Whether to persist the execution record after the response completes."""
self.background = background
"""Whether this is a background (non-blocking) request."""
self.stream = stream
"""Whether to produce SSE streaming output."""
self.input_items = input_items
"""Extracted input items from the request body."""
self.previous_response_id = previous_response_id
"""Previous response ID for conversation chaining, or ``None``."""
self.conversation_id = conversation_id
"""Conversation ID for grouping related responses, or ``None``."""
self.cancellation_signal = cancellation_signal
"""Event signalling that the client has requested cancellation."""
self.agent_session_id = agent_session_id
"""Resolved session ID for this request (S-048)."""
self.context: ResponseContext | None = context
"""Runtime response context for this request. Set after construction
via :meth:`_ResponseEndpointHandler._create_response_context`."""
self.span = span
"""Active observability span for this request."""
self.parsed = parsed
"""Parsed ``CreateResponse`` model instance from the request body."""
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

_ExecutionContext is functioning as an immutable request-scoped record, but it’s implemented as a mutable class with many Any fields. Making it a @dataclass(frozen=True, slots=True) (or at least tightening types like agent_reference: dict[str, Any] and span to a concrete protocol/type) would reduce accidental mutation and improve readability/IDE support.

Suggested change
from typing import Any
from azure.ai.agentserver.responses.models._generated.sdk.models._types import InputParam
from .._response_context import ResponseContext
class _ExecutionContext: # pylint: disable=too-many-instance-attributes
"""Holds all per-request *input* state for a single create-response call.
Passed between the routing layer and the orchestrator to avoid
large keyword-argument bundles on every internal function call.
All fields are set once at construction and treated as immutable by
the orchestrator. Mutable in-flight state (accumulated events,
background record, captured error) lives in :class:`_PipelineState`
inside the orchestrator methods.
"""
def __init__(
self,
*,
response_id: str,
agent_reference: Any,
model: str | None,
store: bool,
background: bool,
stream: bool,
input_items: list[InputParam],
previous_response_id: str | None,
conversation_id: str | None,
cancellation_signal: asyncio.Event,
span: Any,
parsed: Any,
agent_session_id: str | None = None,
context: ResponseContext | None = None,
) -> None:
self.response_id = response_id
"""The assigned response identifier."""
self.agent_reference = agent_reference
"""Normalized agent reference dictionary."""
self.model = model
"""Model name, or ``None`` if not specified."""
self.store = store
"""Whether to persist the execution record after the response completes."""
self.background = background
"""Whether this is a background (non-blocking) request."""
self.stream = stream
"""Whether to produce SSE streaming output."""
self.input_items = input_items
"""Extracted input items from the request body."""
self.previous_response_id = previous_response_id
"""Previous response ID for conversation chaining, or ``None``."""
self.conversation_id = conversation_id
"""Conversation ID for grouping related responses, or ``None``."""
self.cancellation_signal = cancellation_signal
"""Event signalling that the client has requested cancellation."""
self.agent_session_id = agent_session_id
"""Resolved session ID for this request (S-048)."""
self.context: ResponseContext | None = context
"""Runtime response context for this request. Set after construction
via :meth:`_ResponseEndpointHandler._create_response_context`."""
self.span = span
"""Active observability span for this request."""
self.parsed = parsed
"""Parsed ``CreateResponse`` model instance from the request body."""
from dataclasses import dataclass
from typing import Any
from azure.ai.agentserver.responses.models._generated.sdk.models._types import InputParam
from .._response_context import ResponseContext
@dataclass(frozen=True, slots=True) # pylint: disable=too-many-instance-attributes
class _ExecutionContext:
"""Holds all per-request *input* state for a single create-response call.
Passed between the routing layer and the orchestrator to avoid
large keyword-argument bundles on every internal function call.
All fields are set once at construction and enforced as immutable by
the dataclass configuration. Mutable in-flight state (accumulated events,
background record, captured error) lives in :class:`_PipelineState`
inside the orchestrator methods.
"""
response_id: str
"""The assigned response identifier."""
agent_reference: dict[str, Any]
"""Normalized agent reference dictionary."""
model: str | None
"""Model name, or ``None`` if not specified."""
store: bool
"""Whether to persist the execution record after the response completes."""
background: bool
"""Whether this is a background (non-blocking) request."""
stream: bool
"""Whether to produce SSE streaming output."""
input_items: list[InputParam]
"""Extracted input items from the request body."""
previous_response_id: str | None
"""Previous response ID for conversation chaining, or ``None``."""
conversation_id: str | None
"""Conversation ID for grouping related responses, or ``None``."""
cancellation_signal: asyncio.Event
"""Event signalling that the client has requested cancellation."""
span: Any
"""Active observability span for this request."""
parsed: Any
"""Parsed ``CreateResponse`` model instance from the request body."""
agent_session_id: str | None = None
"""Resolved session ID for this request (S-048)."""
context: ResponseContext | None = None
"""Runtime response context for this request. Set after construction
via :meth:`_ResponseEndpointHandler._create_response_context`."""
def _test_execution_context_frozen_semantics() -> None:
"""Basic test to validate that :class:`_ExecutionContext` is immutable.
This function constructs an instance of :class:`_ExecutionContext` and
verifies that attempting to mutate an attribute raises
:class:`dataclasses.FrozenInstanceError`. It is intended to provide
lightweight coverage for the frozen dataclass behavior.
"""
from dataclasses import FrozenInstanceError
ctx = _ExecutionContext(
response_id="response-id",
agent_reference={},
model=None,
store=True,
background=False,
stream=False,
input_items=[],
previous_response_id=None,
conversation_id=None,
cancellation_signal=asyncio.Event(),
span=object(),
parsed=object(),
agent_session_id=None,
context=None,
)
try:
# Attempt to mutate a frozen dataclass field should raise.
ctx.response_id = "other-id" # type: ignore[misc]
except FrozenInstanceError:
# Expected path: immutability is enforced.
return
raise AssertionError(
"_ExecutionContext must be immutable, but attribute assignment succeeded."
)

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +30
def __init__(
self,
*,
response_id: str,
agent_reference: Any,
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

_ExecutionContext is functioning as an immutable request-scoped record, but it’s implemented as a mutable class with many Any fields. Making it a @dataclass(frozen=True, slots=True) (or at least tightening types like agent_reference: dict[str, Any] and span to a concrete protocol/type) would reduce accidental mutation and improve readability/IDE support.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-ai-agentserver-responses

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