Skip to content

Commit b66467b

Browse files
authored
Merge pull request #4979 from aahill/release-build-agents-2
Connected agents updates
2 parents bcc13ec + 1800dfe commit b66467b

File tree

4 files changed

+53
-53
lines changed

4 files changed

+53
-53
lines changed

articles/ai-services/agents/how-to/connected-agents.md

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -110,71 +110,70 @@ To enable your Agent to use a connected agent, you use `ConnectedAgentToolDefini
110110
1. First we need to create agent client and read the environment variables, which will be used in the next steps.
111111

112112
```csharp
113-
var connectionString = System.Environment.GetEnvironmentVariable("PROJECT_CONNECTION_STRING");
114-
var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME");
115-
116-
var projectClient = new AIProjectClient(connectionString, new DefaultAzureCredential());
117-
118-
AgentsClient agentClient = projectClient.GetAgentsClient();
113+
var projectEndpoint = configuration["ProjectEndpoint"];
114+
var modelDeploymentName = configuration["ModelDeploymentName"];
115+
116+
PersistentAgentsClient client = new(projectEndpoint, new DefaultAzureCredential());
119117
```
120118

121-
2. Next we will create the connected agent using the agent client. This agent will be used to initialize the `ConnectedAgentToolDefinition`.
119+
2. Next we will create the main agent `mainAgent`, and the connected `stockAgent` agent using the agent client. This connected agent will be used to initialize the `ConnectedAgentToolDefinition`.
122120

123121
```csharp
124-
Agent connectedAgent = agentClient.CreateAgent(
125-
model: modelDeploymentName,
126-
name: "stock_price_bot",
127-
instructions: "Your job is to get the stock price of a company. If you don't know the realtime stock price, return the last known stock price.");
128-
129-
ConnectedAgentToolDefinition connectedAgentDefinition = new(new ConnectedAgentDetails(connectedAgent.Id, connectedAgent.Name, "Gets the stock price of a company"));
130-
```
122+
PersistentAgent stockAgent = client.Administration.CreateAgent(
123+
model: modelDeploymentName,
124+
name: "stock_price_bot",
125+
instructions: "Your job is to get the stock price of a company. If you don't know the realtime stock price, return the last known stock price."
126+
// tools: [...] tools that would be used to get stock prices
127+
);
128+
ConnectedAgentToolDefinition connectedAgentDefinition = new(new ConnectedAgentDetails(stockAgent.Id, stockAgent.Name, "Gets the stock price of a company"));
129+
130+
PersistentAgent mainAgent = client.Administration.CreateAgent(
131+
model: modelDeploymentName,
132+
name: "stock_price_bot",
133+
instructions: "Your job is to get the stock price of a company, using the available tools.",
134+
tools: [connectedAgentDefinition]
135+
);
131136

132-
3. We will use the `ConnectedAgentToolDefinition` during the agent initialization.
133137

134-
```csharp
135-
Agent agent = agentClient.CreateAgent(
136-
model: modelDeploymentName,
137-
name: "my-assistant",
138-
instructions: "You are a helpful assistant, and use the connected agent to get stock prices.",
139-
tools: [ connectedAgentDefinition ]);
140138
```
141139

142140
4. Now we will create the thread, add the message, containing a question for agent and start the run.
143141

144142
```csharp
145-
AgentThread thread = agentClient.CreateThread();
146-
143+
PersistentAgentThread thread = client.Threads.CreateThread();
144+
147145
// Create message to thread
148-
ThreadMessage message = agentClient.CreateMessage(
146+
PersistentThreadMessage message = client.Messages.CreateMessage(
149147
thread.Id,
150148
MessageRole.User,
151149
"What is the stock price of Microsoft?");
152-
150+
153151
// Run the agent
154-
ThreadRun run = agentClient.CreateRun(thread, agent);
152+
ThreadRun run = client.Runs.CreateRun(thread, agent);
155153
do
156154
{
157155
Thread.Sleep(TimeSpan.FromMilliseconds(500));
158-
run = agentClient.GetRun(thread.Id, run.Id);
156+
run = client.Runs.GetRun(thread.Id, run.Id);
159157
}
160158
while (run.Status == RunStatus.Queued
161159
|| run.Status == RunStatus.InProgress);
162-
163-
Assert.AreEqual(
164-
RunStatus.Completed,
165-
run.Status,
166-
run.LastError?.Message);
160+
161+
// Confirm that the run completed successfully
162+
if (run.Status != RunStatus.Completed)
163+
{
164+
throw new Exception("Run did not complete successfully, error: " + run.LastError?.Message);
165+
}
167166
```
168167

169168
5. Print the agent messages to console in chronological order.
170169

171170
```csharp
172-
PageableList<ThreadMessage> messages = agentClient.GetMessages(
171+
Pageable<PersistentThreadMessage> messages = client.Messages.GetMessages(
173172
threadId: thread.Id,
174173
order: ListSortOrder.Ascending
175174
);
176-
177-
foreach (ThreadMessage threadMessage in messages)
175+
176+
foreach (PersistentThreadMessage threadMessage in messages)
178177
{
179178
Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
180179
foreach (MessageContent contentItem in threadMessage.ContentItems)
@@ -186,9 +185,9 @@ To enable your Agent to use a connected agent, you use `ConnectedAgentToolDefini
186185
{
187186
foreach (MessageTextAnnotation annotation in textItem.Annotations)
188187
{
189-
if (annotation is MessageTextUrlCitationAnnotation urlAnnotation)
188+
if (annotation is MessageTextUriCitationAnnotation urlAnnotation)
190189
{
191-
response = response.Replace(urlAnnotation.Text, $" [{urlAnnotation.UrlCitation.Title}]({urlAnnotation.UrlCitation.Url})");
190+
response = response.Replace(urlAnnotation.Text, $" [{urlAnnotation.UriCitation.Title}]({urlAnnotation.UriCitation.Uri})");
192191
}
193192
}
194193
}
@@ -229,23 +228,21 @@ To create a multi-agent setup, follow these steps:
229228
from azure.identity import DefaultAzureCredential
230229

231230

232-
project_client = AIProjectClient.from_connection_string(
233-
credential=DefaultAzureCredential(),
234-
conn_str=os.environ["PROJECT_CONNECTION_STRING"],
231+
project_client = AIProjectClient(
232+
endpoint=os.environ["PROJECT_ENDPOINT"],
233+
credential=DefaultAzureCredential(),
234+
api_version="latest",
235235
)
236236
```
237237

238238
1. Create an agent that will be connected to a "main" agent.
239239

240240
```python
241-
connected_agent_name = "stock_price_bot"
242-
243241
stock_price_agent = project_client.agents.create_agent(
244242
model=os.environ["MODEL_DEPLOYMENT_NAME"],
245-
name=connected_agent_name,
246-
instructions=(
247-
"Your job is to get the stock price of a company. If you don't know the realtime stock price, return the last known stock price."
248-
),
243+
name="stock_price_bot",
244+
instructions="Your job is to get the stock price of a company. If you don't know the realtime stock price, return the last known stock price.",
245+
#tools=... # tools to help the agent get stock prices
249246
)
250247
```
251248

@@ -263,7 +260,7 @@ To create a multi-agent setup, follow these steps:
263260
agent = project_client.agents.create_agent(
264261
model=os.environ["MODEL_DEPLOYMENT_NAME"],
265262
name="my-agent",
266-
instructions="You are a helpful agent, and use the connected agent to get stock prices.",
263+
instructions="You are a helpful agent, and use the available tools to get stock prices.",
267264
tools=connected_agent.definitions,
268265
)
269266

articles/ai-services/agents/how-to/tools/overview.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,17 @@ The Foundry Agent Service provides the following built-in tools. You can use the
7474
The following tools are authored by third-party partners. Use the links below to view the documentation and code samples.
7575

7676
> [!IMPORTANT]
77-
> * Your use of connected non-Microsoft services is subject to the terms between you and the service provider. By connecting to a non-Microsoft service, you acknowledge that some of your data, such as prompt content, is passed to the non-Microsoft service, and/or your application might receive data from the non-Microsoft service. You're responsible for your use of non-Microsoft data.
78-
> * Using tools might incur usage with tool providers, review the pricing plan with your selected tool providers.
77+
> * Your use of connected non-Microsoft services is subject to the terms between you and the service provider. By connecting to a non-Microsoft service, you acknowledge that some of your data, such as prompt content, is passed to the non-Microsoft service, and/or your application might receive data from the non-Microsoft service. You are responsible for your use (and any charges associated with your use) of non-Microsoft services and data.
78+
> * The code in these non-Microsfot files were created by third parties, not Microsoft, and have not been tested or verified by Microsoft. Your use of the code samples is subject to the terms provided by the relevant third party. By using any third-party sample in this file, you are acknowledging that Microsoft has no responsibility to you or others with respect to these samples.
7979
8080
|Tool |Description |
8181
|---------|---------|
82-
| [Auquan](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/auquan) | Utilize Auquan to perform your financial data crunching |
82+
| [Auquan](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/auquan) | AI-powered workflow automation for institutional finance |
8383
| [Celonis](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/Celonis) | Celonis delivers Process Intelligence to accelerate enterprise AI at scale |
8484
| [InsureMO Insurance Quotation](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/InsureMO) | Action APIs for insurance quotations for Car, Home, and Travel |
8585
| [LEGALFLY](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/legalfly) | Legal insights grounded in trusted sources from your jurisdiction. |
86+
| [LexisNexis](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/LexisNexis) | Seamless access to LexisNexis content. |
8687
| [MiHCM](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/MiHCM) | seamless integration with MiHCM's HR functionalities |
87-
| [Morningstar](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/Morningstar) | Access up-to-date analyst research, expert commentary, and essential Morningstar data. |
88+
| [Morningstar](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/Morningstar) | Access up-to-date investment research and data such as analyst research, expert commentary, and essential Morningstar data. |
89+
| [Trademo](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/Trademo_Glocal_trade) | Provide latest duties and past shipment data for trade between multiple countries |
8890
| [Tripadvisor](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/python/getting-started-agents/3p-tools/Tripadvisor) | Get travel data, guidance and reviews |

articles/ai-services/agents/how-to/triggers.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ For example, consider a workflow with the *Microsoft Forms* connector (which has
2323

2424
To check if a specific connector has a trigger capability, view its documentation and see if it has a **Trigger** section. For example, the [Triggers](/connectors/microsoftforms/#triggers) section of the *Microsoft Forms* connector.
2525

26-
## Prerequisite
26+
## Prerequisites
2727

2828
* [An existing agent](../quickstart.md)
29+
* Supported Logic Apps regions: `west us 2`, `west central us`, `east asia`, and `southeast asia`.
2930

3031
## Set up
3132

articles/ai-services/agents/includes/quickstart-python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ message = project_client.agents.messages.create(
9191
)
9292
print(f"Created message, ID: {message['id']}")
9393

94-
Create and process an agent run
94+
# Create and process an agent run
9595
run = project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
9696
print(f"Run finished with status: {run.status}")
9797

0 commit comments

Comments
 (0)