GENERAL INSTRUCTIONS
-----------------
In our system, the behavior of a conversational AI agent is guided by "guidelines". The agent makes use of these guidelines whenever it interacts with a user (also referred to as the customer).
Each guideline is composed of two parts:
- "condition": This is a natural-language condition that specifies when a guideline should apply.
          We look at each conversation at its most recent state, and we test against this
          condition to understand if we should have this guideline participate in generating
          the next response to the user.
- "action": This is a natural-language instruction that should be followed by the agent
          whenever the "condition" part of the guideline applies to the conversation at its latest state.
          Any instruction described here applies only to the agent, and not to the user.


Task Description
----------------
Sometimes a customer expresses that they’ve experienced something or want to proceed with something, but there are multiple possible ways to go, and it’s as-yet unclear what exactly they intend.
In such cases, we need to identify the potential options and ask the customer which one they mean.

Your task is to determine whether the customer’s intention is currently ambiguous and, if so, what the possible interpretations or directions are.
You’ll be given a disambiguation condition — one that, if true, signals a potential ambiguity — and a list of related guidelines, each representing a possible path the customer might want to follow.

If you identify an ambiguity, return the relevant guidelines that represent the available options.
Then, formulate a response in the format:
"Ask the customer whether they want to do X, Y, or Z..."
This response should clearly present the options to help resolve the ambiguity in the customer's request.

Notes:
- Base your evaluation on the customer's most recent message.
- If you determine that there is indeed an ambiguity - then, when one of the guidelines might be relevant - include it. We prefer to let the customer choose of all plausible options.
- Some guidelines may turn out to be irrelevant based on the interaction. For example, due to earlier parts of the conversation or because the user's status (provided in the interaction history or
as a context variable) rules them out. In such cases, the ambiguity may already be resolved (only one or none option is relevant) and note that no clarification is needed in such cases.

- Notice that if you've already asked for disambiguation from the customer you need to **pay extra attention** to if we need to re-ask for clarification or the user responded and it was resolved.
- **Accept brief customer responses as valid clarifications**: Customers often communicate with very short responses (single words or phrases like "return", "replace", "yes", "no"). If the customer's brief
 response clearly indicates their choice among the previously presented options, consider the ambiguity resolved even if their answer is not in complete sentences.

distinction is between:
- Pending clarification (customer hasn't answered yet) - re-disambiguate (disambiguation_requested = true, customer_resolved=false, is_ambiguous = true)
- Clarification provided (customer has answered) - don't re-disambiguate the same issue (disambiguation_requested = true, customer_resolved=true, is_ambiguous = false)
- New ambiguity (different unclear intent emerges) - do disambiguate (is_ambiguous = true)

- Focus on current context: If the customer has changed the subject or moved on to a different topic in their most recent message, do not disambiguate previous unresolved issues.
Always prioritize the customer's current request and intent over past ambiguities.



Examples of Guidelines Ambiguity Evaluation:
-------------------

Example 1 - Disambiguation example: ###

- **Interaction Events**:
[
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "I received the wrong item in my order."
    }
  }
]


- **Disambiguation Condition:**
The customer received a wrong or damaged item


- **Guidelines**:
1) Condition: The customer asks to return an item for a refund. Action: refund the order
2) Condition: The customer asks to replace an item. Action: Send the correct item and ask the customer to return the one they received


- **Expected Result**:
```json
{
  "tldr": "The customer claimed to receive the wrong item; may want to either replace it or get a refund.",
  "disambiguation_requested": false,
  "is_ambiguous": true,
  "guidelines": [
    {
      "guideline_id": "1",
      "tldr": "may want to refund the wrong item",
      "requires_disambiguation": true
    },
    {
      "guideline_id": "2",
      "tldr": "may want to replace the wrong item",
      "requires_disambiguation": true
    }
  ],
  "clarification_action": "ask the customer whether they\u2019d prefer a replacement or a refund."
}
```

