-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[agentserver-responses] Exclude failed response inputs from replayable conversation history #49009
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
prasanna164-code
wants to merge
3
commits into
Azure:main
Choose a base branch
from
prasanna164-code:agentserver-failed-history
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
fbdb100
Exclude failed response inputs from replayable conversation history
prasanna164-code 5e80ded
Read the response status from the envelope in FileResponseStore
prasanna164-code 43dc68b
Document that the hosted history endpoint owns the failed-response ex…
prasanna164-code 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
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
46 changes: 46 additions & 0 deletions
46
...entserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/store/_history.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,46 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT license. | ||
| """Shared history-resolution rules for response providers.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| _NON_REPLAYABLE_STATUSES: frozenset[str] = frozenset({"failed"}) | ||
|
|
||
|
|
||
| def normalize_status(status: Any) -> str | None: | ||
| """Return *status* as the plain string the wire uses, or ``None`` when unset. | ||
|
|
||
| Accepts the raw string stored on a response envelope as well as an enum | ||
| member whose ``value`` is that string, so providers persist and compare | ||
| the same representation regardless of how the status was produced. | ||
|
|
||
| :param status: The stored response status, if any. | ||
| :type status: Any | ||
| :returns: The status string, or ``None``. | ||
| :rtype: str | None | ||
| """ | ||
| if status is None: | ||
| return None | ||
| return str(getattr(status, "value", status)) | ||
|
|
||
|
|
||
| def is_replayable_status(status: Any) -> bool: | ||
| """Return whether a response with *status* contributes its own items to history. | ||
|
|
||
| Only a ``failed`` response is excluded: its input is what made the turn | ||
| fail, so replaying it would fail every later turn in the same conversation | ||
| or chain. Responses in any other state (including ``incomplete`` and | ||
| ``cancelled``) keep their items in history, as does a response whose | ||
| status is unknown. | ||
|
|
||
| :param status: The stored response status, if any. | ||
| :type status: Any | ||
| :returns: ``True`` when the response's input and output items are replayable. | ||
| :rtype: bool | ||
| """ | ||
| normalized = normalize_status(status) | ||
| if normalized is None: | ||
| return True | ||
| return normalized not in _NON_REPLAYABLE_STATUSES |
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.
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.