Skip to content

Commit 9c8a278

Browse files
authored
[ai.agentserver] add azure-ai-agentserver-core package to agentserver (#43857)
* add azure-ai-agentserver-core * update version number and readme * update doc settings * disable breaking because of python version * minor update on tracing * disable breaking and clean setting * disable pyright and verifytypes * fix test.yml service name * remove old names * update changelog date * update name
1 parent d669502 commit 9c8a278

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+23049
-2
lines changed

eng/.docsettings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ omitted_paths:
2222
language: python
2323
root_check_enabled: True
2424
required_readme_sections:
25-
- ^Azure (.+ client library for Python|Smoke Test for Python)
25+
- ^Azure (.+ client library for Python|Smoke Test for Python|AI Agent Server Adapter for .*Python)
2626
- ^Getting started$
2727
- ^Key concepts$
2828
- ^Examples$
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Release History
2+
3+
## 1.0.0b1 (2025-11-07)
4+
5+
### Features Added
6+
7+
First version
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
include *.md
2+
include LICENSE
3+
recursive-include tests *.py
4+
recursive-include samples *.py *.md
5+
recursive-include doc *.rst *.md
6+
include azure/__init__.py
7+
include azure/ai/__init__.py
8+
include azure/ai/agentserver/__init__.py
9+
include azure/ai/agentserver/core/py.typed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Azure AI Agent Server Adapter for Python
2+
3+
4+
## Getting started
5+
6+
```bash
7+
pip install azure-ai-agentserver-core
8+
```
9+
10+
## Key concepts
11+
12+
This is the core package for Azure AI Agent server. It hosts your agent as a container on the cloud.
13+
14+
You can talk to your agent using azure-ai-project sdk.
15+
16+
17+
## Examples
18+
19+
If your agent is not built using a supported framework such as LangGraph and Agent-framework, you can still make it compatible with Microsoft AI Foundry by manually implementing the predefined interface.
20+
21+
```python
22+
import datetime
23+
24+
from azure.ai.agentserver.core import FoundryCBAgent
25+
from azure.ai.agentserver.core.models import (
26+
CreateResponse,
27+
Response as OpenAIResponse,
28+
)
29+
from azure.ai.agentserver.core.models.projects import (
30+
ItemContentOutputText,
31+
ResponsesAssistantMessageItemResource,
32+
ResponseTextDeltaEvent,
33+
ResponseTextDoneEvent,
34+
)
35+
36+
37+
def stream_events(text: str):
38+
assembled = ""
39+
for i, token in enumerate(text.split(" ")):
40+
piece = token if i == len(text.split(" ")) - 1 else token + " "
41+
assembled += piece
42+
yield ResponseTextDeltaEvent(delta=piece)
43+
# Done with text
44+
yield ResponseTextDoneEvent(text=assembled)
45+
46+
47+
async def agent_run(request_body: CreateResponse):
48+
agent = request_body.agent
49+
print(f"agent:{agent}")
50+
51+
if request_body.stream:
52+
return stream_events("I am mock agent with no intelligence in stream mode.")
53+
54+
# Build assistant output content
55+
output_content = [
56+
ItemContentOutputText(
57+
text="I am mock agent with no intelligence.",
58+
annotations=[],
59+
)
60+
]
61+
62+
response = OpenAIResponse(
63+
metadata={},
64+
temperature=0.0,
65+
top_p=0.0,
66+
user="me",
67+
id="id",
68+
created_at=datetime.datetime.now(),
69+
output=[
70+
ResponsesAssistantMessageItemResource(
71+
status="completed",
72+
content=output_content,
73+
)
74+
],
75+
)
76+
return response
77+
78+
79+
my_agent = FoundryCBAgent()
80+
my_agent.agent_run = agent_run
81+
82+
if __name__ == "__main__":
83+
my_agent.run()
84+
85+
```
86+
87+
## Troubleshooting
88+
89+
First run your agent with azure-ai-agentserver-core locally.
90+
91+
If it works on local by failed on cloud. Check your logs in the application insight connected to your Azure AI Foundry Project.
92+
93+
94+
### Reporting issues
95+
96+
To report an issue with the client library, or request additional features, please open a GitHub issue [here](https://github.com/Azure/azure-sdk-for-python/issues). Mention the package name "azure-ai-agents" in the title or content.
97+
98+
99+
## Next steps
100+
101+
Please visit [Samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/agentserver/azure-ai-agentserver-core/samples) folder. There are several cases for you to build your agent with azure-ai-agentserver
102+
103+
104+
## Contributing
105+
106+
This project welcomes contributions and suggestions. Most contributions require
107+
you to agree to a Contributor License Agreement (CLA) declaring that you have
108+
the right to, and actually do, grant us the rights to use your contribution.
109+
For details, visit https://cla.microsoft.com.
110+
111+
When you submit a pull request, a CLA-bot will automatically determine whether
112+
you need to provide a CLA and decorate the PR appropriately (e.g., label,
113+
comment). Simply follow the instructions provided by the bot. You will only
114+
need to do this once across all repos using our CLA.
115+
116+
This project has adopted the
117+
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
118+
see the Code of Conduct FAQ or contact [email protected] with any
119+
additional questions or comments.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ---------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# ---------------------------------------------------------
4+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
5+
6+
from ._version import VERSION
7+
from .logger import configure as config_logging
8+
from .server.base import FoundryCBAgent
9+
from .server.common.agent_run_context import AgentRunContext
10+
11+
config_logging()
12+
13+
__all__ = ["FoundryCBAgent", "AgentRunContext"]
14+
__version__ = VERSION
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
VERSION = "1.0.0b1"

0 commit comments

Comments
 (0)