Fix docstring/load_dotenv ordering in foundry samples and add try/finally cleanup

Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/382df85c-cf3c-4802-97e0-a6df35fc9876

Co-authored-by: chetantoshniwal <255221507+chetantoshniwal@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-01 18:56:51 +00:00
committed by Eduard van Valkenburg
Unverified
parent bbae6401b1
commit e26c3580fb
6 changed files with 33 additions and 30 deletions
@@ -7,8 +7,6 @@ from agent_framework.foundry import FoundryAgent
from azure.identity import AzureCliCredential
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
"""
Foundry Agent — Connect to a pre-configured agent in Microsoft Foundry
@@ -22,6 +20,9 @@ Environment variables:
FOUNDRY_AGENT_VERSION — Version of the agent (optional, for PromptAgents)
"""
# Load environment variables from .env file
load_dotenv()
async def main() -> None:
agent = FoundryAgent(