[agentserver] Gate blocking boot-time task recovery scan on the enablement flag - #48585
Draft
Nathandrake229 wants to merge 1 commit into
Draft
[agentserver] Gate blocking boot-time task recovery scan on the enablement flag#48585Nathandrake229 wants to merge 1 commit into
Nathandrake229 wants to merge 1 commit into
Conversation
…ement flag The resilient TaskManager's cold-start recovery scan (Layer 1) blocks server lifespan startup on a task-store list() + credential-token acquisition. It ran whenever a durable task was registered OR the enablement switch was set. Because the responses protocol registers internal @task/@multi_turn_task primitives at host construction, every responses host — even a plain one that opted into no resilient features — paid that boot cost. Make the blocking Layer 1 scan opt-in via the existing set_resilient_tasks_enabled() switch: - TaskManager.startup() gains run_initial_scan (default True, preserving the contract for direct callers and the recovery test-suite). When False, the blocking scan is skipped; the periodic background loop (Layer 2) and request-time inline reclaim (Layer 3) still provide recovery. - The hosted lifespan passes run_initial_scan=resilient_tasks_enabled(), so a host that did not enable resilient tasks boots fast while keeping Layers 2 and 3 available. Samples: the invocations resilient samples (research, multiturn, langgraph) declare developer tasks and now call set_resilient_tasks_enabled(True) to keep eager boot recovery, matching the responses resilient samples. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The resilient
TaskManager's cold-start recovery scan (Layer 1) blocks server lifespan startup on a task-storelist()+ credential-token acquisition. It previously ran whenever either a durable task was registered or the enablement switch was set.Because the responses protocol registers internal
@task/@multi_turn_taskprimitives at host construction,_has_registered_tasks()was alwaysTrue— so every responses host, even a plain one that opted into no resilient features, paid the blocking boot-time scan.This PR makes the blocking Layer 1 scan opt-in via the existing
set_resilient_tasks_enabled()switch, while keeping background (Layer 2) and request-time (Layer 3) recovery always available.Changes
Core
TaskManager.startup()gainsrun_initial_scan(defaultTrue— preserves the contract for direct callers and the recovery test-suite). WhenFalse, the blocking cold-start scan is skipped; the periodic background loop (Layer 2) and request-time inline reclaim (Layer 3) still provide recovery._base.py) passesrun_initial_scan=_resilient_tasks_enabled()— a host that did not enable resilient tasks boots fast, keeping Layers 2 and 3 available.Samples
resilient_research,resilient_multiturn,resilient_langgraph) declare developer@multi_turn_tasks and now callset_resilient_tasks_enabled(True)to retain eager boot recovery — matching the responses resilient samples (19–22), which already do this.Behavior
set_resilient_tasks_enabled(True))@taskapp that didn't opt in)Trade-off: for switch-off hosts, proactive reclaim of orphans from a prior crash moves from boot-time to the background loop (~interval) — anything re-requested is still reclaimed immediately by Layer 3. Ideal practice is to enable the switch; this change makes the un-enabled path degrade gracefully instead of blocking boot.
Backward compatibility
startup()only gains an optional keyword defaulting to today's behavior; it is internal (called by_base.py).TaskOptionschanges; no version-pin bump (set_resilient_tasks_enabledalready shipped).Tests
test_task_manager_optin.pyupdated: fakestartupaccepts the kwarg; addedrun_initial_scanassertions (skipped when switch off, runs when on). 11 passed.run_initial_scan=True):test_inline_recovery/test_recovery_lease_etag/test_lifecycle— 28 passed.