###


Example 2 - Disambiguation example when not all guidelines are relevant: ###

- **Interaction Events**:
[
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "Hey, can you book me an appointment? I need a prescription"
    }
  }
]


- **Disambiguation Condition:**
The customer wants to book an appointment, but it’s unclear whether it’s with a doctor or a psychologist, and whether it should be online or in-person.


- **Guidelines**:
1) Condition: The customer asks to book an appointment with a doctor. Action: book the appointment
2) Condition: The customer asks to book a session with a psychologist. Action: book the appointment
3) Condition: The customer asks to book an online appointment to a medical consultation or a session with a psychologist. Action: book the appointment online


- **Expected Result**:
```json
{
  "tldr": "The customer asks to book an appointment but didn't specify the type. Since they mention needing a prescription, it likely relates to a medical consultation, not psychological.",
  "disambiguation_requested": false,
  "is_ambiguous": true,
  "guidelines": [
    {
      "guideline_id": "1",
      "tldr": "the appointment is with a doctor",
      "requires_disambiguation": true
    },
    {
      "guideline_id": "2",
      "tldr": "psychologist is not relevant",
      "requires_disambiguation": false
    },
    {
      "guideline_id": "3",
      "tldr": "online appointment can be relevant",
      "requires_disambiguation": true
    }
  ],
  "clarification_action": "Ask the customer if they prefer an online or in person doctor\u2019s appointment"
}
```

###


Example 3 - Non disambiguation example: ###

- **Interaction Events**:
[
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "Hey, can you book me an online appointment? I need a prescription"
    }
  }
]


- **Disambiguation Condition:**
The customer asked to book an appointment, but it’s unclear whether it’s with a doctor or a psychologist, and whether it should be online or in-person.


- **Guidelines**:
1) Condition: The customer asks to book an appointment with a doctor. Action: book the appointment
2) Condition: The customer asks to book a session with a psychologist. Action: book the appointment
3) Condition: The customer asks to book an online appointment to a medical consultation or a session with a psychologist. Action: book the appointment online


- **Expected Result**:
```json
{
  "tldr": "The customer requests an online appointment and mentions needing a prescription, which suggests a medical consultation",
  "disambiguation_requested": false,
  "is_ambiguous": false
}
```

###


Example 4 - Disambiguation resolves based on the interaction: ###

- **Interaction Events**:
[
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "Hey, are you offering in-person sessions these days, or is everything online?"
    }
  },
  {
    "event_kind": "message",
    "event_source": "ai_agent",
    "data": {
      "message": "I'm sorry, but due to the current situation, we aren't holding in-person meetings. However, we do offer online sessions if needed"
    }
  },
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "Got it. I\u2019ll need an appointment \u2014 my throat is hurting."
    }
  }
]


- **Disambiguation Condition:**
The customer wants to book an appointment, but it’s unclear whether it’s with a doctor or a psychologist, and whether it should be online or in-person.


- **Guidelines**:
1) Condition: The customer asks to book an appointment with a doctor. Action: book the appointment
2) Condition: The customer asks to book a session with a psychologist. Action: book the appointment
3) Condition: The customer asks to book an online appointment to a medical consultation or a session with a psychologist. Action: book the appointment online


- **Expected Result**:
```json
{
  "tldr": "The customer asks to book an appointment. Online sessions are not available. Since they mention hurting throat, it likely relates to a medical consultation, not a psychologist.",
  "disambiguation_requested": false,
  "is_ambiguous": false
}
```

###


Example 5 - New ambiguous request: ###

- **Interaction Events**:
[
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "Hey, can you book me an appointment? I need a prescription"
    }
  },
  {
    "event_kind": "message",
    "event_source": "ai_agent",
    "data": {
      "message": "You can have a doctor\u2019s session either in person or online. Which do you prefer?"
    }
  },
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "I can do it online. Also, I need to book an appointment for my daughter."
    }
  }
]


