Architecture
AI Copilot
How the tenant-safe assistant uses agentic retrieval, tenant-scoped context, and swappable LLM backends.
What it is
EasyFlow's copilot is a tenant-scoped retrieval assistant for supply chain operations. It is designed to answer questions about shipments, inventory, approvals, suppliers, and workflow exceptions using only the current tenant's operational context.
Agentic architecture
Agentic AI in EasyFlow means the assistant does more than autocomplete a generic answer. It gathers tenant context, inspects operational records, and produces an answer grounded in current business data.
| Mode | How it works | Best fit |
|---|---|---|
| Local agentic mode | LangChain agent + tenant MCP tools + Ollama model | Self-hosted demos, on-prem deployments, strict data residency |
| Hosted grounded mode | OpenAI or Gemini provider + tenant-scoped document context | Teams that want managed models without rewriting the app |
| Heuristic fallback | Deterministic local logic over the same tenant dataset | Safe demo fallback when no model backend is available |
Tenant-safe retrieval
- The assistant receives the current tenant slug from the workspace route or request payload.
- Tenant data is loaded only for that tenant workspace.
- Operational records are transformed into tenant-scoped knowledge documents.
- A tenant-scoped MCP server is created in-process for that request only.
- LangChain loads only that MCP server's tools, so the model can query only the current tenant context.
- If a signed-in user is tenant-scoped in the registry, the route refuses cross-tenant access.
Current data sources
Until live ERP-side data is fully wired everywhere, the copilot uses the same tenant-specific operational structures already powering the app UI.
| Source | Used for |
|---|---|
| Inventory data | Low-stock, reorder, SKU, and restock questions |
| Procurement data | Purchase order status and approval questions |
| Logistics data | Shipment delay, ETA, and carrier questions |
| Supplier data | Lead-time, fill-rate, and supplier risk questions |
| Automation / integration data | Workflow trigger and integration status questions |
| Tenant KPIs | Overview, exception, and operational health questions |
LLM backends
EasyFlow now supports multiple backend styles through the same provider interface. The local Ollama path is the most agentic because it can reason through tenant MCP tools directly. Hosted OpenAI and Gemini paths use the same tenant-scoped knowledge documents and return the same structured assistant payload.
User question
↓
Tenant-aware API route
↓
Tenant-scoped knowledge documents
↓
Provider registry
↓
Ollama: LangChain + MCP tools
OpenAI / Gemini: grounded context prompt
↓
Grounded answer + citationsThe default local path uses ChatOllama through LangChain. The hosted-provider path is designed so teams can point EasyFlow at OpenAI or Gemini later without changing the API contract or UI.
# Example local setup
ollama serve
ollama pull llama3.1:8bEnvironment variables
AI_PROVIDER=heuristic
LOCAL_LLM_ENABLED=false
LOCAL_LLM_BASE_URL=http://127.0.0.1:11434
LOCAL_LLM_MODEL=llama3.1:8b
LOCAL_EMBEDDING_MODEL=nomic-embed-text
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4.1-mini
OPENAI_BASE_URL=https://api.openai.com/v1/responses
GEMINI_API_KEY=
GEMINI_MODEL=gemini-2.5-flashSet AI_PROVIDER to ollama, openai, gemini, or heuristic. If no provider is configured, EasyFlow falls back to deterministic tenant-grounded logic instead of failing closed.
Current limitations
- The current retrieval layer is lexical and tenant-scoped, not vector-search based yet.
- The MCP tool layer currently exposes local tenant knowledge documents rather than live ERP-backed indexed stores everywhere.
- The hosted-provider paths are grounded in tenant documents today, but the deeper agentic tool loop currently exists only in the local Ollama + MCP mode.
- Production-quality prompt and model tuning still depend on the deployment environment you choose.