Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions python/agent-framework/sample-agent/.env.template
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# This is a demo .env file
# Replace with your actual values

# OpenAI Configuration
# OpenAI Configuration
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4o

# MCP Server Configuration
MCP_SERVER_PORT=8000
MCP_SERVER_HOST=localhost
MCP_PLATFORM_ENDPOINT=https://test.agent365.svc.cloud.dev.microsoft
MCP_PLATFORM_ENDPOINT=https://preprod.agent365.svc.cloud.dev.microsoft

# Logging
LOG_LEVEL=INFO
Expand All @@ -16,19 +17,16 @@ LOG_LEVEL=INFO
OBSERVABILITY_SERVICE_NAME=agent-framework-sample
OBSERVABILITY_SERVICE_NAMESPACE=agent-framework.samples

# Environment Configuration
# Environment and Authentication
# OBO Default-6e8b84fa-ae41-4a00-9ad1-934b73e5d73c
# Agentic auth - Default-5369a35c-46a5-4677-8ff9-2e65587654e7
# agentic auth - Default-5369a35c-46a5-4677-8ff9-2e65587654e7
ENV_ID=
BEARER_TOKEN=

# Authentication Mode
USE_AGENTIC_AUTH=true

# Agentic Authentication Scope
AGENTIC_AUTH_SCOPE=05879165-0320-489e-b644-f72b33f3edf0/.default

AGENT_ID=
AGENTIC_AUTH_SCOPE=05879165-0320-489e-b644-f72b33f3edf0/.default

# Agent365 Agentic Authentication Configuration
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID=
Expand All @@ -38,10 +36,9 @@ CONNECTIONS__SERVICE_CONNECTION__SETTINGS__SCOPES=https://api.botframework.com/.

AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__TYPE=AgenticUserAuthorization
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__SCOPES=https://graph.microsoft.com/.default
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__ALTERNATEBLUEPRINTCONNECTIONNAME=https://graph.microsoft.com/.default

CONNECTIONSMAP_0_SERVICEURL=*
CONNECTIONSMAP_0_CONNECTION=SERVICE_CONNECTION
CONNECTIONSMAP__0__SERVICEURL=*
CONNECTIONSMAP__0__CONNECTION=SERVICE_CONNECTION

# Optional: Server Configuration
PORT=3978
Expand All @@ -54,9 +51,5 @@ AZURE_OPENAI_API_VERSION="2024-02-01"

# Required for observability SDK
ENABLE_OBSERVABILITY=true
ENABLE_A365_OBSERVABILITY_EXPORTER=false
PYTHON_ENVIRONMENT=development

# Enable otel logs on AgentFramework SDK. Required for auto instrumentation
ENABLE_OTEL=true
ENABLE_SENSITIVE_DATA=true
ENABLE_KAIRO_EXPORTER=false
PYTHON_ENVIRONMENT=development
28 changes: 28 additions & 0 deletions python/agent-framework/sample-agent/MockAcitivity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"id": "94a8b018-7365-43b9-b9a9-bc7fc67be329",
"timestamp": "2025-09-18T22:21:54.612Z",
"channelId": "msteams",
"serviceUrl": "http://localhost:56150/_connector",
"recipient": {
"id": "[email protected]",
"name": "Agent365 Sellak Demo User Instance Nov7_1",
"agenticUserId": "7a4b6845-8a2c-4dfd-aeb9-fb9c5aa0027b",
"agenticAppId": "5d5288ae-72b5-4f2c-a92d-32ebcda338f3",
"tenantId": "e8a85347-fb53-4a91-9267-c616cbe1fd16",
"role": "agenticUser"
},
"from": {
"id": "29:1sH5NArUwkWAX-VmfHH3cfem2S89f2nB0N6aJ5zEjBoxT17fhSMdlYu_55ZyR8_OKFxS3BMnaGldHH3wdf_9K4Q",
"name": "Josjoy",
"aadObjectId": "03f4dd93-7e1e-41d6-bf7c-f211f9e96a13",
"role": "user"
},
"conversation": {
"id": "personal-chat-id",
"conversationType": "personal",
"tenantId": "00000000-0000-0000-0000-0000000000001"
},
"type": "message",
"text": "Send Email to [email protected] with detailed Comparison between NordicTrack Commercial 2450 vs. Peloton Tread treadmills. It should be atleast 200 words. Do not ask follow up questions and directly send the email. Use formal writing style. Sign off as A365TestingAgent Py Ztai A365-samples"
}

153 changes: 153 additions & 0 deletions python/agent-framework/sample-agent/SETUP-GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Quick Setup Guide

Get the A365 Python SDK sample running in 7 simple steps.

## Setup Steps

### 1. Verify prerequisites
First, ensure you have the required Microsoft Agent365 packages:

```powershell
# Navigate to the agent-framework directory (parent of sample-agent)
cd ..

# Check if dist folder exists with required wheel files
ls dist
```

