Files
livekit-agents/python/tests/test_instructions.py
T

30 lines
1.0 KiB
Python

"""Static agent and workflow instruction authoring."""
import pytest
from livekit.agents.beta.workflows import WarmTransfer, WorkflowInstructions
pytestmark = pytest.mark.unit
def test_workflow_sections_produce_static_agent_instructions() -> None:
transfer = WarmTransfer(
"+15550100",
sip_trunk_id="trunk",
instructions=WorkflowInstructions(
persona="You are the desk.", extra="Confirm the booking."
),
)
instructions = transfer._agent.instructions
assert isinstance(instructions, str)
assert "You are the desk." in instructions
assert "Confirm the booking." in instructions
assert instructions.count("You are the desk.") == 1
for placeholder in ("{persona}", "{extra}", "{_conversation_history}"):
assert placeholder not in instructions
def test_fixed_workflow_instructions_replace_the_template() -> None:
transfer = WarmTransfer("+15550100", sip_trunk_id="trunk", instructions="Fixed text.")
assert transfer._agent.instructions == "Fixed text."