Skip to content
Bots

Engineering

The standard we apply to every project.

For teams reviewing the architecture before committing. Nine practices required for every delivery and the reasons behind them.

The principle

Use the LLM for language. Keep decisions auditable.

Language models are useful for interpreting ambiguous requests and writing clear responses. They do not provide a reproducible, line-by-line testable record of a business decision.

That boundary is explicit. Decisions that require justification live in deterministic code. The agent receives and communicates the result.

In this example, the model never approves or denies credit. It receives a Decisao that is already complete, with a reason and policy identifier, and writes the customer message.

business/credito.py
# Pure function. Same input, same decision. Always.
# Covered by unit tests. Traceable through Git history.

def avaliar_elegibilidade(proposta: Proposta) -> Decisao:

    if proposta.idade < IDADE_MINIMA:
        return Decisao.negar(
            motivo="IDADE_MINIMA",
            politica="POL-CRED-014",
        )

    if proposta.score < faixa_minima(proposta.produto):
        return Decisao.negar(
            motivo="SCORE_ABAIXO_DA_FAIXA",
            politica="POL-CRED-021",
        )

    return Decisao.aprovar(
        limite=calcular_limite(proposta),
        politica="POL-CRED-030",
    )

# O agente recebe a Decisao pronta e escreve a mensagem.
# It cannot approve or deny.

Practices

Nine required practices and why they matter.

01

Deterministic decisions outside the model

Authorization, calculations, rule-based classification and eligibility are pure Python functions covered by unit tests. The agent receives the completed decision and writes the message. It cannot approve or deny a request.

Why: An auditor needs a versioned, tested function rather than an interpretation of model behavior.

02

Guardrails as a mandatory envelope

Every agent runs inside a wrapper with flow checks for allowed transitions, input checks for scope, size, injection and sensitive data, and output checks for technical leakage, third-party PII and format. Every node is covered.

Why: Controls belong in the execution path, rather than relying on convention.

03

Prompts are versioned artifacts

Prompts live in versioned YAML with explicit version numbers. Behavior changes require a new version, evaluation and promotion. Rollback points to the previous version without deploying code.

Why: Behavior rollback in minutes, with a record of who changed what and when.

04

Evaluation with a regression gate

Each agent has an evaluation set built from real domain cases. Changes to a prompt, model or rule trigger the suite. A decline beyond the agreed threshold blocks promotion.

Why: Regression testing for nondeterministic behavior.

05

Three-layer observability

Always-on structured JSON logs; an in-memory buffer for the operations dashboard; optional external tracing. Higher layers degrade gracefully so a tracing outage does not bring down the system.

Why: Diagnose production incidents without depending on an external provider being available.

06

Persisted session state

Each conversation turn is persisted with complete state. Sessions survive restarts and process failures and can be reconstructed step by step months later.

Why: A reconstructable audit trail replaces guesswork.

07

A replaceable model layer

The LLM provider sits behind a cached factory configured through environment variables. Switching providers or moving to an open model on your infrastructure leaves business logic unchanged.

Why: Models and pricing change frequently. Architecture should accommodate those changes.

08

Recorded architecture decisions

Each significant structural choice becomes a short ADR in the repository: context, alternatives, decision and consequences. We deliver the history with the code.

Why: Future teams can understand the reasoning without reconstructing it from scattered clues.

09

Fallbacks for external dependencies

Model providers, state storage and tracing have planned, tested degraded paths. The goal is to preserve availability while reducing functionality.

Why: Availability failures can also require incident reporting in regulated environments.

Stack

Tools are choices, not commitments for life.

The architecture allows components to be replaced without rewriting the system. These are our defaults, adapted to what your team already runs and can maintain.

Orchestration
LangGraphPython 3.12+FastAPIPydantic
Models
ClaudeGPTGeminiOpen models (vLLM, Ollama)
Data and state
PostgreSQLRedispgvectorSQLite
Operations
DockerGitHub ActionsOpenTelemetrypytest
Cloud
AWSGoogle CloudAzureSelf-hosted infrastructure

Want to review the architecture in depth?

Arrange a technical conversation with your architecture and security team. We walk through the structure, guardrails and evaluation strategy.