Skip to content

Feature/azure ai agents v1 #40818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4725c2d
init agents v1 with new operations
jhakulin Apr 26, 2025
3d2d7b3
update
jhakulin Apr 26, 2025
5de89e6
add samples
jhakulin Apr 26, 2025
59fe986
aio
jhakulin Apr 27, 2025
d62f7e0
update
jhakulin Apr 27, 2025
4ac641d
update
jhakulin Apr 27, 2025
7c54d1c
updates
jhakulin Apr 27, 2025
10d7921
update
jhakulin Apr 27, 2025
4785142
update
jhakulin Apr 27, 2025
0735270
update
jhakulin Apr 27, 2025
9e1fa9a
update
jhakulin Apr 27, 2025
d4dd1a9
update
jhakulin Apr 27, 2025
c2a50c4
add create_thread_and_run
jhakulin Apr 27, 2025
5067297
create thread and process run
jhakulin Apr 28, 2025
2523ae8
add tests and update README (#40760)
jhakulin Apr 28, 2025
b4f8360
update README
jhakulin Apr 28, 2025
8565a0c
update tests
jhakulin Apr 28, 2025
01d3abc
fix sample
jhakulin Apr 28, 2025
def108e
adding tracing (#40769)
M-Hietala Apr 28, 2025
aa2ea6c
Fix unit tests (#40783)
nick863 Apr 29, 2025
da3bdde
modifying multiagent sample (#40799)
M-Hietala Apr 29, 2025
c152f2c
Jhakulin/azure sdk review fixes (#40795)
jhakulin Apr 30, 2025
8c47c3f
run black, fix some readme update snip issue (#40815)
howieleung Apr 30, 2025
2172c2f
Howie/ffix toolcall (#40750)
howieleung Apr 30, 2025
43b9c8d
Update samples csv data (#40821)
jhakulin Apr 30, 2025
680f9e9
Add ew artifact to list (#40833)
nick863 May 1, 2025
ee5ee22
[AI] [Agents] tool schema updates (#40841)
glharper May 1, 2025
3ff2c17
Remove packages not handled in the branch from the CI (#40842)
nick863 May 1, 2025
c63892d
Jhakulin/agents naming changes (#40845)
jhakulin May 2, 2025
899a393
bring tests README back (#40858)
jhakulin May 2, 2025
1d76e38
Uncomment function tests (#40855)
nick863 May 2, 2025
9928194
Jhakulin/list op update (#40871)
jhakulin May 4, 2025
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
1 change: 1 addition & 0 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ omitted_paths:
- sdk/**/swagger/*
- sdk/ml/azure-ai-ml/tests/*
- sdk/vision/azure-ai-vision-imageanalysis/tests/*
- sdk/ai/azure-ai-agents/tests/*
- sdk/ai/azure-ai-inference/tests/*
- sdk/ai/azure-ai-projects/tests/*
- sdk/storage/azure-storage-extensions/*
Expand Down
1 change: 1 addition & 0 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ignore-paths=
azure\\mixedreality\\remoterendering\\_api_version.py,
azure/mixedreality/remoterendering/_api_version.py,
(?:.*[/\\]|^)projects/(models/_models.py|_model_base.py|operations/_operations.py|aio/operations/_operations.py)$,
(?:.*[/\\]|^)agents/(models/_models.py|_model_base.py|operations/_operations.py|aio/operations/_operations.py)$,
# Exclude any path that contains the following directory names
(?:.*[/\\]|^)(?:_vendor|_generated|_restclient|samples|examples|test|tests|doc|\.tox)(?:[/\\]|$)

Expand Down
7 changes: 7 additions & 0 deletions sdk/ai/azure-ai-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Release History

## 1.0.0b1 (Unreleased)

### Features Added

- Initial version
101 changes: 101 additions & 0 deletions sdk/ai/azure-ai-agents/FunctionTool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# FunctionTool Specifications

FunctionTool is the utility allowing developers to provide functions within their code and invoke during streaming or running.

## Example of Function

Here is an example of a function:
```python
def fetch_weather(location: str) -> str:
"""
Fetches the weather information for the specified location.

:param location (str): The location to fetch weather for.
:return: Weather information as a JSON string.
:rtype: str
"""
# In a real-world scenario, you'd integrate with a weather API.
mock_weather_data = {"New York": "Sunny, 25°C", "London": "Cloudy, 18°C", "Tokyo": "Rainy, 22°C"}
weather = mock_weather_data.get(location, "Weather data not available for this location.")
weather_json = json.dumps({"weather": weather})
return weather_json
```

Here is an example to attach this function definition to create_agent

```python
functions = FunctionTool({fetch_weather})

agent = agents_client.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"],
name="my-assistant",
instructions="You are a helpful assistant",
tools=functions.definitions,
)
```

To verify that the SDK parsed the docstring properly, you can print the definition:

```python
[print(json.dumps(tool.as_dict(), indent=4)) for tool in functions.definitions]
```

Alternatively user can check the tools property in newly created agent:

```python
[print(json.dumps(tool.as_dict(), indent=4)) for tool in agent.tools if tool.type == "function"]
```

The terminal will display the definition as below:

```json
[
{
"type": "function",
"function": {
"name": "fetch_weather",
"description": "Fetches the weather information for the specified location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The location to fetch weather for."
}
},
"required": [
"location"
]
}
}
}
]
```

## Requirements for FunctionTool

To ensure `FunctionTool` operates correctly and generates accurate function definitions that agents can reliably call, adhere to the following standards:

1. **Type Annotations**
- All function parameters and return types should be explicitly type-annotated using Python's type hinting.

2. **Structured Docstrings**
- Utilize a consistent docstring format similar to the example above (see also related agent samples in this repository).
- Include clear descriptions for each function and parameter.

3. **Supported Types**

`FunctionTool` maps common Python types to their JSON Schema equivalents, ensuring accurate representation without complex type details:

- **Strings and Numbers**
- `str` → `string`
- `int` → `integer`
- `float` → `number`
- `bool` → `boolean`

- **Collections**
- `list` → `array`
- `dict` → `object`

- **Nullable Types**
- `Optional[type]` includes `null`
21 changes: 21 additions & 0 deletions sdk/ai/azure-ai-agents/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions sdk/ai/azure-ai-agents/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include *.md
include LICENSE
include azure/ai/agents/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include azure/__init__.py
include azure/ai/__init__.py
Loading
Loading