Skip to content

Commit 48d912d

Browse files
Add microsoft-agents-a365-settings package for Python SDK parity
Co-authored-by: sergioescalera <8428450+sergioescalera@users.noreply.github.com>
1 parent 40072ee commit 48d912d

File tree

17 files changed

+1250
-0
lines changed

17 files changed

+1250
-0
lines changed
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Microsoft Agent 365 Settings SDK
2+
3+
This package provides functionality to manage Agent 365 settings templates and agent instance settings.
4+
5+
## Overview
6+
7+
The Settings SDK enables developers to:
8+
9+
- **Get or Set Agent Setting Templates by Agent Type**: Configure default settings templates that apply to specific types of agents.
10+
- **Get or Set Agent Settings by Agent Instance**: Configure settings for individual agent instances.
11+
12+
## Installation
13+
14+
```bash
15+
pip install microsoft-agents-a365-settings
16+
```
17+
18+
## Usage
19+
20+
### Creating the Service
21+
22+
```python
23+
from microsoft_agents_a365.settings import AgentSettingsService
24+
25+
# Create a service instance
26+
async with AgentSettingsService() as service:
27+
# Use the service
28+
...
29+
30+
# Or manage lifecycle manually
31+
service = AgentSettingsService()
32+
try:
33+
# Use the service
34+
...
35+
finally:
36+
await service.close()
37+
```
38+
39+
### Getting Settings Template by Agent Type
40+
41+
```python
42+
from microsoft_agents_a365.settings import AgentSettingsService
43+
44+
async def get_template(agent_type: str, auth_token: str):
45+
async with AgentSettingsService() as service:
46+
template = await service.get_settings_template_by_agent_type(
47+
agent_type=agent_type,
48+
auth_token=auth_token,
49+
)
50+
return template
51+
```
52+
53+
### Setting a Settings Template
54+
55+
```python
56+
from microsoft_agents_a365.settings import (
57+
AgentSettingsService,
58+
AgentSettingsTemplate,
59+
AgentSettingProperty,
60+
)
61+
62+
async def set_template(agent_type: str, auth_token: str):
63+
template = AgentSettingsTemplate(
64+
agent_type=agent_type,
65+
name="Custom Agent Template",
66+
properties=[
67+
AgentSettingProperty(
68+
name="maxRetries",
69+
value="3",
70+
type="integer",
71+
required=True,
72+
description="Maximum number of retry attempts",
73+
)
74+
],
75+
)
76+
77+
async with AgentSettingsService() as service:
78+
result = await service.set_settings_template_by_agent_type(
79+
agent_type=agent_type,
80+
template=template,
81+
auth_token=auth_token,
82+
)
83+
return result
84+
```
85+
86+
### Getting Settings by Agent Instance
87+
88+
```python
89+
from microsoft_agents_a365.settings import AgentSettingsService
90+
91+
async def get_settings(agent_instance_id: str, auth_token: str):
92+
async with AgentSettingsService() as service:
93+
settings = await service.get_settings_by_agent_instance(
94+
agent_instance_id=agent_instance_id,
95+
auth_token=auth_token,
96+
)
97+
if settings:
98+
for prop in settings.properties:
99+
print(f"{prop.name}: {prop.value}")
100+
return settings
101+
```
102+
103+
### Setting Agent Instance Settings
104+
105+
```python
106+
from microsoft_agents_a365.settings import (
107+
AgentSettingsService,
108+
AgentSettings,
109+
AgentSettingProperty,
110+
)
111+
112+
async def set_settings(agent_instance_id: str, auth_token: str):
113+
settings = AgentSettings(
114+
agent_instance_id=agent_instance_id,
115+
agent_type="custom-agent",
116+
properties=[
117+
AgentSettingProperty(
118+
name="apiEndpoint",
119+
value="https://api.example.com",
120+
type="string",
121+
)
122+
],
123+
)
124+
125+
async with AgentSettingsService() as service:
126+
result = await service.set_settings_by_agent_instance(
127+
agent_instance_id=agent_instance_id,
128+
settings=settings,
129+
auth_token=auth_token,
130+
)
131+
return result
132+
```
133+
134+
## Configuration
135+
136+
The service uses the following environment variables for configuration:
137+
138+
| Environment Variable | Description | Default |
139+
|---------------------|-------------|---------|
140+
| `MCP_PLATFORM_ENDPOINT` | Override the base URL for the Agent 365 platform | `https://agent365.svc.cloud.microsoft` |
141+
| `MCP_PLATFORM_AUTHENTICATION_SCOPE` | The authentication scope for the platform | `ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default` |
142+
143+
## Models
144+
145+
### AgentSettingsTemplate
146+
147+
Represents a settings template for a specific agent type.
148+
149+
| Property | Type | Description |
150+
|----------|------|-------------|
151+
| `id` | str | Unique identifier of the template |
152+
| `agent_type` | str | The agent type this template applies to |
153+
| `name` | str | Display name of the template |
154+
| `description` | str \| None | Optional description |
155+
| `version` | str | Template version (default: "1.0") |
156+
| `properties` | list[AgentSettingProperty] | Collection of setting properties |
157+
158+
### AgentSettings
159+
160+
Represents settings for a specific agent instance.
161+
162+
| Property | Type | Description |
163+
|----------|------|-------------|
164+
| `id` | str | Unique identifier of the settings |
165+
| `agent_instance_id` | str | The agent instance these settings belong to |
166+
| `template_id` | str \| None | Optional reference to the template |
167+
| `agent_type` | str | The agent type |
168+
| `properties` | list[AgentSettingProperty] | Collection of setting values |
169+
| `created_at` | datetime | Creation timestamp |
170+
| `modified_at` | datetime | Last modification timestamp |
171+
172+
### AgentSettingProperty
173+
174+
Represents a single setting property.
175+
176+
| Property | Type | Description |
177+
|----------|------|-------------|
178+
| `name` | str | Name of the setting |
179+
| `value` | str | Current value |
180+
| `type` | str | Value type (default: "string") |
181+
| `required` | bool | Whether the setting is required |
182+
| `description` | str \| None | Optional description |
183+
| `default_value` | str \| None | Optional default value |
184+
185+
## License
186+
187+
This project is licensed under the MIT License.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Copyright (c) Microsoft. All rights reserved.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) Microsoft. All rights reserved.
2+
3+
"""
4+
Microsoft Agent 365 Settings SDK.
5+
6+
This module provides functionality to manage Agent 365 settings templates
7+
and agent instance settings.
8+
"""
9+
10+
from .agent_settings_service import AgentSettingsService
11+
from .agent_settings_service_protocol import AgentSettingsServiceProtocol
12+
from .constants import (
13+
DEFAULT_PLATFORM_AUTH_SCOPE,
14+
DEFAULT_PLATFORM_BASE_URL,
15+
PLATFORM_AUTH_SCOPE_CONFIG_KEY,
16+
PLATFORM_ENDPOINT_CONFIG_KEY,
17+
)
18+
from .models import AgentSettingProperty, AgentSettings, AgentSettingsTemplate
19+
20+
__all__ = [
21+
# Models
22+
"AgentSettingProperty",
23+
"AgentSettings",
24+
"AgentSettingsTemplate",
25+
# Service
26+
"AgentSettingsService",
27+
"AgentSettingsServiceProtocol",
28+
# Constants
29+
"DEFAULT_PLATFORM_BASE_URL",
30+
"PLATFORM_ENDPOINT_CONFIG_KEY",
31+
"PLATFORM_AUTH_SCOPE_CONFIG_KEY",
32+
"DEFAULT_PLATFORM_AUTH_SCOPE",
33+
]

0 commit comments

Comments
 (0)