Skip to main content
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.
Guava Agent tests are defined in code. You can write them using your existing testing framework, such as 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

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

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. Use agent.patch() to create a clone of the Agent where you can override callbacks without modifying the original Agent.
test_patched_agent.py
For any function that isn’t an Agent handler, you can patch it using Python’s builtin patching system.

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.
test_help_desk.py