Hide agentserver response internals from API surface - #48370
Open
Shivakishore14 wants to merge 41 commits into
Open
Hide agentserver response internals from API surface#48370Shivakishore14 wants to merge 41 commits into
Shivakishore14 wants to merge 41 commits into
Conversation
Move response contracts to local TypedDict wire payloads and remove runtime reliance on generated model constructors, serialization helpers, and nested generated SDK model paths. Keep validation behind a stable local wrapper and update tests to exercise dict-native payloads instead of generated model runtime callability. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the source-built TypeSpec Python emitter TypedDict output as the model source instead of the localized bridge artifact. Normalize the emitted package into the local AgentServer generated boundary and remove fake model_base/_models compatibility shims. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pin AgentServer TypeSpec generation to the source PR that removes stale OpenAI usage decorators and enables Python TypeDict generation. Replace the old finalization script with a minimal contract extractor, regenerate API docs and model contracts, and remove unused _types.py output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Regenerate AgentServer response TypedDict contracts, validators, and API docs from the current AgentServer service contract path. Point tsp-location.yaml at the fresh spec PR commit and compile from the clean synced Foundry/src root. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Inline the single-use wire field mutation helper and remove a thin Foundry serializer wrapper that only delegated to to_wire_dict. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Generate the TypedDict enum fallback at the root _generated package so validators use the same _enums import shape as latest main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Point AgentServer Responses generation metadata at the latest spec PR commit after CI-only validation fixes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Address runtime dict-native response compatibility, static analysis, spelling, and Sphinx documentation failures for the AgentServer Responses package. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Update samples to use TypedDict-safe access and required discriminator fields so package Pyright validation passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Regenerate AgentServer response contracts from the rapida/add-agentserver-view spec branch and restore the SDK TypeSpec pointer layout to the main SDK shape with only the commit updated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Fix review feedback for dict-native response models by completing ID generation coverage, preserving wire field names, filtering storage-only SSE fields, and restoring ResponseIncompleteReason as a public compatibility enum. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Sanitize generated model docstrings that Sphinx treats as warnings, narrow public model exports to actual generated types, and add package spellcheck words for generated response ID prefixes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Avoid using generated enum fallback objects in runtime code by comparing against the stable wire string values directly, and annotate the ID dispatch table for mypy. Regenerate API stubs after the public export cleanup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Handle scale service tier validation, tighten input text extraction, preserve required statuses on search output items, reject output-only item types from input conversion, and keep generated union aliases public without exposing enum literal aliases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Use a correctly spelled invalid enum member name in the generated enum fallback regression test so CSpell does not flag the test-only typo. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Generate runtime enum classes from literal aliases so enum members preserve isinstance and iteration semantics, and materialize response timestamps as Unix integers in emitted wire payloads. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Move custom request validators out of the TypeSpec-emitted _generated package and align validation helper names with TypedDict Literal contracts instead of enum shims. Preserve scale service_tier support by reading the generated CreateResponse field literal before schema alias fallback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Update the AgentServer responses SDK to consume the spec fix that removes the server-assigned id field from function-call input items. Regenerate TypedDict contracts, request validators, and API stubs, and add a checked typing contract for CreateResponse function-call input without id. Spec PR: Azure/azure-rest-api-specs#44927 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Update the AgentServer responses TypeSpec pin to the spec PR tip that includes the function-call input id fix and CI metadata for the SDK-only contracts folder. Spec PR: Azure/azure-rest-api-specs#44927 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Enforce generated Literal aliases for enum-like schemas, reject unknown discriminators, preserve nullable literal refs, export public Literal aliases, and clean generated validator/temp outputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4ead3de5-a3b3-4d3a-bf93-a4ee397d7498
…peddict-local # Conflicts: # sdk/agentserver/azure-ai-agentserver-responses/cspell.json Co-authored-by: Shivakishore14 <13432471+Shivakishore14@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move response runtime and validation error helpers behind private modules and remove get_content_expanded from the public models export so APIView only shows intentional protocol models. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Remove undocumented data_url and normalization/conversion helpers from the public response package/model exports while keeping get_input_expanded public for hosted-agents sample compatibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Restore the runtime module for types that appear in public signatures and hide only the cancelled/failed response builder helpers behind underscored names. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep DataUrl and model expansion helpers public to align with the .NET AgentServer Responses surface while leaving non-parity internals private. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Shivakishore14
marked this pull request as ready for review
July 31, 2026 19:19
Shivakishore14
requested review from
RaviPidaparthi,
ankitbko and
vangarp
as code owners
July 31, 2026 19:19
|
Azure Pipelines: 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Shivakishore14
changed the base branch from
sshiva/agentserver-typeddict-local
to
main
July 31, 2026 19:27
Shivakishore14
marked this pull request as draft
July 31, 2026 19:29
Hide internal validation errors and response builder helpers from the public API while preserving public runtime types and model expansion helpers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a 2.0.0b1 changelog entry for the API surface cleanup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Shivakishore14
marked this pull request as ready for review
July 31, 2026 19:58
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Attempts to reduce the package’s public API surface by privatizing implementation helpers and updating generated API artifacts.
Changes:
- Privatizes validation errors and response builders.
- Removes selected top-level helper exports.
- Updates tests, documentation, API artifacts, and version metadata.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/unit/test_validation.py |
Uses private validation errors. |
tests/unit/test_response_execution.py |
Tests renamed private builder. |
tests/unit/test_generated_payload_validation.py |
Updates private error import. |
tests/unit/test_error_source_classification.py |
Updates private error import. |
doc/azure.ai.agentserver.responses.models.rst |
Removes public errors documentation. |
CHANGELOG.md |
Records API cleanup release. |
models/runtime.py |
Renames response builders as private. |
models/_errors.py |
Marks validation helpers internal. |
hosting/_validation.py |
Uses private validation errors. |
hosting/_request_parsing.py |
Uses private validation errors. |
_version.py |
Bumps version to 2.0.0b1. |
responses/__init__.py |
Removes two top-level helper exports. |
api.metadata.yml |
Updates API artifact metadata. |
api.md |
Regenerates the documented API surface. |
|
|
||
|
|
||
| def build_cancelled_response( | ||
| def _build_cancelled_response( |
| def azure.ai.agentserver.responses.get_conversation_id(request: CreateResponse | ResponseObject) -> Optional[str]: ... | ||
|
|
||
|
|
||
| def azure.ai.agentserver.responses.get_input_expanded(request: CreateResponse) -> list[Item]: ... |
…i-review-public-surface # Conflicts: # sdk/agentserver/azure-ai-agentserver-responses/CHANGELOG.md
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
Suppressed comments (2)
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/models/runtime.py:344
- Prefixing these two builders with
_does not perform the described move of runtime helpers/state to a private module.models/runtime.pyremains public, and the regenerated API still exposes the resolver/apply helpers plusResponseExecution,ResponseModeFlags,StreamEventRecord, andStreamReplayStateundermodels.runtime(api.md:5924-6124). Move this implementation tomodels._runtime, update its imports/docs/tests, and regenerate the API artifacts.
def _build_cancelled_response(
sdk/agentserver/azure-ai-agentserver-responses/api.metadata.yml:1
- The regenerated surface still exposes
azure.ai.agentserver.responses.models.get_content_expandedatapi.md:1755becausemodels/__init__.pycontinues to import it and list it in__all__. This contradicts the PR's stated removal; remove those export entries and regenerate both API artifacts.
apiMdSha256: 791aa262be4b10719e1a9ddde5516041bdad4d169806f83d5ebaef26474ccb30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the initial APIView comments from PR #47995 by keeping implementation helpers out of the public API surface.
Changes:
models.get_content_expandedfrom the public models export.models.runtimeto privatemodels._runtime.models.errorsto privatemodels._errors, preserving the publicmodels.ApiErrorResponse/models.Errorwire shape.api.mdandapi.metadata.yml.Validation:
azpysdk apistub .pytest tests/unit/test_validation.py tests/unit/test_generated_payload_validation.py tests/unit/test_error_source_classification.py tests/unit/test_response_execution.py tests/unit/test_runtime_state.py tests/unit/test_public_contract_types.py tests/unit/test_response_context_input_items.py tests/unit/test_resolve_input_items_for_persistence.py tests/unit/test_string_content_expansion.pypytest tests/contract/test_eager_eviction.py