Skip to content

About

Proactive field safety for frontline workers: guided JSA, hazard identification from a photo, automatic SWMS surfacing and a workflow that branches on what was found.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Frontline Safety Copilot

Proactive field safety, hazard identification from a photo

Maturity Tests Multimodal Copilot Studio Safety critical Sample code Licence

Guided capture, automatic surfacing of the safe work method statement that applies, and a workflow that branches on what was actually found.


The problem

Frontline safety tooling is retrospective. It records incidents well and prevents them poorly.

The pattern is the same across every frontline organisation:

Job safety analysis is a form completed after the fact. A worker with their hands full, standing in front of the job, has two minutes. A twelve-field form gets filled in at the end of the shift from memory - which makes it a compliance artefact, not a safety control.

The relevant procedure is in a document library nobody opens. The safe work method statement for working at height exists. It is thorough, it is correct, and it is thirty pages into a SharePoint site that a worker on a loading dock will not open on a phone. The knowledge is present and the access is not.

Reporting is a burden, so it doesn't happen. Near misses - the ones that predict the injury - go unreported, because reporting one costs more effort than the near miss cost.

Everything is retrospective. Incident data accumulates, gets reported on monthly, and describes what already happened to someone.

What the pattern addresses

Problem Approach In this repo
JSA completed after the job, from memory Two-minute conversational pre-start Agent behaviour (SKILL.md)
Worker can't describe a hazard quickly Photo-based hazard identification Vision prompts, not accuracy tested
SWMS in a library nobody opens Matched controls surfaced for the task Control-match prompt plus allow-list check in code
Whole procedure presented, so none read Only the controls relevant to this task Prompt rule
Every job gets the same checklist Workflow branches on what was found decideWorkflowBranch, deterministic and tested
Near misses go unreported Photo is a complete report; agent drafts the rest Agent behaviour
AI reading confused with reporter's account Kept in separate fields, permanently distinguishable Schema design
Hazard with no procedure quietly dropped Unmatched hazards escalated as findings Enforced in code, even if the model omits them
Model says "the area is safe" Never allowed through Prompt rule plus a scrub in code
Emergency described mid-conversation Stop and direct to emergency services Agent rule plus detectEmergency, which runs before any model call

What's in this repo

This is an agent design and prompt reference, not a deployable solution.

Included Not included
Three agent behaviours: JSA, event reporting, vehicle pre-start A packaged solution or deployed agent
Vision and control-matching prompts (prompts/hazardVision.js) Dataverse tables - schema is documented only
Deterministic safety guards (src/safetyGuards.js) A mobile app or PCF controls
30 unit tests, run in CI with no dependencies (npm test) A real procedure/SWMS library
Synthetic procedure library, hazard taxonomy and six end-to-end scenarios
Dataverse schema documentation and safety design principles

Why the guards exist. The prompts ask the model to follow the safety rules. The guards make sure the rules that matter most hold even when it does not: emergency language is caught before any model call, procedure ids the model invents are removed, hazards it forgets to match are escalated, "the area is safe" is scrubbed, and the workflow branch is decided by ordered rules rather than by the model. The tests prove that logic, not the model's accuracy.

Verification status: the vision-based hazard identification and SWMS matching have not been run against a model here. No accuracy testing against a hazard taxonomy or procedure library has been done.

This is safety tooling. Validate against your own obligations, taxonomy and procedures before relying on any of it. The failure mode of a wrong answer is not an inconvenience.


How it works

flowchart TD
    A["Worker about to start a job"] --> B["Describes the task,<br/>or photographs the area"]
    B --> C["<b>Hazard identification</b><br/><small>vision prompt, or description</small>"]
    C --> D["<b>Match to procedures</b><br/><small>by hazard type + task</small>"]
    D --> E{"Workflow branches on<br/>what was found"}

    E -->|Nothing found| F["Proceed with<br/>standard controls"]
    E -->|Standard hazards| G["Confirm controls<br/>in place"]
    E -->|High consequence| H["Permit or isolation<br/>required first"]
    E -->|No matching procedure| I["Escalate to a human"]
    E -->|Immediate danger| J["Stop, make safe first"]

    F --> K[("Assessment recorded<br/><small>becomes site history</small>")]
    G --> K
    H --> K
    I --> K
    J --> K

    K -.->|informs next time| C

    style C fill:#0F6CBD,stroke:#0A4E8A,color:#fff
    style D fill:#0F6CBD,stroke:#0A4E8A,color:#fff
    style E fill:#742774,stroke:#4A184A,color:#fff
    style H fill:#D93F0B,stroke:#9E2E08,color:#fff
    style I fill:#D93F0B,stroke:#9E2E08,color:#fff
    style J fill:#A4262C,stroke:#6E1A1E,color:#fff
    style K fill:#0078D4,stroke:#005A9E,color:#fff
Loading

That last arrow matters. Today's assessment is what makes tomorrow's hazard identification better, because previous events at this site are the strongest signal available.


Scenarios across industries

