The Agent constructor whose tools should be mocked.
A record mapping tool name to a mock implementation.
{
using _mock = withMockTools(DriveThruAgent, {
orderRegularItem: () => new Error('test failure'),
getWeather: () => 'sunny',
});
const result = await session.run({ userInput: 'Order a burger' });
result.expect.containsFunctionCall({ name: 'orderRegularItem' });
}
Temporarily assign a set of mock tool callables to a specific Agent type. Returns a Disposable for use with a
usingdeclaration. While the binding is in scope, tool calls for the matching agent type and tool name are routed to the supplied mock instead of the realexecuteimplementation, and are restored when the enclosing block exits.Mirrors the Python
mock_toolscontext manager, adapted to JS via the explicit resource managementusingsyntax (Python useswith).