Add a Policy Model to a Policy Node of Workflows
Policy models provide reliable, repeatable, and deterministic policy-based decision making at runtime in AI Agent Studio.
You can create a standalone policy model or use a template. Use a standalone model for unique policies that don't follow an established pattern or use a template to create a family of policy models with common inputs, outputs, and decision logic. Add policy rules by uploading a policy document or entering the rules manually. Then generate code that converts unstructured business policies into decision logic that AI agents use to evaluate rules, perform calculations, and make decisions consistently. After publishing, associate the policy model with a Policy node in a workflow. At runtime, the Policy node evaluates the defined rules using the associated policy model and returns the result.
Create a Standalone Policy Model
- Go to AI Agent Studio and open the
Policy
tab. - Select the Policy subtab.
- Select Add.
- Enter a name and description for the policy. The code is automatically populated based on the name.
- (Optional) From the Role list, select a security role and add it.
- From the Template list, select Generic.
- (Optional) From the Context list, select a context to scope the policy to a specific workflow.
- In the Prompt field, enter a prompt to provide additional guidance for generic function generation.
- Select Choose File, and upload one or more policy source documents that contain your business rules.
- Select Generate to generate the functions. It might take some time to generate the function.
- From Functions, select a generated function and review it. View the function name, code, and description in the Info subtab, parameter details in the Input subtab, and return values in the Output subtab.
- From the Test Cases subtab, generate or upload test cases to validate the function. Test cases verify expected results and pass or fail status before the function is used in workflows.
- Select Run Test cases to verify that the function
behaves as expected. Use the Builder Assistant
to debug failed test cases. - Save and close the policy model or publish it.
Published policy models are available from the Policy subtab for use in Policy nodes within workflows.
Create a Policy Model Using a Template
- Go to AI Agent Studio and select the Policy tab.
- Select the Policy Templates subtab.
- Select Add.
- Enter a name and the code is automatically populated based on the name.
- In the Prompt field, select Optimize.
- Enter a description, and then press Enter to generate a prompt that defines the task the template should perform on the input document and specifies the expected output. It might take some time to generate the prompt.
- From Functions, select Add Function.
- Enter a name and description for the function. The code is automatically populated based on the name.
- For Prompt, first select Optimize. Then describe the function's role, processing logic, evaluation criteria, and output requirements for analyzing the input data and then press Enter to generate a prompt. It might take some time to generate the prompt.
- In the Input subtab, select Add Parameter to add the required parameters.
- In the Output subtab, define the return output details, and then select Apply.
- Publish the policy template. Published policy templates are available from the Policy Template subtab for reuse across policy models.
- Select the Policy subtab.
- Select Add.
- Enter a name and description for the policy. The code is automatically populated based on the name.
- (Optional) Add a security role by selecting a role from the Role list and then selecting Add.
- From the Template list, select the policy template that you created.
- (Optional) From the Context list, select a context to scope the policy to a specific workflow.
- Select Choose File, and upload one or more policy source documents that contain your business rules.
- Select Generate to generate the functions. It might take some time to generate the function.
- From Functions, select a generated function and review it. View the function name, code, and description in the Info subtab, parameter details in the Input subtab, and return values in the Output subtab.
- From the Test Cases subtab, generate or upload test cases to validate the function. Test cases verify expected results and pass or fail status before the function is used in workflows.
- Select Run Test cases to verify that the function
behaves as expected. Use Builder Assistant
to debug failed test cases. - Save and close the policy model or publish it.
Published policy models are available from the Policy subtab for use in Policy nodes within workflows.
Associate a Policy Model with a Policy Node
- From the Workflows tab, edit a workflow and add a Policy node.
- Enter a name and description for the Policy node. The code is automatically populated based on the name.
- Select an error handler node to define failure handling.
- From the Policy list, select a published policy model.
- From the Function list, select the policy function to run.
- If the selected function displays the Parameters field, configure the required input parameters. Use expressions to specify the routing decisions. For more information, see Expressions.
- Publish the workflow.
When the workflow runs, the Policy node runs the selected policy function and returns the evaluation results to downstream workflow nodes.