Skip to content

[agentserver] Separate Invocations and Responses task-runtime activation - #49616

Open
Nathandrake229 wants to merge 3 commits into
Azure:mainfrom
Nathandrake229:users/naman/protocol-task-enablement
Open

Nathandrake229 wants to merge 3 commits into
Azure:mainfrom
Nathandrake229:users/naman/protocol-task-enablement

Conversation

@Nathandrake229

@Nathandrake229 Nathandrake229 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Separate task-runtime activation for the Invocations and Responses protocols.

  • Invocations continues to use set_resilient_tasks_enabled(True) before host startup.
  • Responses requests TaskManager when either resilient_background or steerable_conversations is true, independently of the Invocations switch.
  • Responses construction no longer changes that switch.
  • Use the existing persistent task providers; there is no new in-memory task backend.

Based on freshly fetched main at cddd0ee8fe3c0fe2453ee38af71b9c4bf64ae7b5.

Responses server-option truth table

For requests with store=true, background=true:

resilient_background steerable_conversations Responses task runtime Live steering After crash/restart
false false Off No No task-based recovery; unfinished response can remain in_progress.
false true Persistent TaskManager Yes Interrupted response is marked failed without handler re-invocation; persisted queued turns may promote and run as new steered turns.
true false Persistent TaskManager No Interrupted handler is re-invoked.
true true Persistent TaskManager Yes Interrupted handler is re-invoked, with steering supported.

Steering-only mode retains durable task control state and recovery bookkeeping. It is not memory-only or a mode without a recovery scanner.

Request behavior stays unchanged

store background Behavior
true true Stored background execution; survives client disconnect. Recovery follows the server-option table.
true false Stored foreground execution; disconnect cancellation remains. An initialized task runtime marks interrupted foreground work failed rather than re-invoking it.
false true HTTP 400: background=true requires store=true.
false false Ephemeral foreground execution, no task-backed steering/recovery.

Graceful shutdown still best-effort marks unfinished non-resilient responses failed even without TaskManager. SSE backing, persistent-response-provider validation, checkpoint consumption and recoverable shutdown preservation retain their existing resilient_background gates.

Isolation and implementation

  • Cooperative protocol registration contributes independent startup requirements in either multiple-inheritance order.
  • Keep the task manager on its owning host and bind access through context-local lifecycle/request scopes, including HTTP and Invocations WebSocket routes.
  • An enabled protocol does not expose its manager to disabled protocol handlers. Both-disabled Responses bypasses task dispatch explicitly, even if the Invocations switch is on.
  • Late task registration follows the scoped manager. Shutdown clears only its own compatibility singleton.
  • Preserve eager internal task registration before startup recovery and existing persisted dispositions; do not replace the registry or recovery algorithms.
  • Startup construction/initialization errors still fail the lifespan.
  • The low-level Core host retains its standalone switch-based behavior for compatibility.

Compatibility and packaging

This deliberately changes two configurations:

  1. Steering-only Responses now initializes TaskManager automatically; no separate core switch call is required.
  2. Setting the core switch no longer forces task execution for Responses with both feature options false.

Both protocol packages require azure-ai-agentserver-core>=2.3.0b2 because scoped runtime support is a coordinated core/protocol change. No new dependency names, public constructor arguments, versioning feature, registry auto-enablement or task-provider type is introduced.

The unreleased notes use versioned release headings, aligned with runtime and API metadata: Responses 2.4.0b2 and Invocations 1.2.1b1. Existing released entries are preserved.

Updated package changelogs, related guides, conformance setup and Responses samples. The experimental-marker and steering-handoff changes already on main remain intact.

Validation

  • Core task/snapshot suites: 704 passed, 51 skipped.
  • Responses unit/contract/integration: 2,082 passed, 3 skipped.
  • Responses e2e/conformance on Windows: 185 passed, 78 skipped.
  • Invocations non-live suite: 665 passed, 3 skipped, with 3 live tests deselected; all 18 new protocol/MRO/HTTP/WS cases pass.
  • POSIX crash tests in WSL: 5 passed, including both-disabled and steering-only Row 2 recovery.
  • Real hard-stop/restart with the Invocations switch false in both process lifetimes: steering-only mode marks interrupted A failed and executes queued B; resilient steering re-invokes A and then executes B. Responses never changes the switch.
  • Pylint: 10.00/10 across the 10 changed production modules.
  • Mypy passed on changed production modules; full-package Pyright has zero errors for all three packages. Existing warnings occur only in unchanged files.
  • Repository-pinned Black at the repository's 120-column setting and git diff --check pass.

