Skip to content

Python: use writable runtime directory for Foundry Skills sample#6606

Open
malsabbagh05 wants to merge 3 commits into
microsoft:mainfrom
malsabbagh05:fix/foundry-skills-writable-download-dir
Open

Python: use writable runtime directory for Foundry Skills sample#6606
malsabbagh05 wants to merge 3 commits into
microsoft:mainfrom
malsabbagh05:fix/foundry-skills-writable-download-dir

Conversation

@malsabbagh05

Copy link
Copy Markdown

Motivation & Context

The Foundry Skills hosted agent sample currently downloads skills under the sample directory. In hosted Foundry Agent Service, the application directory can be mounted read-only, so startup can fail when the sample tries to recreate downloaded_skills under /app.

This fixes #6571 by defaulting downloaded skills to a writable system temp directory while preserving an environment variable override for deployments that want a specific location.

Description & Review Guide

  • What are the major changes?

    • Default DOWNLOADED_SKILLS_DIR to <system-temp>/maf_downloaded_skills instead of a folder next to main.py.
    • Allow users to override the location with the DOWNLOADED_SKILLS_DIR environment variable.
    • Update the sample README and .env.example to document the runtime directory behavior.
  • What is the impact of these changes?

    • The sample can start in hosted containers where the app directory is read-only.
    • Local users can still choose a stable or inspectable download directory through DOWNLOADED_SKILLS_DIR.
    • No public API or package behavior changes. This only affects the sample.
  • What do you want reviewers to focus on?

    • Whether the temp-directory default is the right behavior for hosted Foundry Agent Service.
    • Whether the environment variable name and README wording are clear enough.

Related Issue

Fixes #6571

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label or add "[BREAKING]" to the title prefix, before or after any language prefix. A workflow keeps the label and title prefix in sync automatically.

Copilot AI review requested due to automatic review settings June 18, 2026 15:20
@moonbox3 moonbox3 added documentation Improvements or additions to documentation python Issues related to the Python codebase labels Jun 18, 2026

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.

Pull request overview

Updates the Foundry Skills hosted-agent Python sample to download skills into a writable runtime directory by default, avoiding failures when the application directory is mounted read-only in hosted Foundry Agent Service environments.

Changes:

  • Default the downloaded-skills directory to <system temp>/maf_downloaded_skills, while still allowing override via DOWNLOADED_SKILLS_DIR.
  • Update the sample README to explain the writable runtime directory behavior and override.
  • Update .env.example to document the optional DOWNLOADED_SKILLS_DIR setting.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/main.py Switches the default downloaded-skills path from the app directory to the system temp directory, with an env var override.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/README.md Documents the new default runtime directory behavior and how to override it.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/.env.example Adds documentation for the optional DOWNLOADED_SKILLS_DIR env var.

Comment on lines +38 to +41
# Defaults to a system temp location because hosted containers may mount the
# application directory read-only. Set DOWNLOADED_SKILLS_DIR to override it.
_DEFAULT_DOWNLOADED_SKILLS_DIR: Final = Path(tempfile.gettempdir()) / "maf_downloaded_skills"
DOWNLOADED_SKILLS_DIR: Final = Path(os.environ.get("DOWNLOADED_SKILLS_DIR", str(_DEFAULT_DOWNLOADED_SKILLS_DIR)))
```

The downloaded `SKILL.md` files land under `downloaded_skills/<name>/SKILL.md` next to `main.py`. This directory is recreated from scratch on every run, so deleting it manually is never necessary.
The downloaded `SKILL.md` files land under `<downloaded-skills-dir>/<name>/SKILL.md`. The directory is recreated from scratch on every run, so deleting it manually is never necessary.
@malsabbagh05

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python Issues related to the Python codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Foundry Hosted Agent Samples - /app is read only in Hosted Foundry Agent Service

3 participants