Package com.tnsai.context.decision
Class DecisionReasoning
java.lang.Object
com.tnsai.context.decision.DecisionReasoning
Represents the reasoning process behind a decision.
DecisionReasoning captures how the agent arrived at its decision: the steps taken, alternatives considered, and confidence level. This enables explaining "why" to users and auditors.
Usage Example
DecisionReasoning reasoning = DecisionReasoning.builder()
.step("Retrieved customer account status from CRM")
.step("Verified premium membership is active")
.step("Calculated maximum allowable discount: 25%")
.step("Requested discount (20%) is within limits")
.alternative("Deny request", "Not considered - customer is in good standing")
.alternative("Offer 15% instead", "Not needed - 20% is acceptable")
.summary("Approved 20% discount based on premium status and order value")
.confidence(0.95)
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents an alternative that was considered.static classBuilder for DecisionReasoning.static final recordRepresents a step in the reasoning process. -
Method Summary
Modifier and TypeMethodDescriptionstatic DecisionReasoning.Builderbuilder()Creates a new builder.explain()Generates a human-readable explanation.doubleintGets the number of reasoning steps.getSteps()booleanReturns true if alternatives were considered.booleanReturns true if there are uncertainties.booleanReturns true if confidence is high (>= 0.9).booleanReturns true if confidence is low (invalid input: '<' 0.7).static DecisionReasoningCreates a simple reasoning with just a summary.toString()
-
Method Details
-
builder
Creates a new builder. -
simple
Creates a simple reasoning with just a summary. -
getSteps
-
getConsideredAlternatives
-
getSummary
-
getConfidence
public double getConfidence() -
getRationale
-
getAssumptions
-
getUncertainties
-
isHighConfidence
public boolean isHighConfidence()Returns true if confidence is high (>= 0.9). -
isLowConfidence
public boolean isLowConfidence()Returns true if confidence is low (invalid input: '<' 0.7). -
hasAlternatives
public boolean hasAlternatives()Returns true if alternatives were considered. -
hasUncertainties
public boolean hasUncertainties()Returns true if there are uncertainties. -
getStepCount
public int getStepCount()Gets the number of reasoning steps. -
explain
Generates a human-readable explanation.- Returns:
- explanation string
-
toString
-