Keep the explicit task switch for Invocations and derive Responses activation from resilient_background or steerable_conversations. Scope runtime access by host and protocol without changing persistent backends, request mode semantics, or recovery dispositions.

Add activation/request matrices, mixed-host and WebSocket isolation coverage, startup failure checks, and feature-driven crash conformance. Update minimum core requirements and related samples/docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b3f38ee6-97fe-4707-8f3d-5a1169666792
@github-actions github-actions Bot added the Hosted Agents sdk/agentserver/* label Oct 20, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@Nathandrake229
Nathandrake229 marked this pull request as ready for review October 20, 2026 07:15
Copilot AI balanced review requested due to automatic review settings October 20, 2026 07:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cross-package lifecycle ownership and crash-recovery isolation require final human review.

1 open issue
What changed in this PR

Separates Invocations and Responses task-runtime activation while retaining persistent task providers and existing recovery behavior.

Changes:

  • Adds host-owned task managers with lifecycle and request scoping.
  • Enables Responses tasks through either feature option, independently of the Invocations switch.
  • Updates dependencies, documentation, samples, and activation/recovery tests.
File Description
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​unit/​test_stream_lifecycle_cleanup.py Enables steering for cleanup tests.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​unit/​test_response_delete_recovery.py Assigns the manager to its host.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​integration/​test_steering_input_handoff.py Tests steering without the core switch.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​integration/​test_protocol_task_enablement.py Tests activation combinations and host isolation.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​e2e/​resilience_contract/​test_row_2_path_c.py Tests crash behavior with and without steering.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​e2e/​resilience_contract/​test_row_2_path_b.py Enables steering for shutdown recovery.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​e2e/​resilience_contract/​test_row_2_path_a.py Enables steering for graceful completion.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​e2e/​resilience_contract/​conftest.py Adds harness steering configuration.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​e2e/​resilience_contract/​_test_handler.py Uses Responses options for activation.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​e2e/​resilience_contract/​_steering_handler.py Removes explicit core-switch activation.
sdk/​agentserver/​azure-ai-agentserver-responses/​tests/​contract/​test_resilient_start_failure.py Explicitly enables runtime-dependent tests.
sdk/​agentserver/​azure-ai-agentserver-responses/​samples/​sample_22_resilient_multiturn.py Removes redundant core-switch setup.
sdk/​agentserver/​azure-ai-agentserver-responses/​samples/​sample_21_resilient_langgraph.py Removes redundant core-switch setup.
sdk/​agentserver/​azure-ai-agentserver-responses/​samples/​sample_20_resilient_steering.py Removes redundant core-switch setup.
sdk/​agentserver/​azure-ai-agentserver-responses/​samples/​sample_19_resilient_streaming.py Removes redundant core-switch setup.
sdk/​agentserver/​azure-ai-agentserver-responses/​README.md Explains independent activation and recovery.
sdk/​agentserver/​azure-ai-agentserver-responses/​pyproject.toml Raises the minimum core dependency.
sdk/​agentserver/​azure-ai-agentserver-responses/​docs/​resilient-responses-developer-guide.md Updates configuration and recovery guidance.
sdk/​agentserver/​azure-ai-agentserver-responses/​docs/​resilience-contract.md Defines runtime-dependent recovery guarantees.
sdk/​agentserver/​azure-ai-agentserver-responses/​CHANGELOG.md Records activation and compatibility changes.
sdk/​agentserver/​azure-ai-agentserver-responses/​azure/​ai/​agentserver/​responses/​hosting/​_routing.py Scopes routes and registers activation requirements.
sdk/​agentserver/​azure-ai-agentserver-responses/​azure/​ai/​agentserver/​responses/​hosting/​_resilient_orchestrator.py Stops modifying the global switch.
sdk/​agentserver/​azure-ai-agentserver-responses/​azure/​ai/​agentserver/​responses/​hosting/​_orchestrator.py Bypasses task dispatch when both options are disabled.
sdk/​agentserver/​azure-ai-agentserver-invocations/​tests/​test_protocol_task_enablement.py Tests protocol composition and transport scoping.
sdk/​agentserver/​azure-ai-agentserver-invocations/​pyproject.toml Raises the minimum core dependency.
sdk/​agentserver/​azure-ai-agentserver-invocations/​CHANGELOG.md Records dependency and isolation changes.
sdk/​agentserver/​azure-ai-agentserver-invocations/​azure/​ai/​agentserver/​invocations/​_invocation.py Adds switch-controlled HTTP task scopes.
sdk/​agentserver/​azure-ai-agentserver-invocations/​azure/​ai/​agentserver/​invocations/​_invocation_ws.py Adds switch-controlled WebSocket task scopes.
sdk/​agentserver/​azure-ai-agentserver-core/​tests/​test_snapshot_lifecycle.py Associates the snapshot manager with its host.
sdk/​agentserver/​azure-ai-agentserver-core/​tests/​tasks/​test_task_manager_not_initialized.py Tests scoped access and late registration.
sdk/​agentserver/​azure-ai-agentserver-core/​docs/​tasks-guide.md Clarifies protocol-specific activation.
sdk/​agentserver/​azure-ai-agentserver-core/​CHANGELOG.md Records scoped-runtime support.
sdk/​agentserver/​azure-ai-agentserver-core/​azure/​ai/​agentserver/​core/​tasks/​_manager.py Adds contextual lookup and owner-specific cleanup.
sdk/​agentserver/​azure-ai-agentserver-core/​azure/​ai/​agentserver/​core/​tasks/​_enablement.py Clarifies the switch’s scope.
sdk/​agentserver/​azure-ai-agentserver-core/​azure/​ai/​agentserver/​core/​tasks/​_decorator.py Directs late registration to the scoped manager.
sdk/​agentserver/​azure-ai-agentserver-core/​azure/​ai/​agentserver/​core/​_middleware.py Adds task-scoping middleware and registration helpers.
sdk/​agentserver/​azure-ai-agentserver-core/​azure/​ai/​agentserver/​core/​_base.py Owns managers and scopes host lifecycle access.

Review effort: Balanced

Comment thread sdk/agentserver/azure-ai-agentserver-responses/CHANGELOG.md Outdated
Describe feature-driven startup, steering-only recovery, and the lack of task-based locking/crash cleanup when both Responses flags are disabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b3f38ee6-97fe-4707-8f3d-5a1169666792
Copilot AI balanced review requested due to automatic review settings October 20, 2026 08:45
Use versioned preview headings so version-specific release-note extraction includes the protocol activation and dependency changes. Preserve released history and align runtime/API metadata versions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b3f38ee6-97fe-4707-8f3d-5a1169666792

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cross-package runtime isolation and recovery lifecycle changes require human validation, with an unresolved activation-isolation issue.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Capture Invocations enablement per host at startup

sdk/​agentserver/​azure-ai-agentserver-invocations/​azure/​ai/​agentserver/​invocations/​_invocation.py:255

[P2] Capture Invocations enablement per host at lifespan startup. The HTTP resolver created here and the WebSocket resolver in _invocation_ws.py:190 re-read the process-wide switch on every manager lookup. If host A starts enabled, setting the switch to False before starting host B removes task access from A's handlers and existing WebSocket sessions even though A's manager is still running. Conversely, switching to True exposes a Responses-enabled mixed host's manager to Invocations that started disabled. Record each protocol's activation decision at startup and use that same state for HTTP and WebSocket scopes. Add overlapping-host coverage that changes the switch between host startups.

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 20, 2026 08:55
@Nathandrake229
Nathandrake229 enabled auto-merge (squash) October 20, 2026 09:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Live-switch lookups and unscoped Voice WebSocket callbacks leave protocol isolation incomplete.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Use host-local invocation enablement for HTTP and WebSocket scopes

sdk/​agentserver/​azure-ai-agentserver-invocations/​azure/​ai/​agentserver/​invocations/​_invocation.py:255

Invocations request scoping reads the live process-wide switch rather than the host's startup decision. If host A starts with the switch enabled, then it is disabled before starting host B, A's HTTP handlers lose access to its still-running manager and task calls raise TaskManagerNotInitialized. The WebSocket lookup in _invocation_ws.py:190 has the same problem. Capture each protocol's enablement at lifespan startup and use that host-local decision for both HTTP and WebSocket scopes. Add an overlapping-host test that changes the switch between startups and verifies A retains access.

Medium severity Apply invocation task scoping to Voice WebSocket routes

sdk/​agentserver/​azure-ai-agentserver-invocations/​azure/​ai/​agentserver/​invocations/​_invocation_ws.py:190

This middleware covers only the base WebSocket route. VoiceAgentServerHost overrides route registration and creates _VoiceWebSocketRoute without middleware (voice/_voice_host.py:189–190,589–604); it also overrides _ws_endpoint. In a composed Voice/Responses host with Invocations disabled and Responses enabled, voice callbacks therefore inherit Core's host-wide scope and can access the Responses manager. Apply Invocations task scoping to the Voice route too, and add a mixed-host test proving disabled voice callbacks cannot obtain the manager.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

4 participants