Run and Test Human Approval in the AI Agent

Now that we have added the human approval tool to the AI agent, we can run and test the agent with the new tool.

  1. In the navigation pane, select Projects.
  2. Select the project in which you created your AI agent. For this tutorial, select the Simple Expense Approval Project.
  3. In the left navigation pane, select AI Agents AI Agents icon.
  4. Run the agent.
    1. In the Agents section, find the AI agent to run: Simple Expense Approval Agent.
    2. Click Actions Actions icon, and select Run.

      The Test Agent page is displayed.

  5. Test the agent.
    1. In the Test Agent page, enter a natural language prompt to test the AI agent.

      Our AI agent is an expense approval agent and we're testing the agent requesting human approval. Enter an expense for more than $50 USD and click Run Run agent icon.

      For example:

      I bought a lamp for $65.

      Test agent page for Simple Expense Approval Agent with new run. Prompt is "I bought a lamp for $65". In the Resources section, the tools listed are Auto Approve Expense Report and Request Human Approval.

      The progress bar displays and then you see agent actions.

    2. Look at the agent actions.
      • System: indicates what you sent to the LLM in the system prompt. This includes the agent role, the agent guidelines, the AI agent pattern guidelines.
      • User: user indicates what you entered to send to the LLM.
      • Assistant: shows the agent reasoning. You should see in the reasoning that the agent is going to request human approval.

      System is what you sent to the LLM:


      Test agent page with agent run 1 selected. In the main area, a user input box contains the message: "I bough a lamp for $65", with a send icon beside it. Below it, there is a log of actions with System visible. To the right, you can see Resources: Tools Auto approve Expense Report and Request Human Approval, and Activity with agent instance ID and conversation ID.

      Assistant displays that the AI agent is going to invoke the human approval tool. The human approval tool is the integration that runs the approval workflow. The AI agent cannot go any further. It needs to wait for human approval. You need to manually approve or reject the expense.


      Test agent page with agent run 1 selected. In the main area, a user input box contains the message: "I purchased a lamp for $65.", with a send icon beside it. Below it, there is a log of actions with User and Assistant visible. Resources: Tools Auto approve Expense Report and Request Human Approval, and Activity with agent instance ID and conversation ID

  6. Approve the expense.
    1. From the Test Agent page, click Back Back icon to return to the AI Agents page.
    2. Select the Observe tab.
    3. In the left toolbar of your project, click Human in the Loop Human in the loop icon.

      You'll see workflow instances.

    4. Hover over the Simple Human Approval Workflow that was invoked by the AI agent and click View audit View details icon.

      The Activity stream panel opens. The start event indicates that the workflow was started. The user task's status shows In progress indicating that the user hasn't completed the task.


      The activity stream showing details for the start event and user task activities in the workflow.

    5. Click the Open in workspace link.

      The Process Automation Workspace opens in another browser tab.


      Workspace welcome screen A blue banner at the top greets the user and states they have 3 open tasks. Below, the "My Tasks" tab is active, displaying a task list table with columns for Title, Process name, Reference Id, Created Date, Due Date, Status, and Actions. One task is shown with the title "User task," linked to the process "SimpleHumanApprovalW..., currently assigned, A "View More" link appears in the upper right of the table.

    6. Click on the task to view the form.

      The task form is displayed.


      User task summary screen displaying details of an approval task. The page shows process name, creator, last updated date and time, and priority (set to Medium) at the top. The main section contains the claim amount (65) and approver comments (“$65 is approved.”). Action buttons for Close, Approve, and Reject appear at the top right, as well as Save and More Actions buttons. The interface also includes icons for additional actions and notes on the right sidebar.

    7. In Approver comments, add any comment you want such as $65 is approved and click Approve.
      The task is approved, and you get a confirmation message. You are back in the Workspace main page.
    8. Close the Workspace Tasks tab in the browser.
    9. In your browser, navigate back to the Observe tab and refresh the Activity stream tab.

      You should see the end event in your workflow. This indicates the workflow was completed.


      The activity stream showing details for the start event, end event, and user task activities in the workflow.

  7. Check the end of the AI agent run.
    1. In the left navigation pane, select AI Agents AI Agents icon.
    2. Select the Observe tab.
      The Agent instances page is displayed.
    3. Hover over the agent instance that you just ran SIMPLE_EXPENSE_APPROVAL_AGENT and click View details View details icon.

      The Activity stream panel opens.

      Notice:

      • Tool: this is the response from the workflow to the AI agent, which is APPROVE.
      • Assistant: You can see the reasoning of the AI agent for Think, Action, Observe. You then can see the conclusion. The AI agent approves the claim because it was approved by the manager.

      The activity stream showing Tool response and Assistant reasoning and conclusion.

Congratulations!

You've created a human approval tool and run it in your AI agent. You learned how to build a human approval tool, how to approve an assigned user task, and how to track the human approval tool in the AI agent.