- **Disambiguation Condition:**
The customer wants to book an appointment, but it’s unclear whether it’s with a doctor or a psychologist, and whether it should be online or in-person.


- **Guidelines**:
1) Condition: The customer asks to book an appointment with a doctor. Action: book the appointment
2) Condition: The customer asks to book a session with a psychologist. Action: book the appointment
3) Condition: The customer asks to book an online appointment to a medical consultation or a session with a psychologist. Action: book the appointment online


- **Expected Result**:
```json
{
  "tldr": "Based on latest message, there is a new request which is again ambiguous. Need to clarify whether it's with a doctor or a psychologist, and whether it should be online or in person",
  "disambiguation_requested": false,
  "is_ambiguous": true,
  "guidelines": [
    {
      "guideline_id": "1",
      "tldr": "the appointment may be with a doctor",
      "requires_disambiguation": true
    },
    {
      "guideline_id": "2",
      "tldr": "psychologist may be relevant",
      "requires_disambiguation": true
    },
    {
      "guideline_id": "3",
      "tldr": "online appointment can be relevant",
      "requires_disambiguation": true
    }
  ],
  "clarification_action": "Ask the customer if they need a doctor or psychologist appointment and if they prefer an online or in person session for their daughter"
}
```

###


Example 6 - Several requests, one needs disambiguation: ###

- **Interaction Events**:
[
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "Hey, can you book me an appointment? I need a prescription. And also I need to a session with a psychologist with my wife in your office."
    }
  }
]


- **Disambiguation Condition:**
The customer wants to book an appointment, but it’s unclear whether it should be online or in-person. They say prescription so they need a doctor.


- **Guidelines**:
1) Condition: The customer asks to book an appointment with a doctor. Action: book the appointment
2) Condition: The customer asks to book a session with a psychologist. Action: book the appointment
3) Condition: The customer asks to book an online appointment to a medical consultation or a session with a psychologist. Action: book the appointment online
4) Condition: The customer asks to book an in person appointment to a medical consultation or a session with a psychologist. Action: book the in person appointment


- **Expected Result**:
```json
{
  "tldr": "The customer asked to book two appointments. For the first appointment there is an ambiguity between doctor or psychologist, and online or in-person. The second one is clear.",
  "disambiguation_requested": false,
  "is_ambiguous": true,
  "guidelines": [
    {
      "guideline_id": "1",
      "tldr": "need a doctor",
      "requires_disambiguation": false
    },
    {
      "guideline_id": "2",
      "tldr": "psychologist can't be relevant",
      "requires_disambiguation": false
    },
    {
      "guideline_id": "3",
      "tldr": "online appointment can be relevant",
      "requires_disambiguation": true
    },
    {
      "guideline_id": "4",
      "tldr": "in person appointment can be relevant",
      "requires_disambiguation": true
    }
  ],
  "clarification_action": "Ask the customer if they prefer an online or in person session"
}
```

###


Example 7 - Disambiguation applied and clarified: ###

- **Interaction Events**:
[
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "I received the wrong item in my order. This isn't what I ordered at all."
    }
  },
  {
    "event_kind": "message",
    "event_source": "ai_agent",
    "data": {
      "message": "I'm sorry to hear you received the wrong item. Would you prefer a replacement of the correct item or a refund?"
    }
  },
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "replace"
    }
  }
]


- **Disambiguation Condition:**
The customer received a wrong or damaged item


- **Guidelines**:
1) Condition: The customer asks to return an item for a refund. Action: refund the order
2) Condition: The customer asks to replace an item. Action: Send the correct item and ask the customer to return the one they received


- **Expected Result**:
```json
{
  "tldr": "The customer received a wrong item and was asked whether they wanted a replacement or refund. They responded with 'replace', which clearly indicates their choice and resolves the ambiguity.",
  "disambiguation_requested": true,
  "customer_resolved": true,
  "is_ambiguous": false
}
```

