Create an example multi-turn specialized agent walkthrough

  • Updated

Specialized agents in Optimizely Opal are purpose-built AI agents you create that complete a single, well-defined task. Each agent can use targeted tools, adjustable reasoning, and defined inputs to finish its task accurately and efficiently. Specialized agents support two interaction modes: single-shot, where the agent runs once and returns a result, and multi-turn, where the agent stays active in Opal Chat for iterative follow-up.

This document walks you through creating an example multi-turn specialized agent. Unlike a single-turn agent that processes one request and completes, a multi-turn agent maintains conversation context across multiple exchanges. This lets you have ongoing dialogue and answer follow-up questions within a single session. Use a multi-turn agent when you want users to review multiple items, ask clarifying questions, and build on previous findings all in a single session, rather than triggering a separate request each time.

Prerequisites

Before developing your specialized agent, ensure the following:

Real-world example

Compliance Advisory agent

Objective – Create a multi-turn specialized agent that engages in ongoing, conversational compliance reviews. In this scenario, the agent reviews website content against Financial Conduct Authority (FCA) financial promotion guidelines and maintains full conversation context, letting users review multiple URLs in sequence, ask follow-up questions about findings, and request comparative analysis across sites. Unlike the single-turn Content Review agent, users drive this agent interactively through Opal Chat rather than triggering a single automated execution.

Build a specialized agent

The development process for the example Compliance Advisory agent follows this workflow: Create → Configure → Build → Test → Refine → Deploy. Compared to a single-turn agent, this walkthrough includes two additional configuration steps: a System Prompt that defines the agent's persistent behavior and a Token Budget that controls how much conversation history the agent retains.

Create your specialized agent

  1. Go to home.optimizely.com.
  2. Select your organization.
  3. Click Opal.

    Screenshot of the Optimizely home page showing the Opal option in the navigation
  4. Click Agents.

    Screenshot of the Agents page in Opal where the list of agents is displayed
  5. Click the Your Agents tab.

    Screenshot of the Agents page in Opal where the Your Agents tab is selected
  1. Click Add Agent > Specialized agent to create a specialized agent.

Configure your specialized agent

Details section

You begin crafting your specialized agent in the Details section. This section contains basic information about your specialized agent. See the Details section in the Specialized agents fundamentals and best practices documentation for details.

  1. Enter the following information:
    • NameCompliance Advisory agent
    • Idcompliance-advisory-agent
    • DescriptionA conversational compliance advisor that reviews website content against FCA financial promotion guidelines. Maintains conversation context to enable iterative review, follow-up questions, and comparative analysis across multiple URLs in a single session.
  2. Leave Active on.
  3. Toggle Multi-turn on. Enabling multi-turn lets the agent maintain conversation history and context across every exchange in a session.
  4. Leave Enabled in Chat on. Users interact with this agent conversationally through Opal Chat.

Your agent details should appear similar to the following:

Screenshot of the Compliance Advisory agent Details section showing Multi-turn toggled on and Enabled in Chat toggled on
The Id serves as the identifier for @mentioning the agent and must not contain spaces. Ensure the Id displays as Available. If it does not, that means there is an agent already created with this Id. Enter a different Id instead.

Build your specialized agent

System Prompt section

The System Prompt defines your agent's persistent persona and standing instructions that apply across every turn in the conversation. Unlike the Prompt Template, which sets up the initial task, the System Prompt remains active throughout the entire session, shaping how your agent responds regardless of what the user asks.

Enter the following in the System Prompt field of your specialized agent.

System Prompt example

You are a senior compliance advisor specializing in FCA financial promotion regulations. Your role is to help users review website content for compliance through ongoing conversation.

Always:

  • Introduce yourself briefly at the start of each new conversation and invite the user to share a URL for review.
  • Remember all URLs reviewed and findings discussed during this conversation. Reference prior context when answering follow-up questions.
  • Offer comparative analysis when the user has reviewed multiple sites in the same session.
  • Use a professional, clear, and empathetic tone. Explain compliance terms in plain language when introducing them.
  • After each review, invite the user to ask follow-up questions or submit another URL.

Input section

The Input section is where you add directions your specialized agent should follow, variables it should prompt the user for, and tools it should use to accomplish its task. See the Input section in the Specialized agents fundamentals and best practices documentation for details.

Prompt template

The prompt template provides the initial instruction set your agent follows at the start of each conversation. For multi-turn agents, structure the template to guide iterative interaction rather than a single, self-contained task.

Expand the following Prompt Template example and enter it in the Prompt template in your specialized agent.

Prompt template example

C – Context

  • Your Role: You are a senior compliance advisor with expertise in FCA financial promotion regulations. You conduct multi-turn compliance reviews — helping users assess one or more URLs through ongoing conversation.
  • Deliverable: You provide structured compliance assessments for each URL reviewed and maintain awareness of all prior findings in this conversation to support comparative analysis.
  • Communication Style: Clear, professional, and conversational. Acknowledge prior context where relevant. Invite follow-up questions after each review.

L – Logic

  • When a URL is provided (via [[url]] or shared in the conversation), conduct a structured compliance review using the FCA-guidelines.pdf reference document.
  • Each review must include: an Executive Summary with an overall compliance score, Issue Categorization using color coding (major issues in red, minor issues in amber, compliant areas in green with justification for all flagged items), and Report Sections in this order: Tone of Voice, Accessibility, Clarity, and Regulations.
  • After each review, invite the user to ask follow-up questions or provide another URL.
  • If the user asks to compare sites reviewed in this conversation, draw on your full conversation context to provide a clear comparative summary.

