- Python
- TypeScript
This guide focuses on automated testing. For manual testing, use
agent.call_local() to place a test call using your local audio device, or agent.chat() to interact with your agent via text in the terminal.pytest or Python’s built-in unittest module. This lets you test your Agent end-to-end alongside your Expert’s code, using patterns you’re already familiar with.Test individual Agent handlers with MockCall
- Python
- TypeScript
The most basic way to test Guava Agents is to test individual handlers like
on_action_request or on_question. You can do so by constructing a guava.testing.MockCall object and passing it in directly to the handler.test_agent.py
Run a roleplay session and analyze the result
- Python
- TypeScript
agent.roleplay(prompt="...") runs your agent against a separate LLM that improvises a conversation based on a prompt. The session runs to completion and returns a TestSession object you can assert against. As in a real call, your registered handlers will be invoked by the Agent.The returned session object contains the transcript, useful helpers that can be asserted against, and a session.evaluate function that evaluates the conversation against a rubric.test_roleplay.py
Patch Agent handlers before testing
In some cases, you may not want every handler to run during a test. Useagent.patch() to create a clone of the Agent where you can override callbacks without modifying the original Agent.
- Python
- TypeScript
test_patched_agent.py
Run a session with full control
agent.test() gives you a live test session where you have full control over timing and caller utterances.
Use this when you need precise control over how the conversation unfolds.
- Python
- TypeScript
test_help_desk.py