Skip to content

Python: Fix samples#4980

Open
TaoChenOSU wants to merge 8 commits intomainfrom
taochen/python-fix-samples
Open

Python: Fix samples#4980
TaoChenOSU wants to merge 8 commits intomainfrom
taochen/python-fix-samples

Conversation

@TaoChenOSU
Copy link
Copy Markdown
Contributor

@TaoChenOSU TaoChenOSU commented Mar 30, 2026

Motivation and Context

Fix some of the samples

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 Mar 30, 2026
@TaoChenOSU TaoChenOSU added python samples Issue relates to the samples labels Mar 30, 2026
@TaoChenOSU TaoChenOSU marked this pull request as ready for review March 30, 2026 18:57
@github-actions github-actions bot changed the title Fix samples Python: Fix samples Mar 30, 2026
@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Mar 30, 2026
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 updates Python samples and CI sample-validation configuration to align with newer Foundry/Agent Framework APIs and environment variable naming, aiming to get sample validation passing again.

Changes:

  • Standardize workflow samples on FOUNDRY_PROJECT_ENDPOINT / FOUNDRY_MODEL and update many FoundryChatClient(..., model=...) call sites accordingly.
  • Update workflow samples to use workflow.as_agent() where appropriate instead of Agent(client=workflow, ...).
  • Adjust GitHub Actions sample-validation workflow/jobs and setup steps (including enabling new provider subdirs and adding Foundry envs).

Reviewed changes

Copilot reviewed 69 out of 69 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/scripts/sample_validation/create_dynamic_workflow_executor.py Increase default per-agent timeout used during dynamic sample validation.
python/samples/README.md Update documented env vars to FOUNDRY_* for getting started guidance.
python/samples/03-workflows/visualization/concurrent_with_visualization.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/tool-approval/sequential_builder_tool_approval.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/tool-approval/group_chat_builder_tool_approval.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/tool-approval/concurrent_builder_tool_approval.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/state-management/workflow_kwargs.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/state-management/state_with_agents.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/README.md Update listed workflow env vars to FOUNDRY_*.
python/samples/03-workflows/parallelism/fan_out_fan_in_edges.py Switch model env var lookup to FOUNDRY_MODEL and adjust prerequisites text.
python/samples/03-workflows/orchestrations/sequential_custom_executors.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/sequential_chain_only_agent_responses.py Replace Azure client usage with FoundryChatClient + Agent(...) construction.
python/samples/03-workflows/orchestrations/sequential_agents.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/magentic.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/magentic_human_plan_review.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/magentic_checkpoint.py Switch model env var lookup to FOUNDRY_MODEL for all agents.
python/samples/03-workflows/orchestrations/handoff_with_tool_approval_checkpoint_resume.py Switch model env var lookup to FOUNDRY_MODEL and adjust prerequisites text.
python/samples/03-workflows/orchestrations/handoff_with_code_interpreter_file.py Switch model env var lookup to FOUNDRY_MODEL and adjust prerequisites text.
python/samples/03-workflows/orchestrations/handoff_simple.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/handoff_autonomous.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/orchestrations/group_chat_simple_selector.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/group_chat_philosophical_debate.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/group_chat_agent_manager.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/concurrent_custom_aggregator.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/concurrent_custom_agent_executors.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/orchestrations/concurrent_agents.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/human-in-the-loop/sequential_request_info.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/human-in-the-loop/guessing_game_with_human_input.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/human-in-the-loop/group_chat_request_info.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/human-in-the-loop/concurrent_request_info.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/human-in-the-loop/agents_with_HITL.py Switch model env var lookup to FOUNDRY_MODEL and adjust how tool choice is provided.
python/samples/03-workflows/human-in-the-loop/agents_with_declaration_only_tools.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/human-in-the-loop/agents_with_approval_requests.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/declarative/student_teacher/main.py Switch model env var lookup to FOUNDRY_MODEL and update docstring env list.
python/samples/03-workflows/declarative/marketing/main.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/declarative/function_tools/main.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/declarative/deep_research/main.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/declarative/customer_support/main.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/declarative/agent_to_function_tool/main.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/control-flow/switch_case_edge_group.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/control-flow/simple_loop.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/control-flow/multi_selection_edge_group.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/control-flow/edge_condition.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/composition/sub_workflow_kwargs.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/checkpoint/workflow_as_agent_checkpoint.py Switch model env var lookup to FOUNDRY_MODEL and use workflow.as_agent().
python/samples/03-workflows/checkpoint/checkpoint_with_human_in_the_loop.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/agents/workflow_as_agent_with_session.py Switch model env var lookup to FOUNDRY_MODEL and use workflow.as_agent().
python/samples/03-workflows/agents/workflow_as_agent_reflection_pattern.py Switch model env var lookup to FOUNDRY_MODEL and use workflow.as_agent().
python/samples/03-workflows/agents/workflow_as_agent_kwargs.py Switch model env var lookup to FOUNDRY_MODEL and use workflow.as_agent().
python/samples/03-workflows/agents/workflow_as_agent_human_in_the_loop.py Switch model env var lookup to FOUNDRY_MODEL and use workflow.as_agent().
python/samples/03-workflows/agents/sequential_workflow_as_agent.py Switch model env var lookup to FOUNDRY_MODEL and use workflow.as_agent().
python/samples/03-workflows/agents/magentic_workflow_as_agent.py Switch model env var lookup to FOUNDRY_MODEL and use workflow.as_agent().
python/samples/03-workflows/agents/handoff_workflow_as_agent.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/agents/group_chat_workflow_as_agent.py Switch model env var lookup to FOUNDRY_MODEL.
python/samples/03-workflows/agents/custom_agent_executors.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/agents/concurrent_workflow_as_agent.py Switch model env var lookup to FOUNDRY_MODEL and use workflow.as_agent().
python/samples/03-workflows/agents/azure_chat_agents_tool_calls_with_feedback.py Switch model env var lookup to FOUNDRY_MODEL and simplify full-conversation handling.
python/samples/03-workflows/agents/azure_chat_agents_streaming.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/agents/azure_chat_agents_and_executor.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/agents/azure_ai_agents_with_shared_session.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/agents/azure_ai_agents_streaming.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/_start-here/step3_streaming.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/03-workflows/_start-here/step2_agents_in_a_workflow.py Switch model env var lookup to FOUNDRY_MODEL and update prerequisites text.
python/samples/02-agents/typed_options.py Update provider client constructor args and use Message list inputs for get_response.
python/samples/02-agents/context_providers/redis/redis_conversation.py Load .env via load_dotenv() for sample configuration.
python/samples/02-agents/compaction/compaction_provider.py Update OpenAIChatClient constructor arg name to model.
python/samples/01-get-started/README.md Remove outdated env-var setup snippet for getting started docs.
.github/workflows/python-sample-validation.yml Update sample-validation jobs/env vars and provider job structure; add Foundry envs.
.github/actions/sample-validation-setup/action.yml Add copilot --version to improve diagnostics in CI setup.

