TestAgent
autogen.testing.test_agent.TestAgent #
A context manager for testing ConversableAgent instances with predefined messages.
This class allows you to temporarily replace an agent's LLM client with a fake client that returns predefined messages. It's useful for testing agent behavior without making actual API calls.
| ATTRIBUTE | DESCRIPTION |
|---|---|
agent | The agent to be tested. TYPE: |
messages | An iterable of messages to be returned by the fake client. |
suppress_messages_end | Whether to suppress StopIteration exceptions from the fake client. TYPE: |
Example
with TestAgent(agent, ["Hello", "How are you?"]) as test_agent: ... # Agent will respond with "Hello" then "How are you?" ... pass