🛠️ Lab 15 — Wrapping an Agent with NeMo Guardrails (50 pts)

Goal: Wrap a conversational agent with NVIDIA NeMo Guardrails, configure both input and output rails using Colang flows, and prove — with a small adversarial test suite — that each rail actually fires. Everything in this lab uses free, open-source tools and can run on a local or free-tier model. Steps:

  1. Install NeMo Guardrails locally (pip install nemoguardrails) and follow the official "getting started" tutorial to stand up a minimal guardrailed conversational agent, pointed at a local or free-tier LLM of your choice.
  2. Create a Colang input rail that rejects or rephrases off-topic input (e.g., the assistant is scoped to a specific topic, such as course-related Q&A, and should politely decline unrelated requests).
  3. Create a second Colang input rail that detects unsafe or prompt-injection input (for example, a message attempting to override the system prompt or extract hidden instructions) and blocks it before it reaches the underlying model.
  4. Create a Colang output rail that checks the model's generated response for policy-violating content and either blocks it outright or rewrites it into a safe alternative before it is returned to the user.
  5. Wire the rails into your config.yml / Colang flows so both input and output rails are active for every turn, and confirm the agent still answers legitimate, on-topic questions normally.
  6. Build a small adversarial test suite of at least 6 prompts covering three categories: off-topic requests, unsafe requests, and prompt-injection attempts (at least 2 per category).
  7. Run your test suite against the guardrailed agent and record, for each prompt, which rail fired (if any) and what the agent's final response was.
  8. Write a short reflection (150–250 words) on one case where a rail worked as expected and one case (a false positive, false negative, or edge case) where it didn't — and what you would change about your Colang flow to fix it.

Deliverables: Submit your NeMo Guardrails config files (config.yml and Colang .co flow files), your adversarial test suite with recorded rail-firing results, and your written reflection, either as an upload (zipped project folder) or pasted directly into the text entry box.