ag2-testing
Installation
SKILL.md
Testing agents and tools
When to use
Writing tests for code that builds AG2 beta Agents, custom @tool functions, middleware, or response schemas — anywhere you don't want to make real LLM API calls.
60-second recipe — mock an LLM response
import pytest
from autogen.beta import Agent
from autogen.beta.testing import TestConfig
@pytest.mark.asyncio
async def test_mocked_response():
agent = Agent("test_agent")
reply = await agent.ask("Hi!", config=TestConfig("This is a mocked response."))
assert reply.body == "This is a mocked response."