AI Architecture: Gateway, Guardrails, and Agentic Tools
AI is the fourth pillar of the openEduSuite digital workplace, built to the same standards as identity, storage, and communication. Four decisions define the layer: inference happens locally so prompts never leave the institution, model access flows through one central gateway so it stays controlled and measurable, the chat tier ships with guardrails so it is safe by default, and an MCP-based tool bus lets assistants act on real services instead of only answering. This reference walks through the fabric from the model runtime to the tool surface.
Local inference as the foundation
Every model that serves users runs inside the platform. The inference runtime (Ollama) is self-hosted and serves open-weight models from the Qwen3 family, alongside a dedicated embeddings model for retrieval. For institutions bound by data-protection law and organizational confidentiality, local inference is the precondition for offering AI at all: prompts and responses are processed on infrastructure the institution controls, and none of it is forwarded to an external provider.
The price of this foundation is capacity planning. A self-hosted stack does not scale by adding a cloud contract, so model capacity must be sized and monitored like any other critical resource.
Small models carry a large share of the load. The guardrail tier described below runs a compact, CPU-friendly classifier beside the main runtime: safety checks stay cheap enough to run on every request, while accelerator capacity stays reserved for generation.
The model gateway: one endpoint, central control
Early in the integration, each AI-capable service connected to the inference runtime directly and configured its own provider, endpoint, and model choice. That worked, but it was opaque: no central usage accounting, no per-service keys, no uniform way to change the backend model, and no OpenAI-compatible surface for services that speak only that protocol.
The architecture replaced those direct connections with a central model gateway (LiteLLM), deployed in its own namespace like any other component. The gateway exposes a single OpenAI-compatible API endpoint, and every AI-capable consumer, the chat frontend, the app builder (Dify), the automation tier (n8n), and office and collaboration services with native AI features, calls exactly this endpoint. The inference runtime sits behind the gateway and is no longer reachable by consumers directly.
Chat frontend App builder Automation File, calendar &
(guardrail filter) (Dify) (n8n) office services
βββββββββββ¬ββββββββββββ΄ββββββ¬ββββββββββββββββ β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Model gateway (LiteLLM), one OpenAI-compatible /v1 endpoint β
β model aliases Β· per-service virtual keys Β· usage metrics β
ββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
βΌ egress restricted
βββββββββββββββββββββββββββββββββ
β Local model runtime (Ollama) β
β flagship Β· sibling Β· β
β embeddings Β· guard model β
βββββββββββββββββββββββββββββββββ
Model aliases
The gateway maintains a small catalog of aliases. Clients never request a concrete model artifact; they request a logical name, the flagship chat and agentic model, a smaller and faster sibling for high-volume and summarization work, or the embeddings model, and the gateway resolves it to the currently configured backend. Swapping a model becomes a one-line gateway configuration change: no consumer restarted, no provider reconfigured.
Per-service keys and accountability
Each consumer receives its own virtual key, provisioned through the same encrypted-secret mechanics the suite uses everywhere: no key material in Git. Keys turn model usage into an accountable, budgeted quantity per service and feed usage metrics into the platform monitoring. When a report asks which service caused a cost spike, the answer is a query, not an investigation.
Network isolation
The gateway is locked down like the rest of the platform. Ingress to its port is allowed only from consumer namespaces; its own egress is restricted to the inference runtime. There is no general cluster egress: local-only inference is enforced at the network layer, not by convention.
Guardrails: moderation, injection, and data minimization
A chat interface that can both answer and act needs a safety tier between user and model. The suite embeds a guardrail filter function into the chat frontend that runs on every request before the prompt reaches the model and again on every response before it reaches the user. The filter is a normal component of the deployment: installed, activated, and verified through the same scripts as everything else, and covered by contract tests and a behavioral matrix.
The guardrail stack combines a local classification model with deterministic heuristics, because neither is sufficient alone.
Content moderation
A compact classification model (Qwen3Guard) judges each turn against safety categories. Unsafe content is blocked; merely controversial content is logged but allowed, so the system observes without over-blocking. Because the classifier is a small local model, warm calls complete in under a second even on CPU; the first call after model load is slower while the model warms up.
Jailbreak and prompt-injection defense
Classic jailbreaks and prompt-injection attempts form a separate category, and one verified finding shaped the design: many jailbreaks are classified as controversial rather than unsafe. Relying on the moderation category alone would therefore let a crafted prompt through. The filter treats the jailbreak category as a hard block, independent of the moderation result, and a behavioral matrix exercises real attack patterns against the live model on every release.
Personal-data redaction
Classification models do not detect personal data reliably, since an email address or a phone number reads as benign. The filter therefore pairs Qwen3Guard with a deterministic redaction heuristic that scans user messages for email addresses, phone numbers, IBANs, and student registration numbers, replacing them with opaque placeholders before the prompt is sent to the model. Two details matter. First, the whole message history is scanned, not just the latest turn, because every turn is re-sent to the model on each request. Second, the heuristic errs on the side of redaction: better to remove something that could have stayed than to leak something that should have been removed.
Agentic tools: an MCP bus for acting on the suite
The chat frontend ships native support for the Model Context Protocol (MCP), the open standard that lets an assistant expose and call external tools. The suite uses this as a genuine tool bus: dedicated tool servers publish the operations of the platform's own services, files and folders on the file service, calendar, tasks, and contacts on the groupware, and rooms on the messenger, as a catalog of structured tools the assistant can invoke on a user's behalf.
That turns the chat from a question-and-answer interface into a place where work happens. A user can ask, in natural language, for a course room to be created with the participants invited, a prepared folder dropped into it, or a meeting scheduled; the assistant executes the corresponding tool calls against the real services under the user's own identity. Evidence is first-class: assistant actions in the messenger are visible in the room, so a human reviewer can always see what was done and where.
Human-in-the-loop for destructive operations
Not every tool call should succeed silently. Tools whose underlying action is destructive (deleting a file, removing a resource) declare a destructive flag in their schema, and their contract requires an explicit confirmation argument. Without that token in the request, the call fails at the schema level before it ever reaches the service. Human-in-the-loop is enforced by the tool itself, not bolted on afterwards.
Multi-agent coordination and audit
The messenger doubles as the coordination surface between agents. Rooms host several participants (assistants and humans), and every agent action plus human approval is recorded in the room's event history, which is the audit trail. Agents that act autonomously do so through the MCP tool servers under their own service identity, and every action stays visible to the room's participants.
Governance: contracts, budgets, and evidence
The AI fabric inherits the suite's verification culture:
- Contract tests run against every layer: gateway, guardrails, tool servers. Drift guards fail the pipeline when a live system no longer satisfies its contract.
- A behavioral matrix runs the guardrail filter against a catalog of attack and edge-case prompts against the real model, clean before every release.
- Agentic behavior is verified through integration tests at the API level and end-to-end browser journeys, each mapped to a user story.
Automation and agents act under service identities, non-interactive accounts with per-service, least-privilege scopes, so a machine in the suite is as auditable and bounded as a human session. Coding agents that work in repositories on behalf of the community get their own gateway key with a budget, their images are pinned by digest, and their prompts pass through the same guardrail scrutiny as human ones. No human in the loop does not mean no safety tier in the loop.
What is deliberately not in the architecture
Some common patterns are intentionally absent. There is no cloud fallback: if a local model is unavailable, requests fail closed rather than leave the cluster, because exporting prompts would break the data-protection boundary. There is no training or per-user fine-tuning inside the platform: capacity is reserved for the shared flagship model. The gateway starts as a single instance with lightweight embedded storage; when real load demands it, that is a scaling decision, not a redesign. And there is no separate account world for AI: assistants, agents, and automation use the same identity platform, the same secrets mechanism, and the same network policies as every other service.
Conclusion
The AI layer is a fabric, not a feature list: local inference that keeps data in-house, a central gateway that makes model access traceable and budgeted, a guardrail tier that pairs a local classifier with deterministic redaction, and an MCP tool bus that lets assistants act on the platform's own services under audit. Each piece follows the rule that governs the whole suite: sovereignty through architecture, not through contracts with an external provider.
Two areas sit on the roadmap: the developer-facing agent surface (a coding assistant that works in repositories on behalf of the community while still talking only through the gateway) and broader agentic journeys across file, calendar, and messaging services.
Further Reading
- AI Integration: how the AI services are wired into the platform (SSO, the n8n bridge, Dify, and Open WebUI)
- Agentic AI Meets Sovereign Cloud: agentic workflows on sovereign infrastructure
- Spec-Contract Test Pyramid: how contracts verify behavior across layers
- Security Architecture: network policies, secrets, and access control around the AI layer
- Networking & Traffic Flow Architecture: how traffic enters the cluster and is isolated
- System Architecture Overview: the platform as a whole
AI in openEduSuite is sovereign by architecture: local inference, one controlled gateway, guardrails at the edge, and tools that act only under audit.