SOFTWARE ENGINEERING / FIELD NOTE

AI with boundaries: why architecture comes before the prompt

An architecture guide for using AI models in products without handing rules, state, or critical decisions to probabilistic behavior.

Dark WhatsApp support dashboard with AI controls and transfer to human operators.
In an operational product, disabling AI and transferring context to a person are architecture—not improvised exceptions.

Adding a language model to a product initially looks like a prompt problem. Write an instruction, send context, receive text, and the demo comes alive. The gap between a convincing demo and a dependable system begins when the response stops being the whole product and becomes one component inside it.

Models are probabilistic. Business rules, balances, permissions, game progression, and state transitions should not be. Architecture must recognize that distinction before an excellent prompt hides a poorly drawn boundary.

The model is a component, not the system

A healthy integration treats AI as a specialized capability: interpret intent, suggest a reply, summarize context, classify a message, or produce a narrative possibility. Identity, authorization, state, policies, telemetry, and recovery mechanisms still surround it.

That separation changes the questions:

  • what context does the model actually need;
  • which actions may it only propose;
  • which actions require deterministic validation;
  • when should an answer be blocked or routed elsewhere;
  • how can the decision be reconstructed after failure;
  • how does a person take over without losing context?

The prompt remains important, but it no longer carries responsibilities that belong to the rest of the software.

1. Keep authoritative state outside AI

In AI_VTT, the game master may narrate a secret door, play a character, and react to an unexpected choice. It must not independently decide remaining health, reachable movement, or a die result. Those facts belong to the rules engine and persisted campaign state.

The pattern extends beyond games. A sales assistant may suggest that a lead is qualified, but changing the CRM stage must follow a known, auditable action. A financial agent may explain an order intent, but it must never replace risk and authorization gates.

Language can be probabilistic. Critical consequences need a deterministic boundary.

An AI response can become a proposed command. The system validates identity, current state, rules, and limits before applying a transition. If validation fails, the proposal is discarded without corrupting the primary workflow.

2. Treat context as a contract

Sending “everything we know” seems convenient but increases cost, latency, and risk. Context should be assembled for a specific task, with known provenance and validity.

A useful contract distinguishes at least four groups:

  1. identity: who is asking and what permissions they hold;
  2. state: current facts required for the decision;
  3. policy: what the capability may and may not do;
  4. history: only the relevant window needed for continuity.

This structure reduces contradiction and improves testing. When an answer is poor, the team can ask whether the cause was an instruction, a missing fact, ambiguous policy, or model behavior.

It also prevents generated text from gaining authority by accident. A narrative description may enter history as content; inventory changes enter state only after the responsible engine confirms them.

3. Put policy before and after the model

A guardrail is not a sentence at the end of a prompt. It is a sequence of decisions around the call.

Before the model, the system can limit available tools, remove unnecessary data, check permissions, and choose a specialized route. Afterward, it can validate format, references, proposed commands, and business conditions.

Syntax and domain validation are different. A response containing a “time” field does not prove the slot is available, belongs to the correct unit, or respects service duration. The model may structure intent; the domain remains responsible for operational truth.

In Auto Whats, a conversation may produce a scheduling or qualification suggestion. The application still queries the correct data, applies policy, and records the change through an explicit path.

4. Design human handoff with the workflow

Transfer to a person should not be a panic button added after launch. In many AI products, it is a normal route.

A good handoff gives the operator:

  • the goal the person tried to accomplish;
  • the facts automation used;
  • actions already executed;
  • the uncertainty or blocking point;
  • a short conversation summary;
  • the ability to continue without asking everything again.

It must also stop automation unambiguously. Two agents replying at once destroy trust. Auto Whats therefore treats per-conversation AI control and human transfer as central parts of the experience.

5. Observe decisions, not only answers

Judging whether text “looks good” is insufficient. The system should record relevant inputs, policy version, model, tool calls, validations, latency, cost, and outcome.

That does not mean retaining sensitive content without limits. Telemetry also needs minimization and deliberate retention. The objective is to reconstruct decisions and find failure patterns without turning observability into unrestricted collection.

Useful signals vary by product:

  • handoff rate and transfer reason;
  • responses blocked by policy;
  • proposed commands that failed validation;
  • operator corrections;
  • latency to the first useful action;
  • continuity after session recovery;
  • cost per completed workflow, not only per call.

A minimal architecture for applied AI

A small vertical slice can preserve the right boundaries:

  1. the interface records an intent;
  2. the service authenticates and assembles minimal context;
  3. policy chooses capability and tools;
  4. the model produces text or a structured proposal;
  5. deterministic validators check format and domain;
  6. the system applies, requests confirmation, or hands off;
  7. telemetry records path and outcome.

Not every workflow needs equal complexity in all seven steps. The value is knowing where responsibility lives. That clarity lets teams change model, provider, or prompting strategy without rewriting the domain.

Three projects, one principle

TestaAí experiments apply the principle differently.

In AI_VTT, AI controls narration and interpretation while rules and campaign remain authoritative. In Auto Whats, AI accelerates service while operators keep visibility and control. In Project Renaissance, intelligent components may support research, while execution remains behind OMS, risk, and explicit enablement.

The technologies change. The decision remains: probabilistic capabilities do not receive silent authority over critical consequences.

Checklist before integrating a model

Before writing the first production prompt, answer:

  • what narrow task belongs to the model;
  • which data is necessary and which must stay out;
  • where true state lives;
  • which tools may be called;
  • who validates a proposed action;
  • how the workflow fails safely;
  • when and how a person takes over;
  • what will be observed to improve quality;
  • how model or provider can change without breaking the domain.

If those answers are still mixed inside the prompt, the risk is not merely a poor response. It is a system without boundaries.

Applied AI becomes more interesting when it stops being the central trick and operates as a well-designed part of the product. The model expands the experience. Architecture preserves trust.

See the technical map of experiments and meet the engineering profile behind the lab.

FIELD NOTE / AI-WITH-BOUNDARIES-ARCHITECTURE-BEFORE-THE-PROMPT

Written by Zero from TestaAí experiments. AI may support structure and review; authorship and responsibility remain human.

FROM TEXT / TO PRODUCT

The idea is clear.
Now, test it.

Enter the lab