• Temporarily assign a set of mock tool callables to a specific Agent type. Returns a Disposable for use with a using declaration. 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 real execute implementation, and are restored when the enclosing block exits.

    Mirrors the Python mock_tools context manager, adapted to JS via the explicit resource management using syntax (Python uses with).

    Parameters

    • agent: AgentConstructor

      The Agent constructor whose tools should be mocked.

    • mocks: Record<string, MockToolFn>

      A record mapping tool name to a mock implementation.

    Returns Disposable

    Example

    {
    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' });
    }