← Projects · Agentic AI · GenAI

AI-Powered HSE Training Content Generation

Vertex AI Agent Engine · Gemini 2.5 Flash · Vertex AI Search · Firestore · 14 agents

A multi-agent platform that turns health, safety & environment source documents into reviewed microlearning content — grounded RAG with per-question source attribution, and a structural guarantee that nothing reaches workers without explicit human approval.

Problem

HSE experts at a global enterprise were hand-authoring large volumes of plain-English safety training questions for plant field workers — slow, inconsistent, and expensive. The goal: let experts upload source documents (PDF, DOCX, PPTX, XLSX, web URLs) and have an AI pipeline generate source-grounded training content — without ever letting unreviewed AI output reach the live question bank. There is no auto-publish code path in the system, by design.

My role

I architected and built the platform: the single Agent Engine ingress and dispatcher (55 methods), the 14-agent registry, the structured-output layer (a Pydantic→Vertex schema flattener with self-correcting retries), the quality-gated generation pipeline, a version-pointer undo/redo engine for every authored artifact, the dual-access design where the admin chat assistant and the REST API share one service layer, and the multi-format RAG ingestion pipeline.

Architecture

Admin (expert)REST API == chat assistant Vertex AI Agent Enginehub → dispatcher (55 methods) 14-agent registryorchestrator → 3 domain experts (health/safety/env)pedagogy-QA · 5-criterion rubric + hard-fail gatestone modifier · gap analysis · topic mappersyllabus/lesson/question editorseach: retrieve → generate → self-critique → attribute Gemini 2.5 Flashstructured output · temp ladder RAG ingestionmulti-format parse (vision fallback) → semantic chunking→ text-embedding-004 (768-dim) → SHA-256 dedup→ Vertex AI Search primary · Firestore-vector fallback Firestore (system of record) + GCStopics · lessons · questions · version snapshotsagent prompts · configs · ingestion jobsversion-pointer undo/redo on every artifact Human review gate — approve / reject / polish / chat-edit / split / undo / redoStructural guarantee: no generated question can reach the live bank without explicit human approval. No auto-publish path exists.

The generation loop. An orchestrator routes each request by topic domain and fans out to three domain-expert agents in parallel. Each expert runs a quality ladder: retrieve grounded context → generate (temp 0.7) → self-critique (temp 0.1) → regenerate once if needed (temp 0.4) → attribute sources per question (temp 0.1). A pedagogy-QA agent then scores every question on a five-criterion rubric with deterministic hard-fail gates and near-duplicate removal (cosine > 0.92).

“LLM writes prose, Python makes decisions.” IDs, statuses, scores, gap classifications, and pass/fail gates are all stamped deterministically in Python; the model writes content and explanations, never controls state. Combined with the mandatory human review gate, the pipeline can fail soft anywhere without ever publishing bad content.

Tech stack

Vertex AI Agent EngineGemini 2.5 Flashtext-embedding-004Vertex AI SearchFirestore (vector)Cloud StoragePydantic v2pymupdf · python-docx · pptx · openpyxl · crawl4aitenacitystructlogPython 3.11+

Key design decisions & trade-offs

  • Single ingress, dual access. The conversational assistant is a Gemini function-calling loop whose tools re-enter the exact same hub methods the REST API uses — chat and API literally cannot diverge. Trade-off: no independent scaling of the two paths.
  • Hand-rolled structured-output layer. Vertex rejects $ref/anyOf JSON schemas, so I built a Pydantic→Vertex schema flattener with a 3-attempt self-correcting retry and truncated-JSON salvage that recovers N−1 objects from an overrun response.
  • Temperature ladder by task. 0.7 where creativity helps (generation), 0.1 where determinism is graded (critique, attribution, QA) — one knob, mapped to intent.
  • Retrieval resilience. Vertex AI Search primary with a two-tier Firestore-native vector fallback — retrieval survives a Search outage.
  • Version-pointer undo/redo. Every artifact keeps dual-state numbered snapshots, so expert edits — including AI chat-edits — are fully reversible.
  • Soft-fail philosophy. Ingestion never raises; QA self-disables to passthrough rather than blocking — safe only because the human approval gate is structural, not procedural.

Scope & results

~22,700 lines across 98 modules · 14 agents · 55 dispatcher methods · ~109 tests · multi-format ingestion (PDF/DOCX/PPTX/XLSX/URL)

Shipped with an admin-facing review workflow (approve/reject/modify, tone adjustment, AI-generated explanations) and a gap-analysis module that classifies topic coverage as uncovered, thin, or stale. Client details are confidential; scope figures are verified from the codebase.