Package dyntabs.ai

Class EasyAgent

java.lang.Object
dyntabs.ai.EasyAgent

public class EasyAgent extends Object
An AI agent that autonomously plans and executes multi-step tasks by orchestrating calls to your registered Java services.

Unlike a regular AI assistant (which answers a single question), an EasyAgent receives a complex task and breaks it into steps, calling your service methods in the right order, using the result of each step to decide what to do next.

Quick Start


 // Your existing Jakarta EE services — no changes needed
 @Stateless InventoryService inventoryService;
 @Stateless PaymentService   paymentService;
 @Stateless OrderService     orderService;

 EasyAgent agent = EasyAI.agent()
     .withServices(inventoryService, paymentService, orderService)
     .withMaxSteps(10)
     .withPlanningPrompt(true)
     .withStepListener(step ->
         log.info("[AGENT] Step {}: {}({}) -> {}",
             step.stepNumber(), step.toolName(),
             step.arguments(), step.result()))
     .build();

 String result = agent.execute(
     "Order 2 laptops for user U123, apply loyalty credit, " +
     "use fallback warehouse WH-EU if out of stock."
 );
 

What the agent does autonomously

  1. Receives the task description
  2. Plans which service methods to call and in what order
  3. Executes each step, passing results forward
  4. Adapts the plan if a step fails or returns unexpected data
  5. Returns a final natural-language summary when done

Safety

Always set withMaxSteps() to cap the number of tool calls. Without a limit, a complex task could generate many sequential calls, significantly increasing token usage and cost. The default is 10 steps.

Transactional note

EasyAgent does not manage transactions across steps. If the agent calls payment.process() and then fails on the next step, the payment will not be rolled back. Design your services to be idempotent or provide compensating transactions where needed.

See Also:
  • Method Details

    • execute

      public String execute(String task)
      Executes the given task description.

      The agent will autonomously call your registered services in the correct order to complete the task, up to the configured maxSteps limit.

      
       String result = agent.execute(
           "Poruči 2 laptopa za korisnika U123, iskoristi loyalty kredit, " +
           "dostavi na Beograd. Ako nema na lageru, uzmi iz magacina WH-EU."
       );
       
      Parameters:
      task - a natural-language description of the task to perform
      Returns:
      a natural-language summary of what was done and the final outcome