[agentserver] Process-isolated hard execution cap for task timeouts (spawn + fork) - #48568
Draft
Nathandrake229 wants to merge 1 commit into
Draft
[agentserver] Process-isolated hard execution cap for task timeouts (spawn + fork)#48568Nathandrake229 wants to merge 1 commit into
Nathandrake229 wants to merge 1 commit into
Conversation
…ts (spawn + fork) Enforce a hard cap on per-turn task timeouts by running the handler in an isolated child process the timeout watchdog can SIGKILL after a bounded grace, without disrupting the main container or co-located tasks, and without the recovery system resurrecting the force-stopped turn. - Opt-in, default off (AGENTSERVER_TASK_ISOLATION); zero overhead when off. - Tiered watchdog: cooperative cancel -> grace -> SIGKILL -> existing finalization (one-shot delete / multi-turn drain-or-suspend). - Spawn backend (create_subprocess_exec, portable) + optional per-chain reuse with idle-TTL (AGENTSERVER_TASK_WORKER_REUSE). - Fork backend (multiprocessing fork, Linux-only, AGENTSERVER_TASK_WORKER_FORK): inherits the imported app (COW, ~ms start, no re-import), reuses all shared worker code via a _ForkProcAdapter; child sanitized via _after_fork_child. - Durable terminal-outcome IPC contract; marker + backstop recovery detection. - Design doc: docs/task-timeout-isolation-design.md. - Tests: spawn + fork one-shot/multi-turn/reuse (green on Linux; fork skips on non-Linux). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6a7cdfb6-6f7c-483b-adef-432cc13f4149
|
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
Adds a hard execution cap for per-turn task timeouts in
azure-ai-agentserver-core(durable/resilient tasks). When a per-turntimeoutelapses and the handler ignores the cooperative cancel, the framework can now force-stop it after a bounded grace by running the handler in an isolated child process the timeout watchdog canSIGKILL— without disrupting the main container or co-located tasks, and without the recovery system resurrecting the force-stopped turn.Design
Full design doc included:
sdk/agentserver/azure-ai-agentserver-core/docs/task-timeout-isolation-design.md(common core + backend-specific internals for spawn vs fork).Key points:
AGENTSERVER_TASK_ISOLATION); zero overhead when off —_run_handlershort-circuits toawait fn(ctx).SIGKILL; in-process injectors are non-authoritative/unsafe (documented, with the full options-evaluated table).ctx.timeout_exceeded→ctx.cancel, persisttimeout_cancelled_atmarker) → grace (AGENTSERVER_TASK_TIMEOUT_HARDCAP_GRACE_SECONDS, default 1h) →SIGKILL→_WorkerKilled→CancelledError→ existing finalization (one-shot delete / multi-turn drain-or-suspend).MSG_RESULT/SUSPEND/EXIT_FOR_RECOVERY/ERROR+ metadata); parent stays sole store/lease writer; marker + derived backstop make recovery finalize (not re-run) a timed-out turn.Backends (differ only in worker internals)
create_subprocess_exec, portable default): blank interpreter, re-imports app, std-pipe transport.multiprocessingfork, Linux-only,AGENTSERVER_TASK_WORKER_FORK): inherits the imported app (COW, ~ms start, no re-import);_after_fork_childsanitization (set_task_manager(None), close inherited peer fd, fresh loop);socketpairtransport; reuses all shared worker code via a_ForkProcAdapter.AGENTSERVER_TASK_WORKER_REUSE, multi-turn only): a spawn optimization (import once/chain); fork barely needs it.All backends share the same protocol,
IsolatedRun/PersistentWorker, bidirectionalctxbridge, terminal contract, and recovery — selected by a single OS-branch at worker creation.Testing (on the pre-rebase base)
tests/taskssuite green with isolation off (654 passed) — default path unchanged.AGENTSERVER_TASK_WORKER_FORK=1; parent container survived fork-child hard-kills and kept serving).Follow-ups
metadatamodel (blocks the isolation tests on this branch).PR_SET_PDEATHSIGorphan-child hard guarantee (Linux).🤖 Draft opened via GitHub Copilot CLI.