MockEnvironment

class MockEnvironment(toolRegistry: ToolRegistry, promptExecutor: PromptExecutor, baseEnvironment: AIAgentEnvironment? = null) : AIAgentEnvironment(source)

A mock implementation of AIAgentEnvironment used for testing agent behavior.

This class provides a controlled environment for testing agents by:

  1. Executing tool calls using either mocked responses or actual tool implementations

  2. Handling exceptions by re-throwing them for test visibility

  3. Optionally delegating termination signals to a base environment

It works in conjunction with MockLLMExecutor to provide a complete testing framework for agent interactions.

Constructors

Link copied to clipboard
constructor(toolRegistry: ToolRegistry, promptExecutor: PromptExecutor, baseEnvironment: AIAgentEnvironment? = null)

Functions

Link copied to clipboard
open suspend override fun executeTools(toolCalls: List<Message.Tool.Call>): List<ReceivedToolResult>

Executes a list of tool calls and returns their results.

Link copied to clipboard
open suspend override fun reportProblem(exception: Throwable)

Reports a problem by throwing the exception.