Class Actions

java.lang.Object
com.tnsai.actions.Actions

public final class Actions extends Object
Framework-owned helpers for action-body wiring.

Home of dispatchedByFramework(): the canonical body for a method whose execution is delegated to ActionExecutor rather than run by Java method invocation. Use it as the default body of any @Capability interface method, or to replace the legacy return null; on concrete @ActionSpec methods whose bodies the framework skips (LLM / MCP / WEB_SERVICE without an ActionResult parameter).

The throw, not a null return, is the whole point: if anyone ever invokes the method outside the framework dispatch path, the call blows up loudly with a clear message instead of silently handing back null and confusing the caller about whether the LLM actually ran.

Since:
0.4.0
  • Field Details

    • DISPATCHED_MESSAGE_PREFIX

      public static final String DISPATCHED_MESSAGE_PREFIX
      Stable message prefix so log greps and test assertions don't break on a rewording.
      See Also:
  • Method Details

    • dispatchedByFramework

      public static RuntimeException dispatchedByFramework()
      Returns a RuntimeException describing the bypass.

      Callers throw this from the method body. Not returned by value — returning it would let silent-call sites quietly keep going.

      Standard usage (concrete class):

      
       @ActionSpec(type = ActionType.LLM, ...)
       public String summarize(String text) {
           throw Actions.dispatchedByFramework();
       }
       
      Standard usage (capability interface):
      
       @Capability
       public interface Summarizer {
           @ActionSpec(type = ActionType.LLM, ...)
           default String summarize(String text) {
               throw Actions.dispatchedByFramework();
           }
       }
       
      Returns:
      an exception ready to be thrown
    • dispatchedByFramework

      public static RuntimeException dispatchedByFramework(String roleName, String methodName)
      Returns a contextualised variant that names the role + method in the message. Preferred when you can cheaply supply the context; otherwise use the no-arg form.
      Parameters:
      roleName - human-readable role identifier
      methodName - the method that was invoked directly
      Returns:
      an exception ready to be thrown