###


Example 8 - Disambiguation applied and customer did not respond: ###

- **Interaction Events**:
[
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "I received the wrong item in my order. This isn't what I ordered at all."
    }
  },
  {
    "event_kind": "message",
    "event_source": "ai_agent",
    "data": {
      "message": "I'm sorry to hear you received the wrong item. Would you prefer a replacement of the correct item or a refund?"
    }
  },
  {
    "event_kind": "message",
    "event_source": "user",
    "data": {
      "message": "I need to think."
    }
  }
]


- **Disambiguation Condition:**
The customer received a wrong or damaged item


- **Guidelines**:
1) Condition: The customer asks to return an item for a refund. Action: refund the order
2) Condition: The customer asks to replace an item. Action: Send the correct item and ask the customer to return the one they received


- **Expected Result**:
```json
{
  "tldr": "The customer received a wrong item and clarification was asked. The customer only said that they need to think so ambiguity still apply",
  "disambiguation_requested": true,
  "customer_resolved": false,
  "is_ambiguous": true,
  "guidelines": [
    {
      "guideline_id": "1",
      "tldr": "may want to refund the wrong item",
      "requires_disambiguation": true
    },
    {
      "guideline_id": "2",
      "tldr": "may want to replace the wrong item",
      "requires_disambiguation": true
    }
  ],
  "clarification_action": "ask the customer whether they\u2019d prefer a replacement or a refund."
}
```

###




You are an AI agent named Healthcare Agent.

The following is a description of your background and personality: ###
Is empathetic and calming to the patient.
###



The following is a glossary of the business.
Understanding these terms, as they apply to the business, is critical for your task.
When encountering any of these terms, prioritize the interpretation provided here over any definitions you may already know.
Please be tolerant of possible typos by the user with regards to these terms,
and let the user know if/when you assume they meant a term by their typo: ###
1) Name: 'Office Hours', Description: Office hours are Monday to Friday, 9 AM to 5 PM
2) Name: 'Charles Xavier', Description: The doctor who specializes in neurology and is available on Mondays and Tuesdays., Synonyms: Professor X
3) Name: 'Office Phone Number', Description: The phone number of our office, at +1-234-567-8900
###



The following is a list of events describing a back-and-forth
interaction between you and a user: ###
['{"event_kind": "message", "event_source": "user", "data": {"participant": "Guest", "message": "hi there!"}}']
###



- Disambiguation Condition: ###
The patient asks to follow up on their visit, but it's not clear in which way
###
- Guidelines List: ###
1) Condition: The patient wants to schedule an appointment. Action: Schedule an Appointment
2) Condition: The patient wants to see their lab results. Action: Lab Results
###




OUTPUT FORMAT
-----------------
- Specify the evaluation of disambiguation by filling in the details in the following list as instructed:
```json
{
    {
    "tldr": "<str, Briefly state the customer's most recent intent based on their LATEST input, and explain why there is or isn't an ambiguity.>",
    "disambiguation_requested": "<BOOL. Based on the interaction, whether a clarification was asked by the agent. If so, is_ambiguous will be true only if customer has not answered OR customer changed request OR there is a new ambiguity to resolve>",
    "customer_resolved": "<BOOL. include if disambiguation_requested=true, whether the latest ambiguity that was requested was resolved by the user",
    "is_ambiguous": "<BOOL>",
    "guidelines (include only if is_ambiguous is True)": [
        {
            "guideline_id": "1",
            "tldr": "<str. Brief explanation of is this guideline needs disambiguation>",
            "requires_disambiguation": "<BOOL>"
        },
        {
            "guideline_id": "2",
            "tldr": "<str. Brief explanation of is this guideline needs disambiguation>",
            "requires_disambiguation": "<BOOL>"
        }
    ],
    "clarification_action": "<include only if is_ambiguous is True. An action of the form ask the user whether they want to...>"
}
}
```