Comment on lines 173 to +176
Workflow samples that use `AzureOpenAIResponsesClient` expect:

- `AZURE_AI_PROJECT_ENDPOINT` (Azure AI Foundry Agent Service (V2) project endpoint)
- `AZURE_AI_MODEL_DEPLOYMENT_NAME` (model deployment name)
- `FOUNDRY_PROJECT_ENDPOINT` (Azure AI Foundry Agent Service (V2) project endpoint)
- `FOUNDRY_MODEL` (model deployment name)
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This section says “Workflow samples that use AzureOpenAIResponsesClient expect:” but the sample code under 03-workflows/ now uses FoundryChatClient (and there are no AzureOpenAIResponsesClient references in that folder). Please update the wording/heading to match the actual client used, otherwise the env-var guidance is confusing/misleading.

Copilot uses AI. Check for mistakes.
@@ -67,11 +67,13 @@ jobs:
# Azure AI configuration
AZURE_AI_PROJECT_ENDPOINT: ${{ vars.AZURE_AI_PROJECT_ENDPOINT }}
AZURE_AI_MODEL_DEPLOYMENT_NAME: ${{ vars.AZUREOPENAI__RESPONSESDEPLOYMENTNAME }}
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.

nit: are we changing this AZUREOPENAI__RESPONSESDEPLOYMENTNAME too to AZURE_OPENAI__RESPONSES_DEPLOYMENT_NAME ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need to consolidate it. We have both defined for our repo.

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

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants