Fix foundry samples: add model/env vars to code interpreter sample, fix optional agent version

Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/a758471e-f73b-4c1c-b5cb-1f1ae0b2971f

Co-authored-by: chetantoshniwal <255221507+chetantoshniwal@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-31 17:02:11 +00:00
committed by Eduard van Valkenburg
Unverified
parent 922b85485d
commit a58f55876c
2 changed files with 10 additions and 3 deletions
@@ -26,7 +26,7 @@ async def main() -> None:
agent = FoundryAgent(
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
agent_name=os.environ["FOUNDRY_AGENT_NAME"],
agent_version=os.environ["FOUNDRY_AGENT_VERSION"],
agent_version=os.environ.get("FOUNDRY_AGENT_VERSION"),
credential=AzureCliCredential(),
)
@@ -18,6 +18,10 @@ Foundry Chat Client with Code Interpreter and Files Example
This sample demonstrates using get_code_interpreter_tool() with Responses on Foundry
for Python code execution and data analysis with uploaded files.
Environment variables:
FOUNDRY_PROJECT_ENDPOINT — Azure AI Foundry project endpoint
FOUNDRY_MODEL — Model deployment name (e.g. "gpt-4o")
"""
# Helper functions
@@ -67,10 +71,13 @@ async def main() -> None:
# Initialize the underlying OpenAI client for file operations
credential = AzureCliCredential()
project_endpoint = os.environ.get("FOUNDRY_PROJECT_ENDPOINT")
# Create FoundryChatClient first, then reuse its project client for file operations
client = FoundryChatClient(credential=credential, project_endpoint=project_endpoint)
client = FoundryChatClient(
credential=credential,
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
model=os.environ["FOUNDRY_MODEL"],
)
openai_client = client.project_client.get_openai_client()
temp_file_path, file_id = await create_sample_file_and_upload(openai_client)