Class StaticFakeResponseSource

java.lang.Object
com.agentforge4j.llm.fake.StaticFakeResponseSource
All Implemented Interfaces:
FakeResponseSource

public final class StaticFakeResponseSource extends Object implements FakeResponseSource
A FakeResponseSource backed by a single, run-agnostic FakeScript: every run is served the same script. For single-workflow dev and demos where there is no per-run registration.

Counters are still strictly run-scoped — each run id gets its own ordinal sequences and is TTL-evicted — so repeated runs do not share an ever-climbing counter and the counter map does not leak. This source therefore never reports FakeResolution.RunNotScripted: the run's entry is created on first use from the single script.

  • Constructor Details

    • StaticFakeResponseSource

      public StaticFakeResponseSource(FakeScript script)
      Creates a static source with default (no TTL, no cap) run-scoped counters.
      Parameters:
      script - the single script served to every run; must not be null
    • StaticFakeResponseSource

      public StaticFakeResponseSource(FakeScript script, FakeRunLifecycle counters)
      Creates a static source whose run-scoped counters use the given lifecycle store (for TTL/cap leak guards). The store is used only for counters and per-run TTL; scripts are not registered against it explicitly.
      Parameters:
      script - the single script served to every run; must not be null
      counters - lifecycle store for run-scoped counters; must not be null
  • Method Details

    • nextResponse

      public FakeResolution nextResponse(FakeInvocation invocation)
      Description copied from interface: FakeResponseSource
      Atomically advances the per-sequence ordinal for this invocation and resolves the response. Implementations must keep counters isolated per FakeInvocation.runId() so concurrent runs never interleave. When no script is available for the run, no counter is advanced and FakeResolution.RunNotScripted is returned.
      Specified by:
      nextResponse in interface FakeResponseSource
      Parameters:
      invocation - the invocation identity (run, workflow, step, agent); never null
      Returns:
      the resolution: a found response, a missing key, or an unscripted run