Annotation Interface Outcome


@Target(METHOD) @Retention(RUNTIME) public @interface Outcome
Marks a method as the outcome of an agent workflow.

Outcome methods are optional workflow phases that denote completion and produce final results, side effects, or state management. The outcome phase executes after other workflow phases have completed successfully, providing an opportunity to finalize workflow results, audit operations, trigger downstream processes, or clean up resources.

Workflows can omit the outcome phase if finalization is not needed.

An agent may currently declare zero or one @Outcome methods. This will likely be relaxed in future versions to adapt to more complex dynamic workflows.

Parameters
Outcome methods can have the following types of parameters that will be automatically resolved:

  • Workflow state domain objects - Any objects used by prior phases in the workflow - triggers, decisions, and actions
  • LargeLanguageModel - LLM instance for analysis, summarization, or content generation based on workflow results
  • Any other CDI injectable dependencies available to the agent - typically in the application scope or managed by the container

Parameters can declare Jakarta Validation constraints (e.g., @Valid, @NotNull). Validation occurs before the outcome method is invoked. Validation failures raise jakarta.validation.ConstraintViolationException, which can be handled by @HandleException methods.

Return type
Outcome methods currently must return void. The outcome phase is designed for finalization and side effects rather than producing data for further processing. In the future, return types may be supported to allow outcome methods to pass on results to downstream systems or workflows.

Semantics

  • Outcome methods execute after preceding workflow phases complete
  • Optional - agents can omit outcome if finalization is not needed
  • Marks the end of successful workflow execution
  • The current workflow context will be destroyed by the container after outcome completion

Examples


 // Simple outcome - finalizes workflow state
 @Outcome
 public void finalizeTransaction(BankTransaction transaction) {
     transaction.setProcessed(true);
     transaction.setProcessedTime(System.currentTimeMillis());
     entityManager.merge(transaction);
 }

 // Outcome receiving action result
 @Outcome
 public void recordOutcome(FraudReport report) {
     auditLog("Fraud case processed: " + report.getId());
 }

 // Outcome with multiple decision/action results
 @Outcome
 public void publishResults(
     DocumentationFiles generatedFiles,
     PullRequestEvent originalEvent
 ) {
     String docPrUrl = generatedFiles.getDocPrUrl();
     notificationService.notifyUser(
         originalEvent.getAuthor(),
         "Documentation generated at: " + docPrUrl
     );
 }

 // Outcome with LLM for summarization
 @Outcome
 public void summarizeAndArchive(
     CustomerSupportResponse response,
     LargeLanguageModel llm
 ) {
     String summary = llm.query(
         "Summarize the customer support interaction",
         response
     );
     ticketService.archive(summary);
 }
 
Since:
1.0
See Also: