Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/yohangr3/agentelanggrafh/llms.txt

Use this file to discover all available pages before exploring further.

Every setting the ERP Financial Agent reads at startup is declared in src/core/config.py as a Pydantic Settings field. Values are loaded from a .env file first, then from real environment variables — with real environment variables taking precedence. Required fields (marked with ... in the source) have no default and will cause the app to refuse to start if they are absent.
Never commit a populated .env file to version control. Copy .env.example to .env, fill in your values, and add .env to .gitignore.

Required variables

These fields have no default value. The application will not start without them.
DB_HOST
string
required
Hostname of the MySQL database server. For AWS RDS use the full endpoint, e.g. iafinagent.choi0eaq2mr7.us-east-1.rds.amazonaws.com.
DB_NAME
string
required
Target database (schema) name. The default database used in the CloudFormation stack is iafinagent.
DB_USER
string
required
Database login username. The CloudFormation stack defaults to admin.
DB_PASSWORD
string
required
Database password. In production this value is injected from AWS Secrets Manager at container startup; set DB_PASSWORD_SECRET_ARN instead and leave this blank in the ECS environment.
COGNITO_USER_POOL_ID
string
required
AWS Cognito User Pool ID that issues JWT tokens. Format: us-east-1_XXXXXXXXX. The CognitoJWTValidator derives the JWKS endpoint URL from this value.

AWS / LLM

AWS_REGION
string
default:"us-east-1"
AWS region where Bedrock, Cognito, DynamoDB, and Secrets Manager resources live. Cross-region inference profiles (us.anthropic.*) require this to be us-east-1.
AWS_ACCOUNT_ID
string
Optional. Your 12-digit AWS account ID. Required by some IAM resource ARN constructions and tenant-panel features. When running on ECS the value is available from instance metadata.
BEDROCK_MODEL_ID
string
default:"us.anthropic.claude-sonnet-4-5-20250929-v1:0"
Bedrock cross-region inference profile used for general LLM calls (intent classification, SQL generation, explanations). Must be a valid inference profile ID, not a base model ID.
BEDROCK_REASONING_MODEL_ID
string
default:"us.anthropic.claude-sonnet-5"
Bedrock inference profile for reasoning-intensive graph nodes. Billed at a higher token rate than the general model; see COST_PER_1K_INPUT_TOKENS_REASONING.
BEDROCK_EMBEDDING_MODEL_ID
string
default:"amazon.titan-embed-text-v2:0"
Bedrock model for generating text embeddings (FAISS schema registry, semantic search). Produces 1024-dimensional vectors by default (EMBEDDING_DIMENSIONS).
DB_PASSWORD_SECRET_ARN
string
Optional. Full ARN of the Secrets Manager secret that stores the database password, e.g. arn:aws:secretsmanager:us-east-1:123456789012:secret:erp-agent/db-password. When set, resolve_secrets() fetches the real password at startup and injects it into DB_PASSWORD. Leave unset for local development.

Database connection

DB_PORT
integer
default:"3306"
MySQL port. Change only if your RDS instance is on a non-standard port.
DB_CONNECT_TIMEOUT
integer
default:"10"
TCP handshake and authentication timeout in seconds. Passed as connect_timeout in connect_args to aiomysql.
DB_READ_TIMEOUT
integer
default:"30"
Per-read timeout in seconds. Controls how long the driver waits for data from the server on a single network read.
DB_WRITE_TIMEOUT
integer
default:"30"
Per-write timeout in seconds. Applies to write operations (relevant if the application is extended beyond read-only access in future).

Session / Cache

REDIS_URL
string
default:"redis://localhost:6379/0"
Full Redis connection URL. In the ECS deployment this is derived from the ElastiCache cluster endpoint: redis://<cluster-endpoint>:6379/0.
REDIS_TTL_MINUTES
integer
default:"30"
Default TTL applied to all Redis keys (session checkpoints, rate-limit counters). Expired keys are evicted automatically by Redis.
SESSION_TTL_MINUTES
integer
default:"30"
How long an idle conversation session is kept alive, counted from the last message in the session.
SESSION_MAX_MESSAGES
integer
default:"100"
Hard ceiling on the number of messages stored per session. Older messages are dropped when the limit is reached.

Agent behaviour

