Class ActionExecutionResult

java.lang.Object
com.tnsai.integration.scop.ActionExecutionResult

public class ActionExecutionResult extends Object
Result of a TnsAI action execution.
  • Method Details

    • success

      public static ActionExecutionResult success(Object result, String preNarration, String postNarration)
    • success

      public static ActionExecutionResult success(Object result, String preNarration, String postNarration, String accessBindingFingerprint)
    • error

      public static ActionExecutionResult error(String errorMessage, Exception exception)
    • getAccessBindingFingerprint

      public String getAccessBindingFingerprint()
      Checked target/policy/caller binding of a successful dispatch; null for undeclared actions. Not a permit.
    • isSuccess

      public boolean isSuccess()
    • isAuthorizationDenied

      public boolean isAuthorizationDenied()
      Whether this failed dispatch contains a typed UNAUTHORIZED cause. Consumers must terminate the current tool turn without asking the model to invent a replacement result; getNarration() is safe denial text. This is a failure disposition, not an authorization grant or a success.
    • getResult

      public Object getResult()
    • getPreNarration

      public String getPreNarration()
    • getPostNarration

      public String getPostNarration()
    • getErrorMessage

      public String getErrorMessage()
    • getException

      public Exception getException()
      Original failure for local diagnostics; its message may contain sensitive policy details.
    • getNarration

      public String getNarration()
      Gets the narration to display to the user. Returns postNarration on success, errorMessage on failure.
    • getOutcome

      public String getOutcome()
      Gets what the action returned, or why it failed, without the narration around it: the text an agent keeps about the action it called.

      On success this is the result's own toString, or "Action completed." when the result is null, its text is blank or is the identity text Object.toString gives it, its class has no toString of its own, or that toString fails. The narration, retrieved context and the owner's state are never used. A result whose own text includes another object's identity text, such as a list of objects without a toString, gives that text as it is. For a SCOP action that has run, it is the action's own post-narration, or "Action completed." without one.

      On failure it is the reason the narration gives, without its "Action <name> failed: " prefix, decided in this order:

      • "This action is not authorized." when authorization was denied, that is, when a TnsAI SecurityException of type UNAUTHORIZED is anywhere in the failure's chain;
      • a retrieval failure's public reason;
      • for an ActionExecutionException, its own message, which for a failure in the action's body is its root cause's type and message as the executor narrates it, for example "IOException: disk full", or "Failed to execute action: <name>" when any other security exception is in the chain;
      • for any other exception, its cause's message when it has a cause, and its own message when it has none;
      • "Action failed." when that reason is null or blank.

      When the reason is the message of a TnsAI exception raised inside an agent context, it ends with that context, such as [agent=..., session=...], and is that context alone when the exception has no message of its own. A failure made by error(String, Exception) gives its narration as it is.

      Returns:
      the outcome, never null
      Since:
      0.18.5