QRG Workflows
Overview
The K12 Safety platform provides two QRG (Quick Reference Guide) workflows:
- QRG Generation -- Creates a full set of role-specific guides from an Emergency Operation Plan.
- QRG Editing -- Modifies a single section of an existing QRG.
Both are async-only. You kick off a job, poll for status, then fetch the result.
QRG Generation
What Happens
When you submit an EOP ID for QRG generation, the system performs a multi-stage pipeline for each functional annex in the plan:
- Annex classification -- Each annex is categorized (functionality-based vs. emergency-type).
- Audience extraction -- Target audiences are identified from the annex content.
- Role mapping -- Audiences are mapped to K12 role IDs (teachers, administrators, support staff). When the EOP has more than 12 role tags, the system automatically batches the mapping step in parallel and merges the results.
- Content generation -- Structured action items are generated for each role, organized into BEFORE, DURING, and AFTER phases.
The result is a collection of role-specific QRGs, each containing phased content blocks.
Generation Flow
Tool Sequence
- Call
k12-qrg-generation-kickoffwith the EOP ID, user, role, and optional parameters (target roles, custom prompt). - Receive a
requestIdwith statusaccepted. - Poll
k12-qrg-generation-statuswith therequestId. - When status reaches
SUCCESS, callk12-qrg-generation-resultto retrieve the generated QRGs.
What Gets Created
Each generated QRG includes:
| Component | Description |
|---|---|
| Role | The K12 role this guide targets (e.g., teacher, administrator) |
| Annex | The source annex the guide was derived from |
| BEFORE | Preparation actions to take before an emergency |
| DURING | Actions to take while the emergency is active |
| AFTER | Recovery and follow-up actions after the emergency |
A single generation request can produce many QRGs -- one per role per annex.
Form Handling
The generation pipeline processes all annex forms from the EOP. Forms are handled based on their state:
- A form marked as in-progress with no content is flagged as an error (the user has not started filling it in).
- A form marked as completed with no content is treated as valid (the user accepted defaults).
- Any form with content is processed normally.
This gives you visibility into which annexes were processed, which were skipped, and which need attention.
QRG Editing
What Happens
QRG editing modifies a single section (BEFORE, DURING, or AFTER) of an existing Quick Reference Guide. You provide the current content, the section identifier, and a prompt describing the change. The system returns an updated version of that section.
Editing Flow
Tool Sequence
- Call
k12-qrg-editing-kickoffwith:userIdandroleId-- Who is making the editsection-- Which phase to edit:BEFORE,DURING, orAFTERcontent-- The current HTML content of that sectionprompt-- What to change (e.g., "Add a bullet about checking fire extinguisher locations")quickReferenceGuide-- Metadata object identifying the QRG (name, type, instructionFor)sessionId-- Optional correlation ID (passnullto start a new session)
- Receive a
requestIdwith statusaccepted. - Poll
k12-qrg-editing-statuswith therequestId. - When status reaches
success, callk12-qrg-editing-resultto retrieve the edited content.
What the Result Contains
| Field | Description |
|---|---|
requestId | Tracking ID for this edit job |
sessionId | Session this edit belongs to |
status | Terminal status (success or error) |
message | The edited section content (HTML) |
isEdit | Boolean confirming the content was modified |
Status Lifecycle
QRG Generation (UPPERCASE statuses)
| Status | Meaning |
|---|---|
accepted | Job received and queued |
PROCESSING | Pipeline is classifying annexes and generating content |
SUCCESS | All QRGs generated; results available |
ERROR | Generation failed; check the result for details |
CANCELLED | Job was cancelled before completion |
QRG Editing (lowercase statuses)
| Status | Meaning |
|---|---|
accepted | Job received and queued |
processing | AI agent is editing the section |
success | Edit complete; result available |
error | Edit failed; check the result message |
cancelled | Job was cancelled before completion |
QRG Generation uses UPPERCASE status values (SUCCESS, ERROR, PROCESSING, CANCELLED). QRG Editing uses lowercase (success, error, processing, cancelled). Your polling logic must account for this difference.
Cancellation
Both QRG workflows support cancellation via k12-qrg-cancel. Pass the requestId and the appropriate jobType (generation or editing) to cancel a pending or in-progress job. The system transitions the job to CANCELLED (generation) or cancelled (editing) and stops further processing on a best-effort basis.
A cancelled job will not produce a result.
EOP editing uses a separate cancellation tool (k12-cancel-task-request) instead of k12-qrg-cancel. See the EOP Workflow page for details.