**If the dist folder doesn't exist or is empty:**
- Create the `dist` folder: `mkdir dist`
- Download or copy the required `.whl` files to the `dist` folder:
- https://github.com/microsoft/Agent365-python/actions/runs/19200334217
- Click on Artifacts - python-3.11
- Download the zip file and extract the wheel files into the `dist` folder
- `microsoft_agents_a365_tooling-*.whl`
- `microsoft_agents_a365_tooling_extensions_agentframework-*.whl`
- `microsoft_agents_a365_observability_core-*.whl`
- `microsoft_agents_a365_observability_extensions_agent_framework-*.whl`
- `microsoft_agents_a365_runtime-*.whl`
- `microsoft_agents_a365_notifications-*.whl`

**✅ Success Check**: The `dist` folder should contain the Microsoft Agent365 wheel files.

```powershell
# Return to sample-agent directory for next steps
cd sample-agent
```

### 2. Set up environment configuration
Open PowerShell **in VS Code** (Terminal → New Terminal) and navigate to the sample-agent directory:

```powershell
# Navigate to the sample-agent directory (where this README is located)
# Make sure you're in the sample-agent folder
cd sample-agent

# Copy the environment template
copy .env.template .env
```

### 3. Update environment variables
Open the newly created `.env` file and update the following values:

```
AZURE_OPENAI_API_KEY=<your_azure_openai_api_key>
AZURE_OPENAI_ENDPOINT=<your_azure_openai_endpoint>
AZURE_OPENAI_DEPLOYMENT=<your_azure_openai_deployment>
AZURE_OPENAI_API_VERSION="2024-02-01"
```

### 4. Install uv
uv is a fast Python package manager. Open PowerShell **in VS Code** (Terminal → New Terminal) and run:

```powershell
# Install uv
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

# Add uv to PATH for this session (only if not already there)
if ($env:PATH -notlike "*$env:USERPROFILE\.local\bin*") {
$env:PATH += ";$env:USERPROFILE\.local\bin"
}

# Test that uv works
uv --version
```

### 5. Set up the project
Continue in the same terminal (make sure you're still in the sample-agent directory):

```powershell
# Verify you're in the right directory - you should see pyproject.toml
ls pyproject.toml

# First, check if Python is installed
python --version
```

**If Python is not found:**
- Download and install Python 3.11+ from https://python.org
- Make sure to check "Add Python to PATH" during installation
- Restart VS Code and try again

**If Python is found, continue:**
```powershell
# Create virtual environment with pip included
uv venv .venv --seed

# Activate the virtual environment
.\.venv\Scripts\Activate.ps1

# Verify setup - you should see (.venv) in your prompt
python --version
```

**✅ Success Check**: Your terminal shows `(.venv)` at the beginning and you can see pyproject.toml in the directory

### 6. Install dependencies

Due to version constraints in the wheel files, we install in two steps:

```powershell
### 3. Install dependencies
```powershell
uv pip install -e . --find-links ../dist --pre

**Important**: You may see some warning messages about dependencies. **This is normal and expected** - the agent will work correctly.

**✅ Success Check**:
- First command: "Installed X packages" (PyPI dependencies from requirements.txt)

### 7. Start the agent
```powershell
python start_with_generic_host.py
```

**✅ Success Check**: You should see:
```
🚀 Starting server on localhost:3978
🎯 Ready for testing!
======== Running on http://localhost:3978 ========
```

## Troubleshooting

**"python is not recognized"** → Install Python 3.11+ from python.org and check "Add Python to PATH"

**"uv not found"** → Restart your terminal and try step 1 again

**"No module named 'dotenv'"** → Try: `uv pip install python-dotenv`

**"No module named..."** → Make sure you see `(.venv)` in your prompt and that all three installation commands in step 6 completed successfully. Most missing dependencies should already be included in `requirements.txt`, but if you still get errors, you can install them individually:
```powershell
# For any additional missing modules:
uv pip install <module-name>
```

**Dependency conflict warnings** → These are expected! Continue with the next step - the agent will work fine

**"No solution found when resolving dependencies"** → Make sure you're using the three-step installation process in step 6 and that the dist folder exists with wheel files

**Agent won't start** → Check you're in the sample-agent directory and that all installation steps completed successfully

## Done!
Your agent is now running and ready for testing. Configuration values will be provided during the bug bash session.
5 changes: 4 additions & 1 deletion python/agent-framework/sample-agent/ToolingManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"mcpServers": [
{
"mcpServerName": "mcp_MailTools",
"mcpServerUniqueName": "mcp_MailTools"
"mcpServerUniqueName": "mcp_MailTools",
"url": "https://preprod.agent365.svc.cloud.dev.microsoft/agents/servers/mcp_MailTools",
"scope": "McpServers.Mail.All",
"audience": "05879165-0320-489e-b644-f72b33f3edf0"
}
]
}
9 changes: 5 additions & 4 deletions python/agent-framework/sample-agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ async def setup_mcp_servers(self, auth: Authorization, context: TurnContext):

