Class LlmChaosProfile
HttpLlmResponse, for testing
agent resilience: probabilistic provider errors (e.g. 429/529 with a
Retry-After header), mid-stream truncation, and malformed SSE chunks.
Determinism: with errorProbability of 1.0 (always) or
0.0/null (never) the error decision is fully deterministic. A
fractional probability draws once per response; set seed to make that
single draw reproducible (note: a fixed seed yields the same decision every
time). Truncation and malformed-SSE are deterministic. Follows the model
field/withX/getter convention so it round-trips without a bespoke
(de)serializer.
It also carries an optional stateful request quota (a fixed-window
rate limit): when quotaName, quotaLimit, and
quotaWindowMillis are set, requests beyond quotaLimit within
the window are rejected with quotaErrorStatus (default 429) and the
retryAfter header. Unlike the probabilistic error this is
deterministic and counts real requests across the process (see
LlmQuotaRegistry); expectations sharing a
quotaName share one counter.
A separate token-based quota (tokenQuotaLimit +
tokenQuotaWindowMillis) models TPM/TPD limits: the cumulative token
count of each response is charged against the window and a 429 is returned
when the sum exceeds the limit. Both request-count and token quotas can be
active simultaneously on the same profile (they use independent counters
within the registry, namespaced by suffix).
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetSeed()inthashCode()static LlmChaosProfilewithErrorProbability(Double errorProbability) withErrorStatus(Integer errorStatus) withMalformedSse(Boolean malformedSse) withQuotaErrorStatus(Integer quotaErrorStatus) withQuotaLimit(Integer quotaLimit) withQuotaName(String quotaName) withQuotaWindowMillis(Long quotaWindowMillis) withRetryAfter(String retryAfter) withTokenQuotaLimit(Long tokenQuotaLimit) Maximum tokens allowed within the token quota window (TPM or TPD depending on window size).withTokenQuotaWindowMillis(Long tokenQuotaWindowMillis) Window length in milliseconds for the token-based quota.withTruncateAtFraction(Double truncateAtFraction) withTruncateMode(LlmChaosProfile.TruncateMode truncateMode) Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
fieldsExcludedFromEqualsAndHashCode
-
Constructor Details
-
LlmChaosProfile
public LlmChaosProfile()
-
-
Method Details
-
llmChaosProfile
-
withErrorStatus
-
getErrorStatus
-
withRetryAfter
-
getRetryAfter
-
withErrorProbability
-
getErrorProbability
-
withTruncateMode
-
getTruncateMode
-
withTruncateAtFraction
-
getTruncateAtFraction
-
withMalformedSse
-
getMalformedSse
-
withSeed
-
getSeed
-
withQuotaName
-
getQuotaName
-
withQuotaLimit
-
getQuotaLimit
-
withQuotaWindowMillis
-
getQuotaWindowMillis
-
withQuotaErrorStatus
-
getQuotaErrorStatus
-
withTokenQuotaLimit
Maximum tokens allowed within the token quota window (TPM or TPD depending on window size). RequiresquotaNameandtokenQuotaWindowMillisto be set. Uses the samequotaErrorStatusandretryAfteras the request-count quota. -
getTokenQuotaLimit
-
withTokenQuotaWindowMillis
Window length in milliseconds for the token-based quota. RequiresquotaNameandtokenQuotaLimitto be set. -
getTokenQuotaWindowMillis
-
equals
- Overrides:
equalsin classObjectWithReflectiveEqualsHashCodeToString
-
hashCode
public int hashCode()- Overrides:
hashCodein classObjectWithReflectiveEqualsHashCodeToString
-