Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: Azure Logic Apps (Standard)
Important
This capability is in preview and is subject to the Supplemental Terms of Use for Microsoft Azure Previews.
When your workflow needs to handle a complex business process or integration scenario, consider whether you can break the workload into smaller sequential tasks, especially when the output from one task flows to the next task. To improve performance, management, scalability, you can set up multiple AI agents that use large language model (LLM) capabilities to complete each subtask. Each agent or model uses outputs from the previous agent or model. This behavior is known as the prompt chaining pattern.
This guide describes how to set up sequential AI agents that follow the prompt chaining pattern in your workflow. The example sets up a business report processing chain that transforms raw performance data into a formatted executive summary.
The following table lists the inputs, tasks, and outputs:
| Element or task | Description |
|---|---|
| Input | Raw quarterly performance text |
| Extract | Identify the numerical values and metrics. |
| Format | Convert to input to a structured format. |
| Sort | Sort the data in descending order. |
| Output | Sorted extracted data in descending order |
Prerequisites
Same requirements as Create autonomous agent workflows.
The autonomous agent workflow with an empty agent requires that you add a trigger that best matches your scenario. The example in this guide uses the Request trigger named When an HTTP request is received.
If you use the same trigger for this example, in the Request Body JSON Schema parameter, enter the following schema:
{
"type": "object",
"properties": {
"report": {
"type": "string"
}
}
}
Best practices
The following table describes best practices for the prompt chaining pattern:
| Practice | Description |
|---|---|
| Keep steps focused | Each agent has a single, clear responsibility. |
| Add validation gates | Implement checks between steps to catch errors early. |
| Design for recovery | Plan how to handle failures at each step. |
| Monitor performance | Track execution time and success rates. |
| Optimize prompts | Refine agent instructions based on results. |
| Test edge cases | Validate behavior with unusual or malformed inputs. |
Set up the data extraction agent
Follow these steps to set up the default empty agent:
In the Azure portal, open your Standard logic app resource.
Open your autonomous agent workflow in the designer.
On the designer, select the empty Agent action.
On the information pane that opens, select the default action name, and rename the action to Data extraction agent.
On the Parameters tab, provide the following information:
Parameter Value System instructions Extract only the numerical values and their associated metrics from the text.On a new line, format each as 'value: metric'.Example format:92%: customer satisfaction45%: revenue growthUser instructions Data to use for extraction: @{triggerBody()?['report']}
In this example,reportis an output from the trigger named When an HTTP request is received. The expression, triggerBody()?['report'], returns the 'report' trigger output.The completed Data extraction agent looks like the following example:
Optionally, you can select the output from the When an HTTP request is received trigger in the dynamic content list, which creates the correct expression and includes the
reporttrigger output.In the User instructions box, enter the following text, including a trailing space and keep the cursor in the position after the space:
Data to use for extraction:From the options that appear when the cursor appears in an edit box, select the dynamic content list (lightning icon).
From the dynamic content list, under When an HTTP request is received, select report.
When you're done, the User instructions box looks like the following example:
Set up the data conversion agent
Follow these steps to set up the next agent, which receives output from the data extraction agent.
Under Data extraction agent, select the plus sign (+), and then select Add an agent.
On the designer, select the new empty Agent action.
On the information pane that opens, select the default action name, and rename the action to Data conversion agent.
On the Parameters tab, provide the following information:
Parameter Value System instructions Convert all numerical values to percentages where possible.If not a percentage or points, convert to decimal, for example, 92 points -> 92%.Keep one number per line.Example format:92%: customer satisfaction45%: revenue growthUser instructions Data to use for conversion: @{outputs('Data_extraction_agent')?['lastAssistantMessage']}
Note: The expression, outputs('Data_extraction_agent')?['lastAssistantMessage'], inserts the last assistant message from Data extraction agent into the user instructions for Data conversion agent.The completed Data conversion agent looks like the following example:
Optionally, you can select the output from the Data extraction agent in the dynamic content list, which creates the correct expression and includes the
lastAssistantMessageoutput from the Data extraction agent.In the User instructions box, enter the following text, including a trailing space and keep the cursor in the position after the space:
Data to use for conversion:From the options that appear when the cursor appears in an edit box, select the expression editor this time (function icon).
In the expression list, select Dynamic content.
From the dynamic content list, under Data extraction agent, select Last Assistant Message, and then select Add.
When you're done, the User instructions box looks like the following example:
Set up the data sorting agent
Follow these steps to set up the next agent, which receives the formatted table from the data conversion agent.
Under Data conversion agent, add a new agent.
On the designer, select the new empty Agent action.
On the information pane that opens, select the default action name, and rename the action to Data sorting agent.
On the Parameters tab, provide the following information:
Parameter Value System instructions Sort all lines in descending order by numerical value.On each line, keep the format 'value: metric'.Example format:92%: customer satisfaction87%: employee satisfactionUser instructions Data to use for sorting: @{outputs('Data_conversion_agent')?['lastAssistantMessage']}
Note: The expression, outputs('Data_conversion_agent')?['lastAssistantMessage'], inserts the last assistant message from Data conversion agent into the user instructions for Data sorting agent.The completed Data sorting agent looks like the following example:
Optionally, you can select the output from the Data conversion agent in the dynamic content list, which creates the correct expression and includes the
lastAssistantMessageoutput from the Data conversion agent.In the User instructions box, enter the following text, including a trailing space and keep the cursor in the position after the space:
Data to use for sorting:From the options that appear when the cursor appears in an edit box, select the expression editor this time (function icon).
In the expression list, select Dynamic content.
From the dynamic content list, under Data conversion agent, select Last Assistant Message, and then select Add.
When you're done, the User instructions box looks like the following example:
Set up the Response action
This example started the workflow with the When an HTTP request is received trigger. For workflows that start with this trigger, make sure the workflow returns the result to the caller by adding the Response action at the end of the workflow.
Follow the general steps to add the action named Response to your workflow.
On the designer, select the Response action.
On the information pane, under Parameters, in the Body parameter, specify the results to return to the caller.
For this example, the Body parameter specifies that the result is the Last Assistant Message output from the Data sorting agent and returns this data to the caller:
{ "type": "Response", "kind": "Http", "inputs": { "statusCode": 200, "body": { "result": "@outputs('Data_sorting_agent')?['lastAssistantMessage']" } }, }
Test your agent workflow
On the designer toolbar, select Run > Run with payload, and provide the following sample input as the "report":
{ "report": "Q3 Performance Summary: Our customer satisfaction score rose to 92 points this quarter. Revenue grew by 45% compared to last year. Market share in our primary market is 23% . Customer churn decreased to 5% from 8%. New user acquisition cost is $43 per user. Product adoption rate increased to 78%. Employee satisfaction is at 87 points. Operating margin improved to 34%." }The following list shows the expected progression for the output:
- Extract values and metrics from raw data.
- Convert the extracted information to the target format.
- Sort the data in the formatted data.
To view the results, on the workflow sidebar, under Tools, select Run history.
On the Run history tab, select the most recent workflow run.
In the Agent log, review the responses from each agent for the system instructions that you specified.
To review the status, inputs, and outputs for each operation, select that operation in the monitoring view window.
Clean up example resources
If you don't need the resources that you created for the examples, make sure to delete the resources so that you don't continue to get charged. You can either follow these steps to delete the resource group that contains these resources, or you can delete each resource individually.
In the Azure search box, enter resource groups, and select Resource groups.
Find and select the resource groups that contain the resources for this example.
On the Overview page, select Delete resource group.
When the confirmation pane appears, enter the resource group name, and select Delete.