Common task agent step patterns

For high-stakes automation, relying on a single AI response can be risky. You can link multiple task agent steps to create self-correcting agentic patterns. For example, one step can draft a solution and another can review it for errors.

Evaluator-optimizer pattern

An evaluator-optimizer pattern uses two task agent steps in a feedback loop: one generates output and the other evaluates it. If the evaluation fails, the workflow routes back to the generator with the errors as additional context.

For the step-by-step procedure, see the Related links section.

Other multi-agent step patterns

You can combine task agent steps with other step types to create additional patterns:

  • Analysis and action: Use a task agent step to analyze logs or alerts, then route the analysis to an Ansible Automation Platform job template step that runs the recommended remediation.
  • Summarization chain: Connect multiple task agent steps in sequence, where each agent summarizes or transforms the output of the previous one for different audiences or formats.
  • Classification and routing: Use a task agent step to classify incoming data (for example, categorizing support tickets by severity), then use a conditional step to route the workflow along different paths based on the classification.

Build an evaluator-optimizer pattern

An evaluator-optimizer pattern uses two task agent steps in a feedback loop: one generates output and the other evaluates it. If the evaluation fails, the workflow routes back to the generator with the errors as additional context.

Before you begin

  • You have access to the workflow builder.
  • At least one LLM provider integration is enabled and healthy.

Procedure

  1. Navigate to the Workflows page and select the workflow you want to modify.
  2. Click Add step and add a primary Task Agent step from the Add step panel.
    1. In the Parameter details, configure the prompt to perform the initial task.

      For example:

      Draft an Ansible playbook that patches all RHEL servers in the 'production' inventory group and reboots them if kernel updates were applied.

    2. Define a response schema that includes the generated content and any metadata downstream steps need.
  3. Click Add step and add a second Task Agent step.

    Connect the primary agent's output to a secondary task agent step configured as the reviewer.

    1. Configure the prompt to evaluate the first agent's output.

      For example:

      Review the provided Ansible playbook for security flaws and best-practice violations. If the playbook passes review, output 'PASS' in the status field. If there are issues, list each error with a description and suggested fix.

    2. Define a response schema with a status field and an errors array.
  4. Click Add step and add a Conditional step to the canvas after the Agent reviewer.

    Configure the condition to evaluate the reviewer's output:

    • If status equals PASS, route the workflow forward to the next action (such as running the playbook with an Ansible Automation Platform job template step).
    • If status does not equal PASS, route the workflow back to the primary task agent step. Pass the error list as additional context in the prompt so the agent can generate an improved version.
  5. Optional: Click Add step and add a Loop step to limit the number of revision cycles and prevent infinite loops.

    Set a maximum iteration count, such as 3.

  6. Optional: Click Add step and add an Approval step.

    Assign a human reviewer and add a contextual message to help them understand what they need to evaluate.