Guará Framework: Turning BDD into 'Executable Narratives' for AI Agents

The Guará framework proposes using BDD—traditionally a testing tool—directly in production code. This provides AI agents with structured contracts to follow, reducing prompt complexity and saving token costs.

Guará is a Python library that allows developers to write Behavior-Driven Development (BDD) scenarios directly in code without complex setup. It is now being explored as a way to create 'executable narratives' that define exactly how an AI agent should behave. Instead of relying on long, expensive system prompts, developers can use these structured scripts to guide agents predictably. This approach minimizes hallucinations and saves money by reducing the amount of thinking the AI needs to do. It also generates human-readable reports, making it easier for non-experts to monitor and verify an agent's actions.

Key points

  • Define agent behaviors as structured 'Given-When-Then' scenarios in Python.
  • Replace vague, expensive system prompts with precise behavioral contracts.
  • Lower token costs by providing deterministic paths for AI agents to follow.
  • Create automatic, easy-to-read reports of an agent’s reasoning process

Quick term guide

production code
The final, live software that real users interact with.
token costs
Token costs are the fees paid for the text an AI model reads and writes.
token cost
The money or usage spent when sending text to an AI model and getting text back.
developers
Developers are people who build software, apps, or websites.
system prompts
Instructions you give an AI before a conversation starts to shape how it behaves throughout.
system prompt
A hidden set of basic instructions that guides how an AI tool behaves.
hallucinations
Errors where an AI generates false information that looks real.
hallucination
When AI makes something up and presents it as a real answer.
Read original