Python: Select Foundry hosting conversation history source - #7997
Python: Select Foundry hosting conversation history source#7997Eduard van Valkenburg (eavanvalkenburg) wants to merge 4 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a4c73599-9f66-4c22-bd66-96fe676e0ce6
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a4c73599-9f66-4c22-bd66-96fe676e0ce6
There was a problem hiding this comment.
Pull request overview
Adds explicit model-history ownership for Python Foundry-hosted response agents, preventing duplicated conversation replay.
Changes:
- Adds
agent_serverandagenthistory-source modes. - Enforces stateless downstream calls in AgentServer mode.
- Adds regression tests, documentation, and ADR 0039.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
_responses.py |
Implements history-source selection and storage safeguards. |
test_responses.py |
Covers history modes and session persistence. |
README.md |
Documents configuration and behavior. |
0039-python-foundry-hosting-history-source.md |
Records the architectural decision. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): a6ea50e3ab2e
Model: gpt-5.6-sol
Overview
The PR makes model-history ownership explicit and adds strong guards for standard Agent instances: it rejects conflicting providers and defaults, forces downstream storage off, clears stale service IDs, and tests persistence and function-loop behavior. Two gaps remain around the broader SupportsAgentRun contract and reuse of the caller-owned agent: mandatory storage options can be dropped for custom agents, and the transient provider installed by the default mode survives a later switch to agent-managed history.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a4c73599-9f66-4c22-bd66-96fe676e0ce6
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a4c73599-9f66-4c22-bd66-96fe676e0ce6
|
Reporter of #7955 — ran my repro/upgrade benches from that thread against this branch (default One gap in ADR 0039, though: the
|
Motivation & Context
Foundry-hosted Responses agents can restore a downstream service conversation ID while also replaying the complete AgentServer response transcript. The model then receives duplicated history, and the duplication compounds on each turn. Always requiring AgentServer history avoids competing sources, but prevents applications from choosing service, session-backed, or external history storage needed for compliance, residency, retention, deletion, encryption, and audit requirements.
This change makes the model-history source explicit while retaining AgentServer response persistence and session storage as independent concerns.
Description & Review Guide
history_source="agent_server" | "agent"toResponsesHostServer. The default AgentServer mode replays response-provider history, disables downstream storage only for clients that advertiseSTORES_BY_DEFAULT=True, removes unsupported storage options for other clients, clears stale service IDs, rejects conflicting history/default conversation configuration, and refuses to persist a session if a client still stores downstream. Agent mode passes only current request input and preserves normalAgenthistory-provider and service-storage behavior. The PR also adds unit and real Foundry integration coverage, package documentation, and ADR 0039 with the considered alternatives.InMemoryHistoryProviderpersisted throughFoundryAgentSessionStore, or an external history provider can explicitly selecthistory_source="agent".service_session_id, and whether the two-value API communicates that distinction clearly.Related Issue
Fixes #7955
The earlier PR #7957 was closed unmerged for design discussion; there is no other open PR for this issue.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and the title prefix in sync automatically.