Repository: emcie-co/parlant
File: tests/core/stable/engines/alpha/test_previously_applied_actionable_batch.py (Python)

Code before:
            EventSource.AI_AGENT,
            "Got it — a table for 2 at 7 PM. Would you like to add anything else before I confirm the reservation?",
        ),
        (
            EventSource.CUSTOMER,
            "Yes, actually — it’s for a birthday. Can we get a small cake? Do you have chocolate cakes?",
        ),
        (
            EventSource.AI_AGENT,
            "Yes we have chocolate and cheese cakes. What would you want?",
        ),
        (
            EventSource.CUSTOMER,
            "Great so add one strawberry chocolate cake please.",
        ),
    ]

    guidelines: list[str] = ["confirm_reservation", "unsupported_capability"]

    await base_test_that_correct_guidelines_are_matched(
        context,
        agent,
        new_session.id,
        customer,
        conversation_context,
        guidelines_target_names=["unsupported_capability"],
        guidelines_names=guidelines,
    )


async def test_that_reapplied_guideline_is_still_applied_when_handling_conditions_sub_issue(
    context: ContextOfTest,
    agent: Agent,
    new_session: Session,
    customer: Customer,
) -> None:
    conversation_context: list[tuple[EventSource, str]] = [
        (
            EventSource.CUSTOMER,
            "I’d like to book a table for 2 at 7 PM tonight.",
        ),
        (
            EventSource.AI_AGENT,
            "Got it — a table for 2 at 7 PM. Would you like to add anything else before I confirm the reservation?",
        ),
        (
            EventSource.CUSTOMER,
            "Yes, actually — it’s for a birthday. Can we get a small cake? Do you have chocolate cakes?",
        ),
        (
            EventSource.AI_AGENT,

Review comment (suggestion):
Couple of notes about this test:
1. I think "confirm_reservation" should be matched here since an item is added to the order - do you agree?
2. The unsupported_capability guideline here is a bit ambiguous. I think we should add a context variable with a menu that does not include that item, to clarify that it really is not supported. Also, the term capability is reserved to the "capabilities" section specifically, so maybe the phrasing of that guideline here should be changed. I suggest we discuss it on Tuesday when we talk.

Code after:
        (EventSource.AI_AGENT, "I'm sorry to hear that. "),
        (EventSource.CUSTOMER, "And this isn’t the first time you've ruined my order, honestly."),
    ]
    guidelines: list[str] = ["problem_with_order"]

    await base_test_that_correct_guidelines_are_matched(
        context,
        agent,
        new_session.id,
        customer,
        conversation_context,
        guidelines_target_names=guidelines,
        guidelines_names=guidelines,
    )


async def test_that_previously_applied_guidelines_are_matched_based_on_capabilities(
    context: ContextOfTest,
    agent: Agent,
    new_session: Session,
    customer: Customer,
) -> None:
    capabilities = [
        Capability(
            id=CapabilityId("cap_123"),
            creation_utc=datetime.now(timezone.utc),
            title="Reset Password",
            description="The ability to send the customer an email with a link to reset their password. The password can only be reset via this link",
            signals=["reset password", "password"],
            tags=[],
        )
    ]
    conversation_context: list[tuple[EventSource, str]] = [
        (
            EventSource.CUSTOMER,
            "Set my password to 1234",
        ),
        (
            EventSource.AI_AGENT,
            "I can’t help you with that — it’s against my security policy. Besides, 1234? What is that, your luggage combination too?",
        ),
        (
            EventSource.CUSTOMER,
            "Ok I see. So can you just send me my current password over here?",
        ),
    ]
    await base_test_that_correct_guidelines_are_matched(
        context,
        agent,
        new_session.id,
        customer,