MAX_HISTORY_MESSAGES
integer
default:"5"
Number of prior conversation turns injected into each LLM prompt as context. Increasing this value improves multi-turn coherence but raises token cost per request.
INTENT_CLASSIFICATION_TEMPERATURE
float
default:"0.0"
Sampling temperature for the intent classification node. 0.0 produces deterministic output.
SQL_GENERATION_TEMPERATURE
float
default:"0.0"
Sampling temperature for SQL generation. 0.0 produces deterministic queries.
EXPLANATION_TEMPERATURE
float
default:"0.3"
Sampling temperature for the explanation generation node.
SQL_CORRECTION_TEMPERATURE
float
default:"0.0"
Sampling temperature for the SQL self-correction node.
ANALYSIS_TEMPERATURE
float
default:"0.4"
Sampling temperature for the report/analysis generation node.
UNDERSTAND_TEMPERATURE
float
default:"0.0"
Sampling temperature for the understand/slot-extraction node.
MAX_CORRECTION_ATTEMPTS
integer
default:"3"
Maximum self-correction retries when the SQL validator rejects a generated query. After this many attempts the agent returns an error to the user.
MAX_CLARIFICATION_ROUNDS
integer
default:"2"
Maximum clarification rounds before the agent applies smart defaults and proceeds without user input.
SQL_VALIDATION_ENABLED
boolean
default:"true"
Enables sqlglot-based validation of every generated SQL statement before execution. Disable only in development when iterating on prompt templates.
INPUT_SANITIZATION_ENABLED
boolean
default:"true"
Enables input sanitization on all user-provided strings before they are passed to LLM nodes or SQL generation.
AUDIT_LOGGING_ENABLED
boolean
default:"true"
Enables audit trail logging. Every query execution is recorded with user, session, generated SQL, and row count.
HITL_ENABLED
boolean
default:"true"
Enables Human-in-the-Loop confirmation before executing expensive queries. When true, queries whose estimated cost exceeds the threshold are paused and sent to the frontend for user approval.
MAX_QUERY_ROWS
integer
default:"10000"
Maximum number of rows the database layer will return from any single SELECT. Results are truncated at this limit to protect memory.
QUERY_TIMEOUT_SECONDS
integer
default:"30"
Wall-clock timeout for SQL execution. Queries that exceed this limit are cancelled and the agent reports a timeout error.
LLM_TIMEOUT_SECONDS
integer
default:"120"
Timeout for individual LLM API calls to Bedrock in seconds.

Schema registry

