-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Python: Select Foundry hosting conversation history source #7997
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
Draft
Eduard van Valkenburg (eavanvalkenburg)
wants to merge
4
commits into
microsoft:main
Choose a base branch
from
eavanvalkenburg:foundry-history-source
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.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a6ea50e
Python: select Foundry hosting history source
eavanvalkenburg 98c216c
Docs: correct history source ADR metadata
eavanvalkenburg a77eeb5
Python: harden hosted history selection
eavanvalkenburg 5713d33
Python: document hosted agent ownership
eavanvalkenburg 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
124 changes: 124 additions & 0 deletions
124
docs/decisions/0039-python-foundry-hosting-history-source.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| --- | ||
| status: proposed | ||
| contact: eavanvalkenburg | ||
| date: 2026-09-01 | ||
| deciders: eavanvalkenburg, moonbox3 | ||
| --- | ||
|
|
||
| # Select the conversation history source for Python Foundry hosting | ||
|
|
||
| ## Context and Problem Statement | ||
|
|
||
| `ResponsesHostServer` currently replays the AgentServer response transcript into every agent run. An `AgentSession` | ||
| can also restore a downstream `service_session_id`, causing the model service to combine its stored conversation with | ||
| the replayed AgentServer transcript. This duplicates prior turns and compounds on each request. | ||
|
|
||
| Conversation data can exist in four places: | ||
|
|
||
| 1. the AgentServer `ResponseProviderProtocol`; | ||
| 2. an Agent Framework `HistoryProvider`; | ||
| 3. `AgentSession.state`, persisted by a `SessionStore` and used by `InMemoryHistoryProvider`; and | ||
| 4. the downstream model service when `store=True`. | ||
|
|
||
| The host must prevent duplicate model history without removing the regular agent storage choices. | ||
|
|
||
| ## Decision Drivers | ||
|
|
||
| - Feed one canonical conversation transcript into each model call. | ||
| - Keep AgentServer response persistence independent from the model's history source. | ||
| - Preserve the normal agent choice between `HistoryProvider` and downstream service storage. | ||
| - Let applications choose storage that satisfies their compliance, residency, retention, deletion, encryption, and | ||
| audit requirements. | ||
| - Retain AgentServer response history as the default hosting behavior. | ||
| - Make existing sessions containing a downstream service ID safe after upgrade. | ||
|
|
||
| ## Considered Options | ||
|
|
||
| ### Always use AgentServer response history | ||
|
|
||
| - Good: one simple default and parity with current .NET Foundry hosting. | ||
| - Good: the selected response provider controls the transcript used by the model. | ||
| - Bad: users cannot use normal agent history providers or service-side continuation. | ||
| - Bad: applications cannot choose a history backend that meets their data-governance requirements independently of | ||
| AgentServer protocol storage. | ||
|
|
||
| ### Clear the service ID but leave downstream storage enabled | ||
|
|
||
| - Good: avoids duplicated input. | ||
| - Bad: creates an untracked stored response or conversation on every model call. | ||
| - Bad: service-side storage incurs retention and cost but is never used for continuation. | ||
|
|
||
| ### Add separate AgentServer, history-provider, service, and automatic modes | ||
|
|
||
| - Good: makes each possible authority explicit at the hosting layer. | ||
| - Bad: duplicates history-selection behavior already implemented by `Agent`. | ||
| - Bad: an automatic mode changes authority based on provider output, making retention and recovery unpredictable. | ||
|
|
||
| ### Select AgentServer history or regular agent history | ||
|
|
||
| - Good: the host makes only the decision it owns: whether AgentServer history supersedes normal agent behavior. | ||
| - Good: regular agent mode preserves service storage, in-session history, and external history providers. | ||
| - Good: `ResponseProviderProtocol`, `HistoryProvider`, and `SessionStore` remain independent extension points. | ||
| - Good: applications can select the storage boundary and lifecycle required by their compliance policies. | ||
| - Neutral: AgentServer still manages protocol-level Responses persistence in regular agent mode, according to the outer | ||
| request, but does not replay that transcript into the model. | ||
|
|
||
| ## Decision Outcome | ||
|
|
||
| Add `history_source: Literal["agent_server", "agent"] = "agent_server"` to `ResponsesHostServer`. | ||
|
|
||
| With `history_source="agent_server"`: | ||
|
|
||
| - load-enabled `HistoryProvider` instances are rejected; | ||
| - an agent-level default `conversation_id` is rejected; | ||
| - the configured response provider transcript and current input are passed to the agent; | ||
| - clients advertising `STORES_BY_DEFAULT=True` receive a downstream `store=False` override; | ||
| - for other clients, an explicit agent-level `store` option is removed and no storage option is forwarded; | ||
| - a restored `service_session_id` is cleared before the run; | ||
| - a client that still returns a service ID fails the response and the contaminated session is not saved; and | ||
| - a transient `InMemoryHistoryProvider` supports intra-run function calls but is removed before session persistence. | ||
|
|
||
| With `history_source="agent"`: | ||
|
|
||
| - only current request input is passed by hosting; | ||
| - load-enabled history providers are allowed; | ||
| - downstream storage options are not changed; and | ||
| - normal `Agent` behavior selects service storage, an explicit history provider, or automatic in-session history. | ||
|
|
||
| The AgentServer response provider continues to control Responses API persistence and retrieval in both modes, according | ||
| to the outer request. The session-store provider also remains independent. Consequently, regular agent mode can combine | ||
| `InMemoryHistoryProvider` with the default `FoundryAgentSessionStore` to persist model history in Foundry without using | ||
| the AgentServer response transcript as model input. | ||
|
|
||
| ## Developer Experience | ||
|
|
||
| ```python | ||
| # Default: AgentServer response history is model history. | ||
| ResponsesHostServer(agent) | ||
|
|
||
| # Regular Agent history and downstream storage behavior. | ||
| ResponsesHostServer(agent, history_source="agent") | ||
| ``` | ||
|
|
||
| Passing `store=None` or omitting `store` continues to select the environment's default AgentServer response provider. | ||
| It does not disable response persistence. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Good: existing applications keep AgentServer history as their default. | ||
| - Good: applications can choose service-side, session-backed, or external history storage to meet data-governance | ||
| requirements. | ||
| - Good: the API does not introduce a second history-selection state machine. | ||
| - Bad: default mode mutates the supplied `RawAgent` by installing a transient history provider. | ||
| - Neutral: a `ResponsesHostServer` owns its supplied agent instance; reusing that agent with another host or invoking it | ||
| directly after server construction is unsupported. | ||
| - Bad: regular agent history and AgentServer response history may differ, which response-oriented evaluations must | ||
| document. | ||
| - Neutral: switching an existing conversation between modes may require resetting its persisted session/history. | ||
|
|
||
| ## More Information | ||
|
|
||
| - [Issue #7955](https://github.com/microsoft/agent-framework/issues/7955) | ||
| - [Closed Python PR #7957](https://github.com/microsoft/agent-framework/pull/7957) | ||
| - [Merged .NET PR #7525](https://github.com/microsoft/agent-framework/pull/7525) | ||
| - [Merged .NET follow-up PR #7572](https://github.com/microsoft/agent-framework/pull/7572) |
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
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.