Class FakeLlmClient

java.lang.Object
com.agentforge4j.llm.fake.FakeLlmClient
All Implemented Interfaces:
LlmClient

public final class FakeLlmClient extends Object implements LlmClient
Stateless LlmClient that replays pre-scripted responses instead of calling a model. It holds only its FakeResponseSource; all per-run state (scripts and ordinal counters) lives in the source's store, so a single instance safely serves concurrent runs.

Keying: the response is selected by the request's LlmInvocationIdentity (workflowId, runId, stepId, agentId) plus a per-sequence ordinal the source advances. Every resolution failure is fail-closed via FakeResponseNotFoundException; the fake never fabricates a default.

  • Constructor Details

    • FakeLlmClient

      public FakeLlmClient(FakeResponseSource responseSource)
      Creates a client backed by the given response source.
      Parameters:
      responseSource - the scripted response source; must not be null
  • Method Details

    • getProviderName

      public String getProviderName()
      Description copied from interface: LlmClient
      Returns the provider id this client executes against (lowercase, such as "openai").
      Specified by:
      getProviderName in interface LlmClient
      Returns:
      non-blank provider id
    • execute

      public LlmExecutionResponse execute(LlmExecutionRequest request)
      Description copied from interface: LlmClient
      Executes an LLM request and returns the response.
      Specified by:
      execute in interface LlmClient
      Parameters:
      request - provider id, prompts, and optional model override for this call
      Returns:
      execution response containing model output and optional token usage