EMBEDDING_DIMENSIONS
integer
default:"1024"
Embedding vector dimensions produced by BEDROCK_EMBEDDING_MODEL_ID. Amazon Titan Embed Text v2 defaults to 1024 dimensions.
SCHEMA_REGISTRY_PATH
string
default:".claude/skills/erp-financial/references"
Path to reference files (sap-schema.md, query-patterns.md) used by the schema registry.
FAISS_INDEX_DIR
string
default:"data/faiss_index"
Directory where FAISS indexes are persisted on disk. On ECS this maps to an EFS mount so the index survives task restarts.
SCHEMA_TOP_K
integer
default:"5"
Number of schema chunks returned by the schema-registry nearest-neighbour search for each query.
PATTERNS_TOP_K
integer
default:"3"
Number of few-shot query patterns returned by the schema registry for each query.
USE_GENERATED_SCHEMA_CATALOG
boolean
default:"true"
When true, the schema_linker node prefers the generated YAML-based schema catalog (yaml_schemas/*.yml) over the legacy domain_catalog.py / enricher.py for covered tables. Setting this to false is an instant rollback if a covered table misbehaves.

Analysis and export

MAX_EXPORT_ROWS
integer
default:"5000"
Maximum number of rows included in CSV or Excel exports.
CHART_AUTO_DETECT
boolean
default:"true"
When true, the visualization node automatically selects the most appropriate chart type based on data shape.

RBAC

RBAC_ENFORCE
boolean
default:"false"
Controls whether RBAC policy violations actually block requests. When false (shadow mode) violations are logged as warnings but the request proceeds. Set to true in production only after verifying no false positives in the audit log.
RBAC_SHADOW_LOG
boolean
default:"true"
When true, every shadow-denial (a violation that is not blocking because RBAC_ENFORCE=false) is logged as a warning. Disable once enforcement is live to reduce log noise.
EXPECTED_TENANT
string
default:"*"
Tenant slug this instance serves. * allows any tenant (backwards-compatible default). Set to a specific slug (e.g. agripac) to restrict access to Cognito users whose custom:tenantId claim matches.

Multi-tenant panel

TENANTS_REGISTRY_TABLE
string
default:"erp-agent-tenants"
DynamoDB table name for the tenant registry used by the instance panel feature.
GITHUB_REPO
string
default:"diegocasasbuenas/gt_langgraph_dev"
owner/repo whose provision-tenant.yml workflow is dispatched by the tenant panel to provision new tenant instances.
GITHUB_TOKEN_SECRET_NAME
string
default:"erp-agent/github-workflow-token"
AWS Secrets Manager secret name for the GitHub Personal Access Token (with Actions:write scope) used to dispatch the provisioning workflow.

Cognito and rate limiting

COGNITO_CLIENT_ID
string
Optional. AWS Cognito App Client ID. When set, the JWT validator also verifies the aud claim in the ID token against this value.
RATE_LIMIT_ENABLED
boolean
default:"true"
Enables per-user rate limiting. When false, all rate-limit checks are skipped.
RATE_LIMIT_PER_MINUTE
integer
default:"20"
Maximum requests per minute allowed per authenticated user. Requests beyond this limit receive HTTP 429.
RATE_LIMIT_PER_HOUR
integer
default:"200"
Maximum requests per hour per authenticated user. Enforced independently of the per-minute limit.

DynamoDB memory

DYNAMODB_ENABLED
boolean
default:"true"
Enables long-term conversation memory in DynamoDB. When true, the agent writes conversation turns to the erp-agent-conversations table so context persists across browser sessions.
DYNAMODB_TTL_DAYS
integer
default:"90"
Number of days before DynamoDB automatically expires conversation records. The TTL attribute on each item is set to now + DYNAMODB_TTL_DAYS.

File upload and code execution

MAX_UPLOAD_SIZE_MB
integer
default:"10"
Maximum file size (in megabytes) accepted by the upload endpoint. Requests that exceed this limit are rejected with HTTP 413.
MAX_UPLOAD_ROWS
integer
default:"50000"
Maximum number of rows accepted in a CSV or Excel upload. Files with more rows are rejected before parsing begins.
FILE_DATA_TTL_MINUTES
integer
default:"120"
TTL in minutes for uploaded file data stored in Redis. After expiry the data is evicted and the user must re-upload.
CODE_EXEC_TIMEOUT_SECS
integer
default:"30"
Timeout in seconds for the code-execution subprocess spawned by the agent.
CODE_EXEC_MEMORY_MB
integer
default:"512"
Memory limit in megabytes for the code-execution subprocess.
CODE_EXEC_MAX_ITERATIONS
integer
default:"3"
Maximum number of code refinement iterations the agent attempts before returning an error.

Retry and circuit breaker

MAX_RETRIES_LLM
integer
default:"3"
Maximum retry attempts for LLM API calls to Bedrock.
MAX_RETRIES_DB
integer
default:"2"
Maximum retry attempts for database operations.
RETRY_BACKOFF_MULTIPLIER
integer
default:"1"
Exponential back-off multiplier applied between retries.
RETRY_BACKOFF_MIN
integer
default:"2"
Minimum wait in seconds before the first retry.
RETRY_BACKOFF_MAX
integer
default:"10"
Maximum wait cap in seconds between retries.
CIRCUIT_BREAKER_FAILURE_THRESHOLD
integer
default:"5"
Number of consecutive failures required to trip the circuit breaker (open state).
CIRCUIT_BREAKER_RECOVERY_TIMEOUT
integer
default:"60"
Seconds after which the circuit breaker transitions from open to half-open and allows a single probe request.

Observability

LANGSMITH_API_KEY
string
Optional. LangSmith API key for LLM call tracing. Tracing is disabled when this variable is absent.
LANGSMITH_PROJECT
string
default:"erp-financial-agent"
LangSmith project name that traces are grouped under.
LANGCHAIN_TRACING_V2
boolean
default:"false"
Enables LangChain’s V2 tracing protocol. Set to true together with LANGSMITH_API_KEY to stream traces to LangSmith.
METRICS_ENABLED
boolean
default:"true"
Enables Prometheus metrics collection. Metrics are exposed on the /metrics endpoint.
METRICS_PREFIX
string
default:"erp_agent"
Prefix applied to all Prometheus metric names.
COST_TRACKING_ENABLED
boolean
default:"true"
Enables per-request token cost tracking. Cost is computed using the COST_PER_1K_*_TOKENS settings and logged alongside every LLM invocation.
COST_PER_1K_INPUT_TOKENS
float
default:"0.003"
USD cost per 1,000 input tokens for the general model (BEDROCK_MODEL_ID, Claude Sonnet 4.5).
COST_PER_1K_OUTPUT_TOKENS
float
default:"0.015"
USD cost per 1,000 output tokens for the general model (BEDROCK_MODEL_ID, Claude Sonnet 4.5).
COST_PER_1K_INPUT_TOKENS_REASONING
float
default:"0.005"
USD cost per 1,000 input tokens for the reasoning model (BEDROCK_REASONING_MODEL_ID).
COST_PER_1K_OUTPUT_TOKENS_REASONING
float
default:"0.025"
USD cost per 1,000 output tokens for the reasoning model (BEDROCK_REASONING_MODEL_ID).
ALERT_LATENCY_THRESHOLD_SECONDS
float
default:"15.0"
Alert is emitted when any request exceeds this latency threshold in seconds.
ALERT_ERROR_RATE_THRESHOLD
float
default:"0.10"
Alert is emitted when the rolling error rate exceeds this fraction (e.g. 0.10 = 10%).
PROMPT_VERSION
string
default:"v1"
Prompt version tag used for A/B testing and evaluation tracking.
EVAL_PARALLEL_WORKERS
integer
default:"5"
Number of parallel workers used by the offline evaluation pipeline.

API

API_CORS_ORIGINS
JSON array
default:"[\"http://localhost:5173\"]"
JSON-encoded list of origins that the FastAPI CORS middleware will allow. Must be a valid JSON array string in .env. Example for local dev with both Vite ports: ["http://localhost:5173","http://localhost:5174"].
API_TIMEOUT
integer
default:"120"
Global API request timeout in seconds.
ENVIRONMENT
string
default:"development"
Runtime environment label. Accepted values include development, staging, and production. Used in log output and CloudWatch tagging.
LOG_LEVEL
string
default:"INFO"
Python logging level. Set to DEBUG to enable SQLAlchemy query echo and verbose agent tracing. Accepted values: DEBUG, INFO, WARNING, ERROR, CRITICAL.

Full .env example

The snippet below covers every configurable variable. Copy it, fill in the required fields, and remove the optional sections you don’t need.
.env
# ── AWS Bedrock ────────────────────────────────────────────────────────────────
BEDROCK_MODEL_ID=us.anthropic.claude-sonnet-4-5-20250929-v1:0
BEDROCK_REASONING_MODEL_ID=us.anthropic.claude-sonnet-5
BEDROCK_EMBEDDING_MODEL_ID=amazon.titan-embed-text-v2:0

# ── Database (MySQL RDS) — required ───────────────────────────────────────────
DB_HOST=your-rds-host.region.rds.amazonaws.com
DB_PORT=3306
DB_NAME=iafinagent
DB_USER=admin
DB_PASSWORD=your-db-password
DB_CONNECT_TIMEOUT=10
DB_READ_TIMEOUT=30
DB_WRITE_TIMEOUT=30

# ── AWS ────────────────────────────────────────────────────────────────────────
AWS_REGION=us-east-1
AWS_ACCOUNT_ID=123456789012

# ── Cognito — required ────────────────────────────────────────────────────────
COGNITO_USER_POOL_ID=us-east-1_XXXXXXXXX
# COGNITO_CLIENT_ID=your-app-client-id

# ── Secrets Manager (optional, production only) ────────────────────────────────
# DB_PASSWORD_SECRET_ARN=arn:aws:secretsmanager:us-east-1:123456789012:secret:erp-agent/db-password

# ── Redis ──────────────────────────────────────────────────────────────────────
REDIS_URL=redis://localhost:6379/0
REDIS_TTL_MINUTES=30
SESSION_TTL_MINUTES=30
SESSION_MAX_MESSAGES=100

# ── Agent behaviour ────────────────────────────────────────────────────────────
MAX_HISTORY_MESSAGES=5
INTENT_CLASSIFICATION_TEMPERATURE=0.0
SQL_GENERATION_TEMPERATURE=0.0
EXPLANATION_TEMPERATURE=0.3
SQL_CORRECTION_TEMPERATURE=0.0
ANALYSIS_TEMPERATURE=0.4
UNDERSTAND_TEMPERATURE=0.0
MAX_CORRECTION_ATTEMPTS=3
MAX_CLARIFICATION_ROUNDS=2
SQL_VALIDATION_ENABLED=true
INPUT_SANITIZATION_ENABLED=true
AUDIT_LOGGING_ENABLED=true
HITL_ENABLED=true
MAX_QUERY_ROWS=10000
QUERY_TIMEOUT_SECONDS=30
LLM_TIMEOUT_SECONDS=120

# ── Schema registry ────────────────────────────────────────────────────────────
EMBEDDING_DIMENSIONS=1024
SCHEMA_REGISTRY_PATH=.claude/skills/erp-financial/references
FAISS_INDEX_DIR=data/faiss_index
SCHEMA_TOP_K=5
PATTERNS_TOP_K=3
USE_GENERATED_SCHEMA_CATALOG=true

# ── Analysis and export ────────────────────────────────────────────────────────
MAX_EXPORT_ROWS=5000
CHART_AUTO_DETECT=true

# ── RBAC ───────────────────────────────────────────────────────────────────────
RBAC_ENFORCE=false
RBAC_SHADOW_LOG=true
EXPECTED_TENANT=*

# ── Multi-tenant panel ─────────────────────────────────────────────────────────
TENANTS_REGISTRY_TABLE=erp-agent-tenants
# GITHUB_REPO=diegocasasbuenas/gt_langgraph_dev
# GITHUB_TOKEN_SECRET_NAME=erp-agent/github-workflow-token

# ── Cognito rate limiting ──────────────────────────────────────────────────────
RATE_LIMIT_ENABLED=true
RATE_LIMIT_PER_MINUTE=20
RATE_LIMIT_PER_HOUR=200

# ── DynamoDB memory ────────────────────────────────────────────────────────────
DYNAMODB_ENABLED=true
DYNAMODB_TTL_DAYS=90

# ── File upload and code execution ─────────────────────────────────────────────
MAX_UPLOAD_SIZE_MB=10
MAX_UPLOAD_ROWS=50000
FILE_DATA_TTL_MINUTES=120
CODE_EXEC_TIMEOUT_SECS=30
CODE_EXEC_MEMORY_MB=512
CODE_EXEC_MAX_ITERATIONS=3

# ── Retry and circuit breaker ──────────────────────────────────────────────────
MAX_RETRIES_LLM=3
MAX_RETRIES_DB=2
RETRY_BACKOFF_MULTIPLIER=1
RETRY_BACKOFF_MIN=2
RETRY_BACKOFF_MAX=10
CIRCUIT_BREAKER_FAILURE_THRESHOLD=5
CIRCUIT_BREAKER_RECOVERY_TIMEOUT=60

# ── Observability ──────────────────────────────────────────────────────────────
# LANGSMITH_API_KEY=your-langsmith-api-key
# LANGSMITH_PROJECT=erp-financial-agent
# LANGCHAIN_TRACING_V2=true
METRICS_ENABLED=true
METRICS_PREFIX=erp_agent
COST_TRACKING_ENABLED=true
COST_PER_1K_INPUT_TOKENS=0.003
COST_PER_1K_OUTPUT_TOKENS=0.015
COST_PER_1K_INPUT_TOKENS_REASONING=0.005
COST_PER_1K_OUTPUT_TOKENS_REASONING=0.025
ALERT_LATENCY_THRESHOLD_SECONDS=15.0
ALERT_ERROR_RATE_THRESHOLD=0.10
PROMPT_VERSION=v1
EVAL_PARALLEL_WORKERS=5

# ── API ────────────────────────────────────────────────────────────────────────
API_CORS_ORIGINS=["http://localhost:5173"]
API_TIMEOUT=120
ENVIRONMENT=development
LOG_LEVEL=INFO
In production the ECS task definition injects DB_PASSWORD directly from Secrets Manager via the secrets block in the CloudFormation template — you do not need to set it as a plain-text environment variable.

Build docs developers (and LLMs) love