logger.info("🔍 Starting MCP server setup...")

agent_user_id = os.getenv("AGENT_ID", "user123")
agentic_app_id = context._activity.recipient.agentic_app_id

use_agentic_auth = os.getenv("USE_AGENTIC_AUTH", "false").lower() == "true"

logger.info(f"🆔 Agent User ID: {agent_user_id}")
logger.info(f"🆔 Agentic App Id: {agentic_app_id}")
logger.info(f"🔐 Using agentic auth: {use_agentic_auth}")

if use_agentic_auth:
Expand All @@ -246,7 +247,7 @@ async def setup_mcp_servers(self, auth: Authorization, context: TurnContext):
chat_client=self.chat_client,
agent_instructions="You are a helpful assistant with access to tools.",
initial_tools=[],
agentic_app_id=agent_user_id,
agentic_app_id=agentic_app_id,
environment_id=self.auth_options.env_id,
auth=auth,
turn_context=context,
Expand All @@ -260,7 +261,7 @@ async def setup_mcp_servers(self, auth: Authorization, context: TurnContext):
chat_client=self.chat_client,
agent_instructions="You are a helpful assistant with access to tools.",
initial_tools=[],
agentic_app_id=agent_user_id,
agentic_app_id=agentic_app_id,
environment_id=self.auth_options.env_id,
auth=auth,
auth_token=self.auth_options.bearer_token,
Expand Down
4 changes: 3 additions & 1 deletion python/agent-framework/sample-agent/host_agent_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ async def cleanup_on_shutdown(app):
app.on_shutdown.append(cleanup_on_shutdown)

try:
run_app(app, host="localhost", port=port, handle_signals=True)
# Use 0.0.0.0 for Azure App Service compatibility, localhost for local dev
host = "0.0.0.0" if os.getenv("WEBSITE_SITE_NAME") else "localhost"
run_app(app, host=host, port=port, handle_signals=True)
except KeyboardInterrupt:
print("\n👋 Server stopped")
except Exception as error:
Expand Down
40 changes: 22 additions & 18 deletions python/agent-framework/sample-agent/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ authors = [
{ name = "Microsoft", email = "[email protected]" }
]
dependencies = [
# AgentFramework SDK - The official package
# AgentFramework SDK - The official package (accepting beta versions)
"agent-framework-azure-ai",

# Microsoft Agents SDK - Official packages for hosting and integration
"microsoft-agents-hosting-aiohttp",
"microsoft-agents-hosting-core",
"microsoft-agents-authentication-msal",
"microsoft-agents-activity",
"microsoft-agents-hosting-aiohttp>=0.5.0",
"microsoft-agents-hosting-core>=0.5.0",
"microsoft-agents-authentication-msal>=0.5.0",
"microsoft-agents-activity>=0.5.0",

# Azure SDK components
"azure-identity",
"azure-identity>=1.25.0",

# Core dependencies
"python-dotenv",
"aiohttp",
"python-dotenv>=1.0.0",
"aiohttp>=3.9.0",

# HTTP server support for MCP servers
"uvicorn[standard]>=0.20.0",
Expand All @@ -36,13 +36,13 @@ dependencies = [
"typing-extensions>=4.0.0",

# Local packages from local index
# - Update package versions to match your built wheels
"microsoft_agents_a365_tooling >= 0.1.0",
"microsoft_agents_a365_tooling_extensions_agentframework >= 0.1.0",
"microsoft_agents_a365_observability_core >= 0.1.0",
"microsoft_agents_a365_observability_extensions_agent_framework >= 0.1.0",
"microsoft_agents_a365_runtime >= 0.1.0",
"microsoft_agents_a365_notifications >= 0.1.0",
# - Use version ranges that work with both dev versions and future production releases
"microsoft_agents_a365_tooling >= 0.1.0.dev11",
"microsoft_agents_a365_tooling_extensions_agentframework >= 0.1.0.dev11",
"microsoft_agents_a365_observability_core >= 0.1.0.dev11",
"microsoft_agents_a365_observability_extensions_agent_framework >= 0.1.0.dev11",
"microsoft_agents_a365_runtime >= 0.1.0.dev11",
"microsoft_agents_a365_notifications >= 0.1.0.dev11",
]
requires-python = ">=3.11"

Expand All @@ -54,8 +54,8 @@ url = "https://pypi.org/simple"
default = true

[[tool.uv.index]]
name = "microsoft_kairo"
url = "../../../../python/dist"
name = "microsoft_agents"
url = "../dist"
format = "flat"

[build-system]
Expand All @@ -66,7 +66,11 @@ build-backend = "hatchling.build"
packages = ["."]

[tool.uv]
dev-dependencies = [
# Allow pre-release versions for dependencies that require them
prerelease = "allow"

[dependency-groups]
dev = [
"pytest>=8.0",
"pytest-asyncio>=0.24.0",
"ruff>=0.1.0",
Expand Down