Skip to content

Fix missing isolation kwarg on update_response in bg non-stream finalization#46395

Merged
RaviPidaparthi merged 1 commit intomainfrom
fix/bg-nonstream-isolation-update
Apr 19, 2026
Merged

Fix missing isolation kwarg on update_response in bg non-stream finalization#46395
RaviPidaparthi merged 1 commit intomainfrom
fix/bg-nonstream-isolation-update

Conversation

@RaviPidaparthi
Copy link
Copy Markdown
Member

Problem

In _run_background_non_stream's finally block, the update_response call was missing the isolation= keyword argument. The _isolation variable was only computed inside the else branch (for create_response) but not used by the if branch (for update_response).

When isolation headers are present (x-agent-user-isolation-key / x-agent-chat-isolation-key), Foundry storage creates the response in a scoped partition at response.created time (FR-003). The finalization update_response without isolation headers then targets the unscoped partition, gets 404, the error is silently swallowed, and the record is evicted from memory. All subsequent GET polls hit Foundry's stale in_progress snapshot, leaving the response stuck permanently.

Affected path: background=True, stream=False, store=True with Foundry storage and isolation keys present.

Fix

Hoist the _isolation = context.isolation if context else None computation above the if/else branch so both update_response and create_response receive it.

Changes

  • _orchestrator.py: Move _isolation computation before the if _provider_created: branch, add isolation=_isolation to update_response call
  • test_bg_isolation_propagation.py (new): 3 contract tests using a recording provider that captures the isolation kwarg on every update_response call — verifies both keys, user-only key, and no-keys scenarios
  • CHANGELOG.md: Bug fix entry for 1.0.0b2

…ization

In _run_background_non_stream's finally block, the update_response call
was missing the isolation= keyword argument. The _isolation variable was
only computed inside the else branch (for create_response) but not used
by the if branch (for update_response).

When isolation headers are present, Foundry storage creates the response
in a scoped partition at response.created time (FR-003). The finalization
update_response without isolation headers then targets the unscoped
partition, gets 404, the error is silently swallowed, and the record is
evicted from memory. All subsequent GET polls hit Foundry's stale
in_progress snapshot, leaving the response stuck permanently.

Fix: hoist _isolation computation above the if/else so both branches
receive it.

Includes:
- Contract test verifying isolation propagation to update_response
- CHANGELOG entry for 1.0.0b2
Copilot AI review requested due to automatic review settings April 19, 2026 10:06
@github-actions github-actions Bot added the Hosted Agents sdk/agentserver/* label Apr 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Foundry storage partitioning bug in the Responses background non-stream finalization path by ensuring the request’s isolation context is forwarded to the terminal update_response call, preventing stuck in_progress responses when isolation headers are present.

Changes:

  • Hoists isolation context computation in _run_background_non_stream and passes isolation= into update_response.
  • Adds contract tests to assert isolation propagation to update_response across header combinations.
  • Documents the fix in the package changelog for 1.0.0b2.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sdk/agentserver/azure-ai-agentserver-responses/azure/ai/agentserver/responses/hosting/_orchestrator.py Ensures background non-stream finalization update_response uses the same isolation context as create_response.
sdk/agentserver/azure-ai-agentserver-responses/tests/contract/test_bg_isolation_propagation.py New regression/contract coverage verifying isolation is forwarded to update_response in bg non-stream mode.
sdk/agentserver/azure-ai-agentserver-responses/CHANGELOG.md Adds a bug-fix entry describing the isolation propagation issue and impact.

@RaviPidaparthi RaviPidaparthi enabled auto-merge (squash) April 19, 2026 10:11
@RaviPidaparthi RaviPidaparthi merged commit e0ba263 into main Apr 19, 2026
26 checks passed
@RaviPidaparthi RaviPidaparthi deleted the fix/bg-nonstream-isolation-update branch April 19, 2026 10:26
RaviPidaparthi added a commit that referenced this pull request Apr 19, 2026
Version bump for hotfix release: the isolation fix (PR #46395) merged
after 1.0.0b2 was already published.

CHANGELOG: new 1.0.0b3 section with the bg non-stream isolation bug fix.
RaviPidaparthi added a commit that referenced this pull request Apr 19, 2026
Version bump for hotfix release: the isolation fix (PR #46395) merged
after 1.0.0b2 was already published.

CHANGELOG: new 1.0.0b3 section with the bg non-stream isolation bug fix.
fafhrd91 pushed a commit to fafhrd91/azure-sdk-for-python that referenced this pull request Apr 28, 2026
…ization (Azure#46395)

In _run_background_non_stream's finally block, the update_response call
was missing the isolation= keyword argument. The _isolation variable was
only computed inside the else branch (for create_response) but not used
by the if branch (for update_response).

When isolation headers are present, Foundry storage creates the response
in a scoped partition at response.created time (FR-003). The finalization
update_response without isolation headers then targets the unscoped
partition, gets 404, the error is silently swallowed, and the record is
evicted from memory. All subsequent GET polls hit Foundry's stale
in_progress snapshot, leaving the response stuck permanently.

Fix: hoist _isolation computation above the if/else so both branches
receive it.

Includes:
- Contract test verifying isolation propagation to update_response
- CHANGELOG entry for 1.0.0b2
fafhrd91 pushed a commit to fafhrd91/azure-sdk-for-python that referenced this pull request Apr 28, 2026
Version bump for hotfix release: the isolation fix (PR Azure#46395) merged
after 1.0.0b2 was already published.

CHANGELOG: new 1.0.0b3 section with the bg non-stream isolation bug fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants