Design Considerations

Embabel is designed to give you the ability to determine the correct balance between LLM autonomy and control from code. This section discusses the design considerations that you can use to achieve this balance.

Domain objects

A rich domain model helps build a good agentic system. Domain objects should not merely contain state, but also expose behavior. Avoid the anemic domain model. Domain objects have multiple roles:

  1. Ensuring type safety and toolability. Code can access their state; prompts will be strongly typed; and LLMs know what to return.
  2. Exposing behavior to call in code, exactly as in any well-designed object-oriented system.
  3. Exposing tools to LLMs, allowing them to call domain objects.

The third role is novel in the context of LLMs and Embabel.

Expose methods that LLMs should be able to call using the @Tool annotation:

@Tool(description = "Build the project using the given command in the root") // ①
public String build(String command) {
    BuildResult br = ci.buildAndParse(new BuildOptions(command, true));
    return br.relevantOutput();
}
  1. The Spring AI @Tool annotation indicates that this method is callable by LLMs.

When an @Action method issues a prompt, tool methods on all domain objects are available to the LLM.

You can also add additional tool methods with the withToolObjects method on PromptRunner.

Domain objects may or may not be persistent. If persistent, they will likely be stored in a familiar JVM technology such as JPA or JDBC. We advocate the use of Spring Data patterns and repositories, although you are free to use any persistence technology you like.

Tool Call Choice

When to use MCP or other tools versus method calls in agents

Mixing LLMs

It’s good practice to use multiple LLMs in your agentic system. Embabel makes it easy. One key benefit of breaking functionality into smaller actions is that you can use different LLMs for different actions, depending on their strengths and weaknesses. You can also the cheapest (greenest) possible LLM for a given task.

Was this page helpful?

Share