E – Examples

  • When a user asks "How does this compare to the last site I reviewed?" — reference the findings from the previous review and provide a direct comparison of compliance scores and key issues.
  • When a user asks "Can you explain why that was flagged?" — provide a plain-language explanation of the relevant FCA guideline and the specific flagged content.

A – Action

  • If [[url]] is provided, begin the compliance review immediately. If no URL is provided, ask the user to share the URL they want reviewed.
  • Conduct each review by comparing the web content at the URL against the FCA financial promotion guidelines in the attached FCA-guidelines.pdf document.
  • After completing each review, ask: "Would you like to review another URL, ask a follow-up question about these findings, or request a comparison of all sites reviewed in this session?"

R – Result

  • Output each compliance review directly in the chat interface in a structured, readable format.
  • Use color-coded language for issue categorization: major issues (red), minor issues (amber), and compliant areas (green).
  • When providing comparative analysis, present a clear summary of compliance scores and key findings across all reviewed URLs.

Variables

This example references one variable, url, in the Prompt Template. Because this is a multi-turn agent, the URL variable is optional — users can provide it when invoking the agent or share it conversationally at any point in the session.

  1. Click Add Variable and configure the following:
    • TypeString
    • Nameurl
    • DescriptionURL of the website to review for FCA financial promotion compliance. Can be provided at invocation or shared conversationally during the session.
    • Required? – Unselected
  2. Click Save.

Tools

This agent needs to browse web pages to review content. Select Enable automatic tool prediction in the Tools section to let Opal choose the most appropriate tools for each request automatically, including browse_web.

Inference level

This agent needs to browse web pages to review content. You have two options for configuring tools:

  • Explicit selection – If you know which tools the agent needs, click Add Tool, select browse_web, and click Add Selected.
  • Automatic tool prediction – To let users of the agent call tools as needed without specifying them in advance, select Enable automatic tool prediction.

Files

The Prompt Template references FCA-guidelines.pdf. Upload this file so your agent can compare web content against the FCA financial promotion guidelines.

  1. Download FCA-guidelines.pdf.
  2. Click Add file in the Files section of the specialized agent Setup.
  3. Locate and select the PDF file on your computer and click Upload.
The FCA-guidelines.pdf file was generated using Opal. It is optimized for use within this example agent walkthrough and may not be fully compatible or functional if used externally.

Token budget

Multi-turn agents accumulate conversation history with each exchange, which increases token usage over time. Setting an appropriate token budget ensures your agent maintains enough context to reference prior findings without truncating important conversation history.

For this example agent, select Medium (25K – 75K tokens). This supports 15–30 turns with rich context — sufficient for a typical multi-URL review session with follow-up questions.

Use the following as a guide when configuring token budgets for your own agents:

Budget Token range Best for
Low 10K – 25K 5–10 turns. Simple, stateless queries. Lookup, calculation, or question-and-answer tasks with minimal context.
Medium 25K – 75K 15–30 turns. Rich context. One or two knowledge bases. Multi-step reasoning across multiple URLs.
High 75K – 200K 30+ turns. Full conversation history. Multiple documents. Deep, iterative refinement sessions.

Output section

The Output helps Opal know how you expect its output.

  1. Expand the Output section.
  2. Leave the Data Type drop-down list as Text.
  3. Enter A structured compliance assessment for the reviewed URL, including an executive summary with compliance score, color-coded issue categorization, and report sections covering tone of voice, accessibility, clarity, and regulations. for the Description.

Save specialized agent

Click Save. A confirmation message appears. If it does not, fix the errors and click Save again.

Test your specialized agent

After creating, configuring, and saving your specialized agent, use the Test Run option to verify that the agent maintains conversation context correctly across multiple exchanges.

Simulate the following multi-turn interaction in the Test Run panel:

  1. Click Test Run.
  2. Enter www.fidelity.com/mutual-funds/overview for the url.
  3. Click Run and review the output. The agent should produce a structured compliance assessment for the Fidelity URL.
  4. After the agent returns its findings, enter the following follow-up message: Which specific FCA guideline is the prominence of risks issue tied to?
  5. Review the agent's response. It should reference its prior findings and cite the specific FCA guideline, confirming that conversation context is being maintained.
  6. Enter: Now review www.chase.com and compare it to Fidelity.
  7. Review the agent's comparative analysis. It should assess the Chase URL and provide a side-by-side comparison with the Fidelity findings from earlier in the session.

See the Test an agent section in the Manage agents documentation for more information on testing your specialized agent.

Refine your specialized agent

Based on the output of your test run, you can adjust your specialized agent's System Prompt, Prompt Template, and Inference Level to refine its behavior. For multi-turn agents, pay particular attention to whether the agent correctly references prior conversation context in its responses. See the Refinement strategies section in the Specialized agent foundation documentation for additional refinement steps.

Deploy your specialized agent

After any refinements, your specialized agent is ready to deploy. Confirm that Enabled in Chat is on — you left this on during the Configure step. Users in your Opal instance can invoke this agent by entering @compliance-advisory-agent in Opal Chat, optionally providing a URL to begin a review immediately or starting a conversation to kick off the session.

Useful resources

For a deeper understanding of the agent ecosystem in Opal, review the following foundational materials:

If you use Opti ID, administrators can turn off generative AI in the Opti ID Admin Center. See Turn generative AI off across Optimizely applications.