Skip to content

Commit 45e9d9f

Browse files
committed
Update sample agent files
1 parent c89f1bf commit 45e9d9f

49 files changed

Lines changed: 3931 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__TYPE=AgenticUserAuthorization
2+
3+
CONNECTIONSMAP_0_SERVICEURL=*
4+
CONNECTIONSMAP_0_CONNECTION=SERVICE_CONNECTION
5+
6+
7+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID=6eba289a-f3c2-4fed-ae31-e917548503ff
8+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET=rd.8Q~cMU2akle4M0tgsUCrHWpkFz9lzSO7L4b0-
9+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID=badf1f56-284d-4dc5-ac59-0dd53900e743
10+
11+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__SCOPES=5a807f24-c9de-44ee-a3a7-329e88a00ffc/.default
12+
13+
AZURE_OPENAI_API_KEY="9D0JCBGo9t8JttlbJRQAzoFP1oPNJ4U2VvWApq5jMrHv00CbdhpWJQQJ99BJACYeBjFXJ3w3AAABACOGYlrX"
14+
AZURE_OPENAI_ENDPOINT="https://a365-hw-openai-sentinel.openai.azure.com/"
15+
AZURE_OPENAI_DEPLOYMENT="gpt-4o-mini"
16+
17+
ENABLE_A365_OBSERVABILITY=true
18+
ENABLE_A365_OBSERVABILITY_EXPORTER=false
19+
# PYTHON_ENVIRONMENT=production
20+
AGENT_ID=6eba289a-f3c2-4fed-ae31-e917548503ff
21+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__ALT_BLUEPRINT_NAME=SERVICE_CONNECTION
22+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__SCOPES=https://graph.microsoft.com/.default
23+
CONNECTIONSMAP__0__SERVICEURL=*
24+
CONNECTIONSMAP__0__CONNECTION=SERVICE_CONNECTION
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__TYPE=AgenticUserAuthorization
2+
3+
CONNECTIONSMAP_0_SERVICEURL=*
4+
CONNECTIONSMAP_0_CONNECTION=SERVICE_CONNECTION
5+
6+
7+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID=38987164-942b-4fea-97f9-c630b0ca523a
8+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET=uZY8Q~lyRSymXFu6JoVqL6fhs8Tb53P4nRlq~bpJ
9+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID=badf1f56-284d-4dc5-ac59-0dd53900e743
10+
11+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__SCOPES=5a807f24-c9de-44ee-a3a7-329e88a00ffc/.default
12+
13+
AZURE_OPENAI_API_KEY="9D0JCBGo9t8JttlbJRQAzoFP1oPNJ4U2VvWApq5jMrHv00CbdhpWJQQJ99BJACYeBjFXJ3w3AAABACOGYlrX"
14+
AZURE_OPENAI_ENDPOINT="https://a365-hw-openai-sentinel.openai.azure.com/"
15+
AZURE_OPENAI_DEPLOYMENT="gpt-4o-mini"
16+
17+
ENABLE_A365_OBSERVABILITY=true
18+
ENABLE_A365_OBSERVABILITY_EXPORTER=true
19+
# PYTHON_ENVIRONMENT=production
20+
AGENT_ID=38987164-942b-4fea-97f9-c630b0ca523a
21+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__ALT_BLUEPRINT_NAME=SERVICE_CONNECTION
22+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__SCOPES=https://graph.microsoft.com/.default
23+
CONNECTIONSMAP__0__SERVICEURL=*
24+
CONNECTIONSMAP__0__CONNECTION=SERVICE_CONNECTION
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Getting Started with Kairo Exporter Sample
2+
3+
This sample demonstrates how to build an Agent365 Python agent with comprehensive observability using the Kairo SDK. It showcases telemetry tracking for agent invocation, AI inference calls, and tool execution, with telemetry exported to the Agent365 service.
4+
5+
## 📋 Prerequisites
6+
7+
- Python 3.11 or higher
8+
- Azure OpenAI service account
9+
- Agent365 service registration
10+
- Microsoft 365 developer tenant (for authentication)
11+
12+
## 🛠️ Setup Instructions
13+
14+
### 1. Clone and Navigate
15+
16+
```bash
17+
cd Agent365/python/samples/getting_started_with_kairo_exporter
18+
```
19+
20+
### 2. Create Virtual Environment
21+
22+
```bash
23+
python -m venv .venv
24+
.venv\Scripts\activate # Windows
25+
# source .venv/bin/activate # macOS/Linux
26+
```
27+
28+
### 3. Install Dependencies
29+
30+
```bash
31+
pip install -r requirements.txt
32+
```
33+
34+
### 4. Environment Configuration
35+
36+
Copy the template and configure your environment:
37+
38+
```bash
39+
cp env.TEMPLATE .env
40+
```
41+
42+
Edit `.env` with your configuration:
43+
44+
```properties
45+
# Service Connection (this is the azure bot credentials)
46+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID=your-service-client-id
47+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET=your-service-client-secret
48+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID=your-tenant-id
49+
50+
# Agent Blueprint Connection (this is the agent credentials)
51+
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__CLIENTID=your-agent-client-id
52+
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__CLIENTSECRET=your-agent-client-secret
53+
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__TENANTID=your-tenant-id
54+
55+
# Agentic User Authorization
56+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__TYPE=AgenticUserAuthorization
57+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__ALT_BLUEPRINT_NAME=AGENTBLUEPRINT
58+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__SCOPES=https://graph.microsoft.com/.default
59+
60+
# Connection Mapping
61+
CONNECTIONSMAP__0__SERVICEURL=*
62+
CONNECTIONSMAP__0__CONNECTION=SERVICE_CONNECTION
63+
64+
# Azure OpenAI Configuration
65+
AZURE_OPENAI_API_KEY=your-openai-api-key
66+
AZURE_OPENAI_ENDPOINT=https://your-openai-resource.openai.azure.com/
67+
AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini
68+
69+
# Observability Settings
70+
ENABLE_OBSERVABILITY=true
71+
ENABLE_A365_OBSERVABILITY_EXPORTER=true # Canonical; enables Agent365 telemetry exporter
72+
PYTHON_ENVIRONMENT=development
73+
```
74+
```
75+
Legacy alias still accepted (deprecated):
76+
77+
```properties
78+
ENABLE_KAIRO_EXPORTER=true
79+
```
80+
81+
### 5. Run the Agent
82+
83+
**Using Python directly:**
84+
```bash
85+
python -m src.main
86+
```
87+
88+
## Install Agents Playground
89+
### Quick Install (Windows via winget)
90+
```
91+
winget install agentsplayground
92+
```
93+
94+
### Start Agents Playground
95+
Add agentsplayground to your PATH
96+
After installation run:
97+
```
98+
agentsplayground
99+
```
100+
This launches a web browser with the Microsoft 365 Agents Playground UI where you can configure and chat with your local agent.
101+
Use the Playground UI to send a message (e.g. "What is the weather in Seattle?").
102+
103+
Send a custom activity with the message and correct recipient object. Other fields can be left as is
104+
```json
105+
{
106+
"id": "94a8b018-7365-43b9-b9a9-bc7fc67be329",
107+
"timestamp": "2025-09-18T22:21:54.612Z",
108+
"channelId": "msteams",
109+
"serviceUrl": "http://localhost:56150/_connector",
110+
"recipient":
111+
{
112+
"id": "a365testingagent@testcsaaa.onmicrosoft.com",
113+
"name": "A365 Testing Agent",
114+
"agenticUserId": "ea1a172b-f443-4ee0-b8a1-27c7ab7ea9e5",
115+
"agenticAppId": "933f6053-d249-4479-8c0b-78ab25424002",
116+
"tenantId": "5369a35c-46a5-4677-8ff9-2e65587654e7",
117+
"role": "agenticUser"
118+
},
119+
"from":
120+
{
121+
"id": "29:1sH5NArUwkWAX-VmfHH3cfem2S89f2nB0N6aJ5zEjBoxT17fhSMdlYu_55ZyR8_OKFxS3BMnaGldHH3wdf_9K4Q",
122+
"name": "UserName",
123+
"aadObjectId": "03f4dd93-7e1e-41d6-bf7c-f211f9e96a13",
124+
"role": "user"
125+
},
126+
"conversation": {
127+
"id": "__PERSONAL_CHAT_ID__",
128+
"conversationType": "personal",
129+
"tenantId": "00000000-0000-0000-0000-0000000000001"
130+
},
131+
"type": "message",
132+
"text": "what can you do"
133+
}
134+
```
135+
136+
## 🏗️ Architecture Overview
137+
138+
### Observability Flow
139+
140+
1. **User Message**`InvokeAgentScope` starts
141+
2. **Token Exchange** → Agentic token obtained for telemetry export
142+
3. **AI Processing**`InferenceScope` tracks OpenAI calls
143+
4. **Tool Execution**`ExecuteToolScope` monitors tool operations
144+
5. **Response** → All telemetry exported to Agent365 service
145+
146+
### Authentication Flow
147+
148+
1. **Agent Registration**: Service connects using service connection credentials
149+
2. **User Authentication**: Agentic user authorization for each conversation
150+
3. **Token Exchange**: Tokens exchanged for proper audience/scopes
151+
4. **Telemetry Export**: Cached tokens used for Agent365 service authentication
152+
153+
## 🔧 Configuration Options
154+
155+
### Kairo Exporter Settings
156+
157+
In `start_server.py`, you can configure:
158+
159+
```python
160+
success = configure(
161+
service_name="AzureOpenAiKairoTracing", # Service identifier
162+
service_namespace="AzureOpenAiKairoTesting", # Namespace
163+
logger_name="kairo", # Logger name
164+
token_resolver=token_resolver_func, # Token resolution function
165+
cluster_category="preprod", # Target cluster (preprod/prod)
166+
)
167+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"tenantId": "badf1f56-284d-4dc5-ac59-0dd53900e743",
3+
"subscriptionId": "964de8b4-c259-4d89-a809-697ef73502f6",
4+
"resourceGroup": "nikhilc-rg",
5+
"location": "eastus",
6+
"environment": "prod",
7+
"needDeployment": true,
8+
"graphBaseUrl": "https://graph.microsoft.com",
9+
"clientAppId": "217fa152-bd72-431a-8329-82b6fbc2db95",
10+
"appServicePlanName": "nikhilc-rg-plan",
11+
"appServicePlanSku": "B1",
12+
"webAppName": "nikhilcagent0416-webapp",
13+
"agentIdentityDisplayName": "nikhilcagent0416 Identity",
14+
"agentBlueprintDisplayName": "nikhilcagent0416 Blueprint",
15+
"agentUserPrincipalName": "nikhilcagent0416@a365preview070.onmicrosoft.com",
16+
"agentUserDisplayName": "nikhilcagent0416 Agent User",
17+
"managerEmail": "Nikhilc@a365preview070.onmicrosoft.com",
18+
"agentUserUsageLocation": "US",
19+
"deploymentProjectPath": "C:\\Users\\nikhilc\\repos\\Agent365SDK\\Agent365-python\\build\\getting_started_with_kairo_exporter",
20+
"agentDescription": "nikhilcagent0416 - Agent 365 Agent"
21+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
debug Telemetry: agents-playground-cli/cliStart {"cleanProperties":{"isExec":"true","argv":"<REDACTED: user-file-path>,<REDACTED: user-file-path>,-e,http://localhost:3978/api/messages,-c,emulator"}}
2+
3+
log Listening on 56150
4+
log Microsoft 365 Agents Playground is being launched for you to debug the app: http://localhost:56150
5+
debug started web socket client
6+
debug started web socket client
7+
log Waiting for connection of endpoint: http://localhost:3978/api/messages
8+
log waiting for 1 resources: http://localhost:3978/api/messages
9+
log wait-on(42708) complete
10+
log Events recording disabled.
11+
debug Telemetry: agents-playground-server/eventsRecording {"cleanProperties":{"enabled":"false"}}
12+
13+
debug Telemetry: agents-playground-server/getConfig {"cleanProperties":{"internalConfig":"{\"locale\":\"en-US\",\"localTimezone\":\"America/Los_Angeles\",\"channelId\":\"emulator\",\"debugConfig\":{\"eventsRecordingEnabled\":false}}"}}
14+
15+
debug Telemetry: agents-playground-server/error {"cleanProperties":{"stack":"\"Error: Request failed with status code 500\\n at UserBotError (<REDACTED: user-file-path> (<REDACTED: user-file-path> (<REDACTED: user-file-path> (node:internal/process/task_queues:95:5)\\n at async ConversationUpdateUserBotAccessor.sendInstallationMemberAddedActivity (<REDACTED: user-file-path>)\"","message":"\"Request failed with status code 500\"","code":"\"UserBotError\"","innerHttpError":"{\"statusCode\":500,\"body\":\"500 Internal Server Error\\n\\nServer got itself in trouble\"}"}}
16+
17+
log InternalServiceError: Request failed with status code 500
18+
at UserBotError (C:\snapshot\packages\cli\dist\bundled.js)
19+
at ConversationUpdateUserBotAccessor.handleAxiosError (C:\snapshot\packages\cli\dist\bundled.js)
20+
at ConversationUpdateUserBotAccessor.sendActivity (C:\snapshot\packages\cli\dist\bundled.js)
21+
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
22+
at async ConversationUpdateUserBotAccessor.sendInstallationMemberAddedActivity (C:\snapshot\packages\cli\dist\bundled.js) {
23+
code: 'UserBotError',
24+
innerHttpError: {
25+
statusCode: 500,
26+
body: '500 Internal Server Error\n\nServer got itself in trouble'
27+
}
28+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID=
2+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET=
3+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID=
4+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__ALT_BLUEPRINT_NAME=AGENTBLUEPRINT
5+
6+
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__CLIENTID=
7+
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__CLIENTSECRET=
8+
CONNECTIONS__AGENTBLUEPRINT__SETTINGS__TENANTID=
9+
10+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__TYPE=AgenticUserAuthorization
11+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__ALT_BLUEPRINT_NAME=AGENTBLUEPRINT
12+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__SCOPES=https://graph.microsoft.com/.default
13+
14+
CONNECTIONSMAP__0__SERVICEURL=*
15+
CONNECTIONSMAP__0__CONNECTION=SERVICE_CONNECTION
16+
17+
18+
AZURE_OPENAI_API_KEY=
19+
AZURE_OPENAI_ENDPOINT="https://a365-hw-openai-sentinel.openai.azure.com/"
20+
AZURE_OPENAI_DEPLOYMENT="gpt-4o-mini"
21+
22+
#Kairo SDK Specific keys
23+
ENABLE_OBSERVABILITY=true
24+
ENABLE_KAIRO_EXPORTER=true
25+
PYTHON_ENVIRONMENT=production/development
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"id": "7b0926a6-c4ee-445a-a913-bd054594bd09",
3+
"schemaVersion": "0.1.0-preview",
4+
"agentIdentityBlueprintId": "6eba289a-f3c2-4fed-ae31-e917548503ff",
5+
"communicationProtocol": "activityProtocol"
6+
}
6.12 KB
Loading
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/vdevPreview/MicrosoftTeams.schema.json",
3+
"id": "6eba289a-f3c2-4fed-ae31-e917548503ff",
4+
"name": {
5+
"short": "nikhilcpermtest Blueprint",
6+
"full": "nikhilcpermtest Blueprint"
7+
},
8+
"description": {
9+
"short": "A brief description of what your agent does.",
10+
"full": "A comprehensive description of your agent\u0027s capabilities and purpose. Explain what problems it solves, what data it can access, and how users will interact with it. This description helps users understand when and how to use your agent effectively."
11+
},
12+
"icons": {
13+
"outline": "outline.png",
14+
"color": "color.png"
15+
},
16+
"accentColor": "#9ec9d9",
17+
"version": "1.1.5",
18+
"manifestVersion": "devPreview",
19+
"developer": {
20+
"name": "Microsoft Corporation",
21+
"mpnId": "",
22+
"websiteUrl": "https://go.microsoft.com/fwlink/?LinkId=518028",
23+
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=518028",
24+
"termsOfUseUrl": "https://shares.datatransfer.microsoft.com/assets/Microsoft_Terms_of_Use.html"
25+
},
26+
"agenticUserTemplates": [
27+
{
28+
"id": "7b0926a6-c4ee-445a-a913-bd054594bd09",
29+
"file": "agenticUserTemplateManifest.json"
30+
}
31+
]
32+
}
Binary file not shown.

0 commit comments

Comments
 (0)