The same guard chain runs whatever the work. examples/scenarios/ holds six synthetic scenarios, each with the worker's words, a simulated model response, and the branch the guards must reach. The tests run every one end to end.

Scenario Industry What the model got wrong, or what happened Branch
Restocking upper racking Retail and distribution Nothing. Overhanging pallet, matched control confirm-controls
Replacing a circuit breaker Facilities Nothing. Exposed busbars need isolation permit-first
Light vehicle pre-start Field service Invented procedure SWP-TYRE-99, removed escalate
Home care visit Health and community care Silently dropped an unrestrained dog, caught escalate
Clearing a gutter, dark photo Facilities Said "the area looks safe", scrubbed; person required proceed-standard
Forklift near miss Retail and distribution Worker says someone is not breathing stop, before any model call

The procedure library and taxonomy in examples/ are illustrative. Replace them with your own; the tests check that every procedure maps to a taxonomy type.


Photo-based hazard identification

A photo is often the fastest and most honest report available. Someone in a loading bay can show a hazard in one second that would take two minutes to type.

It is also the easiest thing to get dangerously wrong, so the constraints are strict.

What the model may not do

It cannot confirm absence. "No guard is visible in this image" is acceptable. "There is no guard" is not. A photo is one angle at one moment, and a confident all-clear is the most dangerous output this system could produce.

It cannot state an area is safe. It reports which hazards it identified and which controls apply. Only the person standing there can say it is safe - and that is where the responsibility belongs.

It cannot infer cause, sequence or fault. An image shows a state, not a story.

It cannot assess a person. Competence, behaviour and condition are not readable from a still.

A clear photo is not a clear job. Absence of an identified hazard is never presented as an all-clear.

The reporter always outranks the model

For incident reporting, the AI's reading of a photo goes in a dedicated field, never in the description. The description belongs to the reporter, in their words, verbatim - including their grammar, because how someone describes what happened to them is evidence.

Anyone reading the record months later can tell exactly which words came from the person and which from the model. In an investigation, that distinction is everything.

If the model's reading appears to contradict the account, both are recorded and neither is asserted over the other. It saw one frame; they were there.


The emergency rule

Before anything else, in every capture path:

If there is any indication someone is seriously hurt or in immediate danger - say to call emergency services, and stop.

No detail collection. No offering to create a record instead. A person deciding whether to call should not be reading a form.

The agent behaviours carry this rule, but a rule in a prompt is a request. detectEmergency in src/safetyGuards.js is a deliberately broad keyword check that runs before any model call, so the stop does not depend on the model noticing. It is a floor, not a classifier: it will produce false positives, and that is the right trade. Extend the patterns for your workforce's language.


Not manufacturing risk

A behaviour worth stating explicitly, because it is counter-intuitive to build:

When nothing significant is found, say so and let them get on with it.

A safety tool that manufactures risk to appear diligent gets ignored within a fortnight - and an ignored safety tool is worse than none, because the organisation believes it has a control that nobody uses.

Equally: never talk someone out of stopping. If a worker is hesitant, support stopping.


Contents

Path Purpose
agent/behaviors/job-safety-analysis.md Pre-work JSA with hazard identification and control matching
agent/behaviors/report-safety-event.md Conversational incident capture with photo handling
agent/behaviors/vehicle-pre-start.md Vehicle and plant pre-start with defect classification and tag-out
examples/ Synthetic procedures, hazard taxonomy and end-to-end scenarios
prompts/hazardVision.js Vision prompts, the control-matching prompt and worker-input fencing
src/safetyGuards.js Emergency check, output validation, procedure allow-list, workflow branching
tests/ Unit tests (npm test, Node 20+)
dataverse/README.md Schema for events, hazards, procedures and assessments
docs/design-principles.md The safety-specific design constraints and why

Status

This is a reference design. The agent behaviours, photo-handling rules and prompts encode the constraints that matter, but accuracy against a specific hazard taxonomy and procedure library needs validating in your own environment before it is relied on.

Validate before deploying. This is safety tooling. The failure mode of a wrong answer is not an inconvenience.


Disclaimer

This is sample code, published as a reusable reference pattern.

  • Provided as is, without warranty of any kind, express or implied. See LICENSE.
  • Not production ready. Treat it as a starting point, not a finished solution. Review, test and harden it against your own requirements before any real use.
  • Not an official Microsoft product and not affiliated with, endorsed by, or supported by Microsoft. Product names are trademarks of their respective owners.
  • No support commitment. Issues and pull requests are welcome, but nothing here carries an SLA.
  • Some behaviours documented here rely on undocumented or preview platform features that can change without notice. Verify against current documentation before depending on them.
  • You are responsible for security, privacy, licensing and regulatory compliance in your own environment.

Licence

MIT - see LICENSE.

No warranty. This is a reference implementation, not a certified safety system. You are responsible for validating it against your own obligations, hazard taxonomy and procedures.

About

Proactive field safety for frontline workers: guided JSA, hazard identification from a photo, automatic SWMS surfacing and a workflow that branches on what was found.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages