Skip to content

Python: New Foundry Hosted Agents samples: RAG, Skills, and Memory#5822

Open
TaoChenOSU wants to merge 7 commits into
mainfrom
feature/python-foundry-hosted-samples-rag-memory-skills
Open

Python: New Foundry Hosted Agents samples: RAG, Skills, and Memory#5822
TaoChenOSU wants to merge 7 commits into
mainfrom
feature/python-foundry-hosted-samples-rag-memory-skills

Conversation

@TaoChenOSU
Copy link
Copy Markdown
Contributor

@TaoChenOSU TaoChenOSU commented May 13, 2026

Motivation and Context

We need more samples for MAF with Foundry Hosted Agents.

Description

This PR adds three:

  • Integration with AzureAISearch for RAG scenarios
image
  • Integration with Foundry Skills
image
  • Integration with Foundry Memory
image

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@TaoChenOSU TaoChenOSU self-assigned this May 13, 2026
Copilot AI review requested due to automatic review settings May 13, 2026 18:19
@TaoChenOSU TaoChenOSU added python samples Issue relates to the samples labels May 13, 2026
@github-actions github-actions Bot changed the title New Foundry Hosted Agents samples: RAG, Skills, and Memory Python: New Foundry Hosted Agents samples: RAG, Skills, and Memory May 13, 2026
@moonbox3 moonbox3 added the documentation Improvements or additions to documentation label May 13, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 62%

✓ Correctness

No actionable issues found in this dimension.

✓ Security Reliability

No actionable issues found in this dimension.

✓ Test Coverage

No actionable issues found in this dimension.

✗ Design Approach

Two design issues stand out. The Azure Search RAG sample is built and documented as if sourceName/sourceLink are injected into model context for citations, but the actual AzureAISearchContextProvider only emits document text plus doc_id, so those schema fields never influence responses. Separately, the Foundry Skills sample downloads remote ZIPs and unpacks them with extractall() without any path containment check, which bypasses the repo’s own path-traversal safeguards for file-based skills and allows a crafted archive to write outside downloaded_skills/<name>. That does not advance the sample feature itself, but it does create broad lockfile churn and merge-conflict risk in a repo that explicitly prefers targeted lock updates.

Flagged Issues

  • The RAG sample's citation design relies on sourceName/sourceLink fields that the provider never reads: AzureAISearchContextProvider._extract_document_text() only pulls from content-like fields plus doc_id (see _context_provider.py:980-995 and tests at test_aisearch_context_provider.py:884-914). Either the sample needs a custom provider that formats those fields into context, or the docs/schema should be reduced to what the provider actually consumes.

Automated review by TaoChenOSU's agents

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Python Foundry-hosted Responses samples demonstrating Azure AI Search RAG and Foundry Skills, plus updates the hosted sample index to include them.

Changes:

  • Adds an Azure AI Search RAG hosted-agent sample with provisioning guidance, runtime code, Docker packaging, and deployment manifests.
  • Adds a Foundry Skills hosted-agent sample with sample skills, skill provisioning, startup download/bootstrap, Docker packaging, and deployment manifests.
  • Updates the Foundry hosted-agent README sample list.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
python/samples/04-hosting/foundry-hosted-agents/README.md Adds RAG and Skills samples to the Responses sample table.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/.dockerignore Excludes local/dev files from the RAG image build.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/.env.example Documents required RAG environment variables.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/Dockerfile Packages the RAG sample as a Python container.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/README.md Documents setup, provisioning, running, and deployment for RAG.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/agent.manifest.yaml Adds Foundry deployment manifest for the RAG sample.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/agent.yaml Adds hosted-agent runtime config for RAG.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/main.py Implements the RAG hosted agent using Azure AI Search context.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/provision_index.py Adds a helper to create/seed the Azure AI Search index.
python/samples/04-hosting/foundry-hosted-agents/responses/08_azure_search_rag/requirements.txt Lists RAG sample dependencies.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/.dockerignore Excludes provisioning/source/runtime artifacts from the Skills image.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/.env.example Documents required Skills sample environment variables.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/Dockerfile Packages the Skills sample as a Python container.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/README.md Documents Foundry Skills authoring, provisioning, runtime loading, and deployment.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/agent.manifest.yaml Adds Foundry deployment manifest for the Skills sample.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/agent.yaml Adds hosted-agent runtime config for Skills.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/main.py Implements startup skill download and hosted agent wiring.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/provision_skills.py Adds a helper to upload local SKILL.md packages to Foundry Skills.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/requirements.txt Lists Skills sample dependencies.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/skills/escalation-policy/SKILL.md Adds escalation-policy skill content.
python/samples/04-hosting/foundry-hosted-agents/responses/09_foundry_skills/skills/support-style/SKILL.md Adds support-style skill content.

Comment thread python/samples/04-hosting/foundry-hosted-agents/README.md Outdated
@TaoChenOSU TaoChenOSU marked this pull request as ready for review May 14, 2026 00:38
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 61%

✓ Correctness

Three new Foundry Hosted Agents samples (RAG, Skills, Memory) are well-structured and mostly correct. API usage matches framework signatures, the zip-slip guard is properly implemented, and previous review comments appear addressed. One correctness concern: the memory sample creates an async DefaultAzureCredential without closing it, unlike the skills sample (which uses async with) and existing samples (which use the sync credential).

✓ Security Reliability

The new samples are well-structured with good security practices (zip-slip guard in the skills sample, proper async-with credential management in provisioning scripts). The one remaining issue is the Foundry Memory sample (10_foundry_memory/main.py) where an async DefaultAzureCredential is created inline and never closed—the same pattern that was previously flagged and fixed in the other two samples in this PR.

✓ Test Coverage

No actionable issues found in this dimension.

✗ Design Approach

The new Foundry Memory sample has one design-level issue: it documents per-user cross-session memory isolation, but the implementation passes a literal {{$userId}} scope string into FoundryMemoryProvider and nothing in the hosting path shown here substitutes that placeholder. That means all callers would share the same memory scope instead of being isolated by user.

Flagged Issues

  • python/samples/04-hosting/foundry-hosted-agents/responses/10_foundry_memory/main.py:46 uses scope="{{$userId}}", but FoundryMemoryProvider forwards self.scope verbatim to the memory store (_memory_provider.py:170-173,198-203,259-264) and the Responses host only passes message history into agent.run (_responses.py:296-305). As written, this collapses all users into one shared memory scope rather than isolating memories per user.

Automated review by TaoChenOSU's agents

project_client=client.project_client,
memory_store_name=os.environ["MEMORY_STORE_NAME"],
# Scope memories by user id, so each user that interacts with the agent
# has their own isolated memories in the store (assuming those users are
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sample's per-user isolation depends on {{$userId}} being replaced at runtime, but the code path never performs that substitution. FoundryMemoryProvider sends self.scope verbatim to search_memories / begin_update_memories, and the Responses host only forwards messages/history into agent.run. Every caller shares the literal scope string {{$userId}}, so memories bleed across users instead of being isolated.

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 samples Issue relates to the samples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants