SelfCorrectionConfig¶
This docs was updated at: 2026-03-21
com.paragon.harness.SelfCorrectionConfig ยท Class
Configuration for the self-correction loop in SelfCorrectingInteractable.
Self-correction automatically retries a failed agent run by injecting the error back as user context, giving the agent a chance to fix its own mistakes.
Example:
SelfCorrectionConfig config = SelfCorrectionConfig.builder()
.maxRetries(3)
.retryOn(result -> result.isError() || result.isGuardrailFailed())
.feedbackTemplate("Your previous response failed with: {error}. Please try again.")
.build();
See Also
SelfCorrectingInteractable
Since: 1.0
Fields¶
DEFAULT_FEEDBACK_TEMPLATE¶
public static final String DEFAULT_FEEDBACK_TEMPLATE =
"Your previous response failed with the following error:\n\n"
+ "
Default feedback template injected on failure.
Methods¶
maxRetries¶
Returns the maximum number of retry attempts.
Returns
max retries
retryOn¶
Returns the predicate that decides whether a result should trigger a retry.
Returns
retry predicate
feedbackTemplate¶
Returns the feedback template. Use {error} as a placeholder for the error message.
Returns
feedback template
formatFeedback¶
Formats the error message into the feedback template.
Parameters
| Name | Description |
|---|---|
errorMessage |
the error message to inject |
Returns
the formatted feedback string
builder¶
Returns a new builder with sensible defaults:
- maxRetries = 3
- retryOn = any error result
- feedbackTemplate =
.DEFAULT_FEEDBACK_TEMPLATE
Returns
a new builder
maxRetries¶
Sets the maximum number of self-correction retries.
Parameters
| Name | Description |
|---|---|
maxRetries |
must be positive |
Returns
this builder
retryOn¶
Sets the predicate that decides whether to retry.
Parameters
| Name | Description |
|---|---|
retryOn |
predicate returning true when a retry should be attempted |
Returns
this builder
feedbackTemplate¶
Sets the feedback template. Use {error} where you want the error message injected.
Parameters
| Name | Description |
|---|---|
feedbackTemplate |
the template string |
Returns
this builder
build¶
Builds the configuration.