Python: Fix SK migration samples (#5047)

* Fix SK migration samples

* Fix env vars for SK

* Hard code model for sheel tool samples
This commit is contained in:
Tao Chen
2026-04-02 01:40:34 -07:00
committed by GitHub
Unverified
parent 628bb1af48
commit 3d87cec304
6 changed files with 27 additions and 10 deletions
@@ -610,14 +610,19 @@ jobs:
env:
FOUNDRY_PROJECT_ENDPOINT: ${{ vars.FOUNDRY_PROJECT_ENDPOINT || vars.AZURE_AI_PROJECT_ENDPOINT }}
FOUNDRY_MODEL: ${{ vars.FOUNDRY_MODEL || vars.AZUREOPENAI__RESPONSESDEPLOYMENTNAME }}
# Azure OpenAI configuration
# Azure OpenAI configuration for AF
AZURE_OPENAI_ENDPOINT: ${{ vars.AZUREOPENAI__ENDPOINT }}
AZURE_OPENAI_MODEL: ${{ vars.AZURE_OPENAI_DEPLOYMENT_NAME || vars.AZUREOPENAI__RESPONSESDEPLOYMENTNAME }}
# OpenAI configuration
# Azure OpenAI configuration for SK
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_DEPLOYMENT_NAME }}
# OpenAI key
OPENAI_API_KEY: ${{ secrets.OPENAI__APIKEY }}
# OpenAI configuration for AF
OPENAI_CHAT_MODEL: ${{ vars.OPENAI__CHATMODELID }}
OPENAI_RESPONSES_MODEL: ${{ vars.OPENAI__RESPONSESMODELID }}
OPENAI_MODEL: ${{ vars.OPENAI__RESPONSESMODELID }}
# OpenAI configuration for SK
OPENAI_CHAT_MODEL_ID: ${{ vars.OPENAI__CHATMODELID }}
# Copilot Studio
COPILOTSTUDIOAGENT__ENVIRONMENTID: ${{ secrets.COPILOTSTUDIOAGENT__ENVIRONMENTID }}
COPILOTSTUDIOAGENT__SCHEMANAME: ${{ secrets.COPILOTSTUDIOAGENT__SCHEMANAME }}
@@ -18,6 +18,9 @@ This sample demonstrates implementing a local shell tool using get_shell_tool(fu
that wraps Python's subprocess module. Unlike the hosted shell tool (get_shell_tool()),
local shell execution runs commands on YOUR machine, not in a remote container.
Currently not all models support the shell tool. Refer to the OpenAI documentation for the
list of supported models: https://developers.openai.com/api/docs/models/
SECURITY NOTE: This example executes real commands on your local machine.
Only enable this when you trust the agent's actions. Consider implementing
allowlists, sandboxing, or approval workflows for production use.
@@ -53,7 +56,10 @@ async def main() -> None:
print("=== OpenAI Agent with Local Shell Tool Example ===")
print("NOTE: Commands will execute on your local machine.\n")
client = OpenAIChatClient()
# Currently not all models support the shell tool. Refer to the OpenAI
# documentation for the list of supported models:
# https://developers.openai.com/api/docs/models/
client = OpenAIChatClient(model="gpt-5.4-nano")
local_shell_tool = client.get_shell_tool(
func=run_bash,
)
@@ -17,6 +17,9 @@ for executing shell commands in a managed container environment hosted by OpenAI
The shell tool allows the model to run commands like listing files, running scripts,
or performing system operations within a secure, sandboxed container.
Currently not all models support the shell tool. Refer to the OpenAI documentation
for the list of supported models: https://developers.openai.com/api/docs/models/
"""
@@ -24,7 +27,10 @@ async def main() -> None:
"""Example showing how to use the shell tool with OpenAI Chat."""
print("=== OpenAI Chat Client Agent with Shell Tool Example ===")
client = OpenAIChatClient()
# Currently not all models support the shell tool. Refer to the OpenAI
# documentation for the list of supported models:
# https://developers.openai.com/api/docs/models/
client = OpenAIChatClient(model="gpt-5.4-nano")
# Create a hosted shell tool with the default auto container environment
shell_tool = client.get_shell_tool()
@@ -23,12 +23,12 @@ async def run_semantic_kernel() -> None:
from semantic_kernel.connectors.ai.open_ai import OpenAISettings
openai_settings = OpenAISettings()
assert openai_settings.responses_model is not None, "Responses model ID must be set in OpenAISettings"
assert openai_settings.responses_model_id is not None, "Responses model ID must be set in OpenAISettings"
client = OpenAIResponsesAgent.create_client()
# SK response agents wrap OpenAI's hosted Responses API.
agent = OpenAIResponsesAgent(
ai_model=openai_settings.responses_model,
ai_model_id=openai_settings.responses_model_id,
client=client,
instructions="Answer in one concise sentence.",
name="Expert",
@@ -29,12 +29,12 @@ async def run_semantic_kernel() -> None:
return a + b
openai_settings = OpenAISettings()
assert openai_settings.responses_model is not None, "Responses model ID must be set in OpenAISettings"
assert openai_settings.responses_model_id is not None, "Responses model ID must be set in OpenAISettings"
client = OpenAIResponsesAgent.create_client()
# Plugins advertise callable tools to the Responses agent.
agent = OpenAIResponsesAgent(
ai_model=openai_settings.responses_model,
ai_model_id=openai_settings.responses_model_id,
client=client,
instructions="Use the add tool when math is required.",
name="MathExpert",
@@ -30,12 +30,12 @@ async def run_semantic_kernel() -> None:
from semantic_kernel.connectors.ai.open_ai import OpenAISettings
openai_settings = OpenAISettings()
assert openai_settings.responses_model is not None, "Responses model ID must be set in OpenAISettings"
assert openai_settings.responses_model_id is not None, "Responses model ID must be set in OpenAISettings"
client = OpenAIResponsesAgent.create_client()
# response_format requests schema-constrained output from the model.
agent = OpenAIResponsesAgent(
ai_model=openai_settings.responses_model,
ai_model_id=openai_settings.responses_model_id,
client=client,
instructions="Return launch briefs as structured JSON.",
name="ProductMarketer",