-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[agentserver-responses] Spec compliance: error shapes, eager eviction, chat isolation, storage logging, diagnostic logging #46364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RaviPidaparthi
wants to merge
14
commits into
main
Choose a base branch
from
feature/spec-compliance-error-shapes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
56c47e2
Spec compliance: error shapes, post-delete 404, storage logging
RaviPidaparthi cef0a57
Address PR review: add FoundryBadRequestError handlers, clean up impo…
RaviPidaparthi b32dc39
Set 1.0.0b2 release date to 2026-04-17
RaviPidaparthi 3558979
feat: chat isolation enforcement & malformed ID validation
RaviPidaparthi 6b8428a
feat(agentserver-responses): eager eviction of terminal response records
RaviPidaparthi d305bbf
fix(agentserver-responses): remove stream mode flag stamping on persi…
RaviPidaparthi 615497d
feat(agentserver-responses): inbound request logging middleware and h…
RaviPidaparthi 0f83834
chore: remove .NET references from code comments and docstrings
RaviPidaparthi e5f7e87
fix: add type ignore for Starlette add_middleware typing
RaviPidaparthi 903e498
fix: update githubcopilot core dependency to >=2.0.0b1
RaviPidaparthi 636c3b2
Revert "fix: update githubcopilot core dependency to >=2.0.0b1"
RaviPidaparthi 60528f6
Move InboundRequestLoggingMiddleware to core
RaviPidaparthi cc693e2
Bump core to 2.0.0b2, invocations to 1.0.0b2 for middleware move
RaviPidaparthi ea83b19
feat(responses): add x-agent-session-id header + B40 error shape (§8,…
RaviPidaparthi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
sdk/agentserver/azure-ai-agentserver-responses/CHANGELOG.md
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
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
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
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
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
85 changes: 85 additions & 0 deletions
85
...-ai-agentserver-responses/azure/ai/agentserver/responses/store/_foundry_logging_policy.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
| """Logging policy for Foundry storage HTTP calls. | ||
|
|
||
| Logs method, URI, status code, duration, and correlation headers for | ||
| each outbound storage request at the ``azure.ai.agentserver`` logger. | ||
|
|
||
| This mirrors the .NET ``FoundryStorageLoggingPolicy`` and provides | ||
| consistent observability for storage operations. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| import time | ||
| from typing import TYPE_CHECKING, TypeVar | ||
|
|
||
| from azure.core.pipeline import PipelineRequest, PipelineResponse | ||
| from azure.core.pipeline.policies import AsyncHTTPPolicy | ||
|
|
||
| if TYPE_CHECKING: | ||
| pass | ||
|
|
||
|
RaviPidaparthi marked this conversation as resolved.
Outdated
|
||
| logger = logging.getLogger("azure.ai.agentserver") | ||
|
|
||
| T = TypeVar("T") | ||
|
RaviPidaparthi marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Correlation headers to extract and log | ||
| _CLIENT_REQUEST_ID_HEADER = "x-ms-client-request-id" | ||
| _SERVER_REQUEST_ID_HEADER = "x-ms-request-id" | ||
|
|
||
|
|
||
| class FoundryStorageLoggingPolicy(AsyncHTTPPolicy[PipelineRequest, PipelineResponse]): | ||
| """Azure Core per-retry pipeline policy that logs Foundry storage calls. | ||
|
|
||
| Logs the HTTP method, URI, response status code, duration in milliseconds, | ||
| and correlation headers (``x-ms-client-request-id``, ``x-ms-request-id``) | ||
| for observability of storage operations. | ||
| """ | ||
|
|
||
| async def send(self, request: PipelineRequest) -> PipelineResponse: # type: ignore[override] | ||
| """Send the request and log the operation details. | ||
|
|
||
| :param request: The pipeline request. | ||
| :type request: ~azure.core.pipeline.PipelineRequest | ||
| :return: The pipeline response. | ||
| :rtype: ~azure.core.pipeline.PipelineResponse | ||
| """ | ||
| http_request = request.http_request | ||
| method = http_request.method | ||
| url = http_request.url | ||
|
|
||
| client_request_id = http_request.headers.get(_CLIENT_REQUEST_ID_HEADER, "") | ||
|
|
||
| start = time.monotonic() | ||
| try: | ||
| response = await self.next.send(request) | ||
| except Exception: | ||
| elapsed_ms = (time.monotonic() - start) * 1000 | ||
| logger.warning( | ||
| "Foundry storage %s %s failed after %.1fms (client-request-id=%s)", | ||
| method, | ||
| url, | ||
| elapsed_ms, | ||
| client_request_id, | ||
| ) | ||
| raise | ||
|
|
||
| elapsed_ms = (time.monotonic() - start) * 1000 | ||
| status_code = response.http_response.status_code | ||
| server_request_id = response.http_response.headers.get(_SERVER_REQUEST_ID_HEADER, "") | ||
|
|
||
| log_level = logging.INFO if 200 <= status_code < 400 else logging.WARNING | ||
| logger.log( | ||
| log_level, | ||
| "Foundry storage %s %s -> %d (%.1fms, client-request-id=%s, request-id=%s)", | ||
| method, | ||
| url, | ||
| status_code, | ||
| elapsed_ms, | ||
| client_request_id, | ||
| server_request_id, | ||
| ) | ||
|
|
||
| return response | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.