Skip to main content

Motivation

AskMyDocs ships with safe defaults: a fresh install behaves like a competent hybrid-RAG service out of the box. But every enterprise deployment eventually needs to tune something — the embedding provider, the reranker’s trust gradient, the refusal threshold, the retention windows. This page is the map of what is configurable, where the knob lives, and what it does. It is not an exhaustive env dump (see .env.example for that) — it argues the knobs that change behaviour you can observe.

Theory: configuration is layered, not flat

A knob is never read directly from the environment by a service. The flow is always env var → config/*.php cast + default → service constructor / config() call. This indirection matters:
  • config/*.php is the single source of truth for the default and the cast ((float), (bool), (int)). An unset env var is not “null” — it is the documented default.
  • Tests and config:cache read the compiled config, not $_ENV. Reading env() outside config/*.php is a bug (it returns null once config is cached).
After changing .env in production, run php artisan config:clear (or re-run config:cache). A cached config ignores live .env edits — this is the single most common “my setting did nothing” report.

The config files

Configuration is split by concern. The files you will touch most: Sister-package surfaces (connectors, mcp-pack, mcp, widget, laravel-flow, pii-redactor-admin, eval-harness, ai-act-compliance, evidence-risk-review, …) each ship their own config/*.php. See Sister packages.

Providers (config/ai.php)

Chat and embeddings are configured independently — Anthropic has no embeddings endpoint, so you mix providers freely.
Each provider has a <NAME>_API_KEY, <NAME>_CHAT_MODEL, <NAME>_TEMPERATURE, <NAME>_MAX_TOKENS, and <NAME>_TIMEOUT, but the rest of the surface is provider-specific — Anthropic adds ANTHROPIC_API_VERSION and has no *_BASE_URL or embeddings model; OpenAI / Gemini / OpenRouter add *_BASE_URL and *_EMBEDDINGS_MODEL; Regolo exposes a REGOLO_CHAT_MODEL* cheapest/smartest matrix plus REGOLO_EMBEDDINGS_DIMENSIONS. The full per-provider matrix — including the dimension-safety auto-select order when AI_PROVIDER=anthropic — is documented in AI providers.
KB_EMBEDDINGS_DIMENSIONS is part of the database contract. Changing the embeddings model to a different width (OpenAI 1536 → Gemini 768 → Regolo 4096) requires resizing the vector(N) columns and flushing the embedding cache and re-indexing. See Troubleshooting.

Retrieval & reranking (config/kb.php)

The reranker is the trust gradient — it fuses several signals into one score, then applies a canonical boost and a status penalty. Defaults (kb.reranking.* and kb.canonical.*): The deep treatment of the formula lives in the chat & retrieval and grounding & evidence tiers pages.

The refusal gate

The anti-hallucination firewall refuses to answer when retrieval is too weak — better a refusal than a fabrication. Three thresholds, all in config/kb.php:
See the anti-hallucination firewall page for why the refusal is modelled as a status, not an error.

Graph expansion & rejected-approach injection

Both features degrade to no-ops when a tenant has zero canonical docs — an existing consumer sees identical retrieval until it canonicalises.

Deletion, retention & multi-tenancy

KB_PROJECT_ISOLATION_ENABLED is default-off by design: the v8.9 isolation audit shipped it opt-in so existing deployments keep their behaviour. Cross-tenant isolation is always enforced (see multi-tenant isolation and security & threat model).

Worked example: switch chat to a local-EU Regolo model, keep OpenAI embeddings

Because the embeddings provider and dimension are unchanged, no migration and no re-index are needed — only the chat path moves to Regolo.

Gotchas & operations

  • config:cache in production, config:clear after edits. Cached config ignores live .env.
  • Never call env() outside config/*.php. It returns null under config:cache.
  • CSV env vars (SANCTUM_STATEFUL_DOMAINS, CORS_ALLOWED_ORIGINS, KB_GRAPH_EXPANSION_EDGE_TYPES) are trimmed + filtered on parse — leading whitespace is tolerated, but keep them comma-separated with no stray quotes.
  • Default-off flags ship off. When you enable a flag (project isolation, PII redaction, agentic tool-calling, the MCP HTTP server), verify the enabled and disabled paths — both must be healthy (see feature-flag discipline).

Self-hosting

Install, migrate, build the SPA, run the worker + scheduler.

Scheduler & maintenance

Every scheduled job, its cron, and its enable toggle.

AI providers

The full provider matrix and the dimension-safety auto-select.

Troubleshooting

Embedding-dimension gotcha, health checks, common failures.