Python: fix(foundry-hosting): root hosted checkpoints under durable home dire…#7220
Open
PratikWayase wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes hosted WorkflowAgent checkpoint persistence in the Python Foundry hosting implementation by ensuring hosted checkpoints are stored under a durable home directory rather than the ephemeral filesystem root, so workflows can resume correctly after session compute recreation.
Changes:
- Added
ResponsesHostServer._resolve_checkpoint_root(is_hosted)to select{cwd}/.checkpointsfor local mode and$HOME/.checkpoints(with a safe fallback) for hosted mode. - Updated
ResponsesHostServer.__init__to use the new resolver for_checkpoint_storage_pathwhile preserving workflow-agent initialization behavior. - Added unit tests validating local vs hosted checkpoint path resolution, including missing/unusable
HOMEcases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py | Introduces checkpoint root resolution logic and updates server initialization to use it in hosted mode. |
| python/packages/foundry_hosting/tests/test_responses.py | Adds tests covering hosted/local checkpoint storage path behavior and edge cases around HOME. |
Comment on lines
+404
to
+413
| home = os.environ.get("HOME", "").strip() | ||
| if home and home != "/": | ||
| try: | ||
| resolved = Path(home).resolve() | ||
| if str(resolved) != str(resolved.root): | ||
| return str(resolved / ".checkpoints") | ||
| except (OSError, ValueError): | ||
| pass | ||
|
|
||
| return "/home/session/.checkpoints" |
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.
Motivation & Context
Previously,
ResponsesHostServer.__init__rooted the hosted checkpoint store at the absolute path/.checkpoints(the filesystem root). When a WorkflowAgent session compute was stopped and reached idle, a continuation request would recreate the compute, but the workflow checkpoint was not restored. Because the checkpoint was written to the ephemeral root path, it was lost, causing the workflow to restart from its initial state instead of resuming from the pendingrequest_infoapproval step.Description & Review Guide
What are the major changes?
_resolve_checkpoint_root(is_hosted)static method: When hosted, this method roots the store at{$HOME}/.checkpoints(reading theHOMEenvironment variable, default/home/session) instead of/.checkpoints.HOMEis not unset, blank, or the filesystem root (e.g.,/). If it is, it falls back to/home/session/.checkpointsto guarantee the store never lands under the read-only root, reintroducing the bug.__init__: The checkpoint path assignment now calls_resolve_checkpoint_root(self.config.is_hosted)instead of using the rawCHECKPOINT_STORAGE_PATHconstant.HOME, missingHOME, and unusableHOMEvalues (/, empty, whitespace).What is the impact of these changes?
$HOMEvolume, surviving across requests and compute recreation (idle → active).{cwd}/.checkpoints).What do you want reviewers to focus on?
_resolve_checkpoint_rootlogic, specifically theHOME=/guard, which prevents writing to/.checkpointseven if the environment variable is misconfigured.self._is_workflow_agent = Trueassignment was correctly preserved during the refactor.Related Issue
Fixes #7137
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.