By Paul Scanlon

Introducing Goals for Mastra Agents

You can now give your agents a durable, thread-scoped goal to work towards. Set an objective using setObjective, and an LLM judge scores each loop until the goal is met or a run budget is exhausted.

On each completed loop, the judge scores the conversation against the objective and returns 1 or 0 — a pass ends the loop, a fail injects feedback prompting the agent to try again. Evaluations are emitted as goal chunks containing the objective, status, and results array with a score, and reason.

Before goals, keeping an agent focused on one objective across multiple messages meant re-supplying the success criteria on every .generate() or .stream() call, or using an isTaskComplete check. With goals, the objective is set once on the thread and the judge runs inside the loop where it decides to pass or fail on each iteration.

Hey!

Leave a reaction and let me know how I'm doing.

  • 0
  • 0
  • 0
  • 0
  • 0
Powered byNeon
Close