liveBook · Manning

Goal

As explained in Spring AI in Action

A goal is a desired state or result that an agent seeks to achieve through its actions.

A goal names a desired result an agent should achieve. In Embabel, an action annotated with @AchievesGoal marks the finishing point of a workflow. section 12.3.2

Use goals to structure agent behavior:

  • Define the desired outcome, such as determining game mechanics or player counts. section 12.3.2
  • Work backward by adding actions that supply the workflow needed to reach the goal. section 12.3.2
  • Inspect goals and their preconditions through the agent shell, then execute user input against the resulting workflow. section 12.3.6
Listing 12.8 An action method that achieves the goal of determining game mechanics
@Value("classpath:/promptTemplates/mechanicsDeterminer.st")  #1
Resource mechanicsDeterminerPromptTemplate;

@Action
@AchievesGoal(description = "Game mechanics have been determined.")   #2
public GameMechanics determineGameMechanics(GameRules gameRules) {
  LOGGER.info("Determining mechanics from rules for: {}",
              gameRules.gameTitle());

  var prompt = promptResourceToString(mechanicsDeterminerPromptTemplate,  #3
      Map.of("gameRules", gameRules.rulesText()));

  return PromptRunner.usingLlm()
      .createObject(prompt, GameMechanics.class);  #4
}

Shows an action that uses @AchievesGoal to derive structured game mechanics from game rules through an LLM. section 12.3.2

How Spring AI in Action covers it

How deep it goes
Defines goal-achieving actions and exposes goal preconditions, but defers deeper planning internals.
Examples
Demonstrates goals for determining board-game mechanics and player counts, including Azul queries executed through the shell.
What you can do after
Build goal-oriented agent workflows whose terminal actions return structured answers.
How it connects
Connects goals with agents, actions, workflows, preconditions, and structured LLM output.

Also explained in

Compare how 11 books explain goal →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring AI in Action. The section links point to the parts of the book it draws on.