-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[agentserver-core] Gate resilient TaskManager auto-init behind durable-task opt-in #48367
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
Open
Nathandrake229
wants to merge
8
commits into
main
Choose a base branch
from
namantyagi/agentserver-core-task-optin
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.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
889dab7
[agentserver-core] Gate resilient TaskManager auto-init behind durabl…
bd26125
Preserve late-registration via lazy TaskManager bootstrap
9282136
Guard shutdown import of tasks module; harden lazy-bootstrap test
a7b1a02
Gate TaskManager on explicit switch AND declared tasks; drop lazy fac…
951c6a3
Always construct TaskManager; gate only the network recovery scan
f3da0cf
Gate recovery scan on (task declared OR switch) instead of AND
2e39002
Fix stale AND wording in test module docstring (semantics are OR)
2aaa4e6
Merge branch 'main' into namantyagi/agentserver-core-task-optin
Nathandrake229 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| apiMdSha256: 803cc6578b722fdf575384cd50fee9429f690be7e4036cd805ff4fa9090892f8 | ||
| apiMdSha256: fd3b7bd1ae87d9b18719027594934c55d968973f159fbc8a5b416d227c67282c | ||
| parserVersion: 0.3.30 | ||
| pythonVersion: 3.14.3 | ||
| pythonVersion: 3.12.10 |
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
60 changes: 60 additions & 0 deletions
60
sdk/agentserver/azure-ai-agentserver-core/azure/ai/agentserver/core/tasks/_enablement.py
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,60 @@ | ||
| # --------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # --------------------------------------------------------- | ||
| """Explicit force-enable switch for the resilient task recovery scan. | ||
|
|
||
| The resilient ``TaskManager`` is always constructed by ``AgentServerHost`` (a | ||
| cheap, in-memory object that makes no task-store calls), so ``get_task_manager`` | ||
| and ``.run()`` / ``.start()`` work regardless of this switch. What this switch | ||
| affects is only the network-backed **startup recovery scan** (a hosted | ||
| task-store ``list()`` plus credential-token acquisition) and the periodic | ||
| recovery loop it spawns. | ||
|
|
||
| That recovery runs at startup when EITHER a durable task has been declared | ||
| (``@task`` / ``@multi_turn_task``) OR this switch is on. So an app that uses | ||
| tasks gets recovery automatically; this switch is a **force-enable** that | ||
| starts the recovery loop even before any task is declared (useful when tasks | ||
| are registered lazily after startup — the running loop then picks them up). | ||
|
|
||
| The switch is process-global and defaults to ``False``. It is intentionally | ||
| decoupled from any ``AgentServerHost`` instance so it can be flipped | ||
| independently at import time, e.g.:: | ||
|
|
||
| from azure.ai.agentserver.core.tasks import set_resilient_tasks_enabled | ||
|
|
||
| set_resilient_tasks_enabled(True) | ||
| """ | ||
|
|
||
| _RESILIENT_TASKS_ENABLED: bool = False | ||
|
|
||
|
|
||
| def set_resilient_tasks_enabled(value: bool = True) -> None: | ||
| """Force-enable (or clear) the resilient task recovery scan process-wide. | ||
|
|
||
| Setting this to ``True`` starts the startup recovery scan + periodic | ||
| recovery loop even when no durable task is declared at startup. It does | ||
| NOT gate the ``TaskManager``'s existence: ``.run()`` / ``.start()`` work | ||
| whether or not this is set — this only controls automatic crash recovery. | ||
|
|
||
| Must be called before ``AgentServerHost`` lifespan startup (typically at | ||
| import time) to take effect. Defaults to enabling when called with no | ||
| argument. | ||
|
|
||
| :param value: ``True`` to force-enable recovery, ``False`` to clear. | ||
| :type value: bool | ||
| """ | ||
| global _RESILIENT_TASKS_ENABLED # pylint: disable=global-statement | ||
| _RESILIENT_TASKS_ENABLED = bool(value) | ||
|
|
||
|
|
||
| def resilient_tasks_enabled() -> bool: | ||
| """Return whether the recovery scan was explicitly force-enabled. | ||
|
|
||
| Note this reflects only the switch — recovery also runs automatically when | ||
| a durable task is declared, so a ``False`` return does not mean recovery is | ||
| off, nor that tasks are unavailable. | ||
|
|
||
| :return: ``True`` if :func:`set_resilient_tasks_enabled` turned it on. | ||
| :rtype: bool | ||
| """ | ||
| return _RESILIENT_TASKS_ENABLED |
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
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.