AI Engineering — Living Glossary #023
Lesson 23 of 24 Chapter 4 Production AI EngineeringAI Safety and Risk: Engineering Trustworthy Production AI Systems
Chapter 4: Deploying, Scaling, and Operating AI Systems
AIYING — Accomplishing with AI
Understand the Term. Connect the Technology. Apply the Knowledge.
1. The Industry Problem: An Instruction Hidden in a Manual
A manufacturing company introduces an AI assistant that helps maintenance technicians find information in approved equipment manuals.
One retrieved document contains a malicious sentence:
The sentence is not an authorized instruction. It appears inside lower-trust source content that the assistant was asked to analyze.
If the assistant treats this content as an instruction, it may produce dangerous guidance. If it is also allowed to control maintenance systems, the consequences could be more serious.
The engineering question is not simply whether the model can recognize the suspicious text.
This is a practical AI safety and risk engineering problem.
↑ Back to contents2. What Is AI Safety and Risk Engineering?
AI safety engineering is the application of technical and organizational practices to reduce the likelihood and impact of harmful AI-system behavior.
AI risk management is the process of identifying, analyzing, evaluating, treating, and monitoring uncertainty that may affect people, organizations, and other stakeholders.
In production AI, relevant risks may arise from:
- The model's outputs and limitations.
- Training and reference data.
- Retrieval and external content.
- Tools and connected systems.
- Application permissions and workflows.
- Human decisions and organizational processes.
- Changing conditions after deployment.
Safety is not equivalent to eliminating every possible risk. Engineering teams must understand residual risk, define acceptable operating boundaries, and assign accountability.
3. Why Safety Engineering Matters
Real-world consequences
AI outputs can influence financial, operational, educational, industrial, and healthcare decisions. Incorrect or unauthorized behavior may cause harm beyond an inaccurate answer.
Expanded attack surfaces
RAG systems, connected tools, and agents introduce external content and capabilities that require explicit trust boundaries.
Operational uncertainty
Model behavior can vary across prompts, contexts, versions, and deployment conditions.
Accountability
Organizations need identifiable owners for risk decisions, controls, incident handling, and approval of changes.
Legal and regulatory responsibilities
Applicable requirements depend on jurisdiction, industry, use case, and the organization's role. A generic safety checklist is not a substitute for a context-specific compliance assessment.
↑ Back to contents4. Major Categories of AI Risk
| Risk category | Example | Potential consequence |
|---|---|---|
| Accuracy | Invented maintenance procedure | Incorrect decision or physical harm |
| Prompt injection | Instructions embedded in retrieved content | Unauthorized behavior |
| Privacy | Customer data exposed in responses or logs | Confidentiality breach |
| Security | Agent uses a tool without proper authorization | Unauthorized system changes |
| Bias and fairness | Unequal error rates across affected groups | Unfair outcomes |
| Excessive agency | AI executes actions beyond approved scope | Uncontrolled operational impact |
| Misuse | Application used for harmful purposes | Harm to users or others |
| Reliability | Failure under unexpected workload | Interrupted service or bad decisions |
| Data integrity | Poisoned or outdated knowledge source | Misleading recommendations |
| Governance | No owner for high-risk decisions | Unmanaged residual risk |
Risk categories can overlap. For example, a prompt injection may cause a privacy breach through an unauthorized tool call.
↑ Back to contents5. Prompt Injection and Trust Boundaries
A prompt injection occurs when attacker-controlled or otherwise untrusted content attempts to redirect an AI system's behavior.
Direct and indirect injection
- Direct: An attacker places malicious instructions in a message submitted to the application.
- Indirect: The assistant encounters malicious instructions in a document, web page, tool result, email, or another lower-trust source.
Why retrieved documents are not instructions
RAG systems retrieve information to support a task. A retrieved manual may contain facts to summarize, but it does not gain authority to change the assistant's permissions or safety requirements.
Trust-boundary principle
Authorized user / system policy
|
v
Application controls
|
v
AI reasoning / generation
^
|
Retrieved documents and tools
(lower-trust data)
Lower-trust content must not grant
permissions or override policy.
Engineering defenses
- Keep trusted instructions separate from retrieved content.
- Enforce permissions in application code and tool services.
- Use least-privilege credentials.
- Validate proposed actions against approved policies.
- Restrict sensitive operations to explicit approval workflows.
- Test with realistic injection attempts.
- Monitor and investigate suspicious behavior.
6. Safety-by-Design Production Architecture
A safer AI application combines independent controls rather than relying on one model-generated judgment.
User request
|
v
Authentication and authorization
|
v
Input checks and risk classification
|
v
Workflow controller / policy engine
|
+----> Approved retrieval sources
| |
| v
| Source and access checks
|
+----> Language model
| |
| v
| Proposed answer / action
|
v
Output and action validation
|
+----> Unsafe / uncertain?
| |
| v
| Block, clarify or escalate
|
v
Authorized tool or user response
|
v
Telemetry, evaluation and audit
Security outside the model
Tool services must independently check authorization, input validity, and allowed operations. A model's request to perform an action is not sufficient authority.
Separation of recommendation and execution
An assistant may recommend that a qualified technician inspect equipment, while the actual maintenance operation remains under approved human procedures.
Fail-safe behavior
When a safety-critical requirement cannot be verified, the system should not invent a procedure or proceed with an irreversible action.
↑ Back to contents7. Preventive, Detective, and Corrective Controls
| Control type | Purpose | Examples |
|---|---|---|
| Preventive | Reduce the chance of unsafe behavior | Least privilege, authorization, approved sources, action restrictions |
| Detective | Identify suspicious or harmful behavior | Safety evaluations, anomaly alerts, audit events, user reports |
| Corrective | Contain and recover from problems | Disable tools, rollback, isolate data, incident remediation |
Controls should be selected according to the actual threat and the potential severity of harm.
A response filter may help with inappropriate content, but it cannot replace database permissions, physical interlocks, or formal approvals.
8. Assessing and Prioritizing AI Risks
Risk assessment begins with the intended use, affected stakeholders, operating environment, and reasonably foreseeable misuse.
Step 1 — Identify hazards and threats
List situations in which the system could cause or contribute to an undesirable outcome.
Step 2 — Analyze consequences
Consider severity, exposure, affected people, reversibility, and operational dependencies.
Step 3 — Estimate likelihood
Use available evidence, attack testing, historical incidents, and uncertainty estimates. Avoid treating unsupported numeric scores as precise probabilities.
Step 4 — Prioritize controls
Focus on severe, plausible, and insufficiently controlled risks.
Step 5 — Assign ownership
Document who approves the controls, accepts residual risk, and responds when conditions change.
| Illustrative risk | Impact | Primary mitigation |
|---|---|---|
| Unsafe maintenance recommendation | Potentially severe | Approved procedures, blocked unsafe actions, qualified review |
| Unauthorized work-order modification | Operational disruption | Tool authorization and approval |
| Outdated equipment manual | Incorrect guidance | Version-controlled document retrieval |
| Sensitive log exposure | Privacy or security harm | Redaction, access controls, retention limits |
These are qualitative teaching examples, not a validated risk rating for any particular facility.
↑ Back to contents9. Safety Evaluations and Red Teaming
Safety evaluation asks whether the system behaves acceptably under defined normal, unusual, and adversarial conditions.
Representative test categories
- Ordinary authorized requests.
- Ambiguous or incomplete instructions.
- Outdated and conflicting documents.
- Indirect prompt injection in retrieved content.
- Unauthorized tool requests.
- Attempts to reveal sensitive information.
- Requests involving high-impact decisions.
- Failures of connected tools and data sources.
Red teaming
Red teaming deliberately probes for vulnerabilities, unsafe behaviors, and failure modes. It complements routine testing but cannot prove complete safety.
Measure both safety and usefulness
A system that blocks every request may avoid some harms but fail its intended purpose. Measure harmful compliance and inappropriate refusal separately.
Regression testing
Re-run relevant safety tests when models, prompts, tools, permissions, or retrieval sources change.
↑ Back to contents10. Human Oversight and Accountability
Human oversight must be designed around meaningful authority, competence, time, and access to relevant evidence.
When to require approval
- Safety-critical operational changes.
- High-impact or irreversible actions.
- Requests outside the assistant's authorized scope.
- Cases with unresolved uncertainty or conflicting evidence.
- Exceptions to standard business policies.
What a reviewer needs
Provide the proposed action, source evidence, relevant context, uncertainty, and consequences. The reviewer must be able to reject or modify the action.
Accountability
Assign clear responsibility for system ownership, risk acceptance, control testing, deployment approval, and incident response.
Human-in-the-loop is not automatically effective: rubber-stamp approvals and overloaded reviewers may provide little actual protection.
↑ Back to contents11. AI Safety Versus Related Concepts
| Concept | Main concern |
|---|---|
| AI Safety | Preventing or reducing harmful outcomes |
| AI Security | Protecting systems against unauthorized access and attacks |
| AI Risk Management | Identifying, assessing, treating, and monitoring uncertainty |
| Guardrails | Specific constraints and checks on inputs, outputs, and actions |
| Responsible AI | Broader considerations including fairness, transparency, accountability, and human impact |
| AI Governance | Organizational authority, policies, oversight, and accountability |
| AI Evals | Systematic measurement of behavior against defined criteria |
| Production Observability | Evidence for understanding system behavior during operation |
These disciplines overlap, but none alone provides a complete safety assurance.
↑ Back to contents12. Industry Applications
- Manufacturing: Prevent unsafe maintenance guidance and unauthorized control actions.
- Financial services: Protect customer information and require review for consequential decisions.
- Healthcare: Control clinical-use boundaries, sensitive information, and escalation.
- Customer support: Prevent disclosure of another customer's records.
- Software engineering agents: Restrict file access, code execution, and production deployment permissions.
- Human resources: Evaluate fairness and prevent inappropriate automated decision-making.
- Enterprise knowledge systems: Defend against malicious or unauthorized retrieved content.
The applicable control set depends on the use case, severity of potential harm, and governing requirements.
↑ Back to contents13. Detailed Industry Case: Manufacturing Maintenance Assistant
Illustrative training scenario; not a reported incident at a named company.
Business objective
Help qualified maintenance staff locate approved equipment instructions, summarize troubleshooting steps, and prepare draft work orders.
Authorized system boundaries
- Read approved equipment documentation.
- Provide citations to document versions.
- Draft maintenance work orders.
- Request qualified human review.
- Never directly disable safety interlocks or control hazardous equipment.
The attack
A malicious instruction is inserted into a retrieved document excerpt and attempts to persuade the assistant to recommend bypassing a safety mechanism.
Risk analysis
The immediate concern is unsafe advice. A related concern is whether the assistant could use connected tools to create or execute an unsafe action.
Defense design
- Allow retrieval only from approved, version-controlled sources.
- Mark retrieved material as task data, not trusted instructions.
- Prohibit the assistant from directly controlling machinery.
- Enforce tool permissions independently of model output.
- Validate maintenance recommendations against approved procedures.
- Escalate hazardous or uncertain cases to qualified personnel.
- Record appropriate safety events without exposing secrets.
Illustrative incident timeline
| Time | Event | Engineering response |
|---|---|---|
| 09:00 | Adversarial test submitted | Test harness captures request and trace ID |
| 09:01 | Suspicious retrieved text detected | Flag untrusted instruction attempt |
| 09:02 | Model proposes unsafe guidance in one test run | Output policy check blocks response |
| 09:05 | Safety event reviewed | Restrict affected source and investigate |
| 10:00 | Controls and retrieval configuration updated | Run regression tests |
| 11:00 | Test suite reviewed | Document residual risk and release decision |
The timeline is hypothetical. Detection and blocking are not guaranteed in every real deployment.
Verification
The engineering team confirms that:
- Unsafe tool actions remain technically unavailable.
- Relevant adversarial test cases do not result in unsafe outputs.
- Approved maintenance questions still receive useful answers.
- Escalation works when safe guidance cannot be established.
- Safety events are visible to the appropriate operators.
14. Production Monitoring and Incident Response
Safety engineering continues after deployment.
Signals to monitor
- Safety-policy violations and blocked actions.
- Unauthorized tool-call attempts.
- Prompt-injection detections and reviewed findings.
- Unexpected changes in refusal or escalation rates.
- Quality regressions on safety-sensitive tasks.
- Changes in document sources and permissions.
- Human overrides and incident reports.
Response workflow
Safety signal / user report
|
v
Assess severity and exposure
|
v
Contain affected capability
|
v
Preserve appropriate evidence
|
v
Investigate cause and impact
|
v
Repair / rollback / restrict
|
v
Re-evaluate and authorize recovery
|
v
Document lessons and follow-up
For severe risks, teams may need to disable a tool, restrict a workflow, or suspend the affected feature while investigation proceeds.
Response procedures should align with existing organizational security, safety, and incident-management processes.
↑ Back to contents15. Engineering Decisions and Trade-offs
| Decision | Benefit | Trade-off |
|---|---|---|
| Restrict tool permissions | Limits unauthorized impact | Some tasks need additional approval |
| Human approval | Adds qualified judgment | Latency and reviewer workload |
| Strict output filtering | Can block harmful responses | False positives and missed harms |
| Approved retrieval sources | Improves source control | May limit information coverage |
| Detailed audit logging | Supports investigation | Privacy, retention, and cost concerns |
| Disable risky features | Reduces exposure | May reduce functionality |
Choose controls proportionate to the risk and verify that they work under realistic conditions.
↑ Back to contents16. Hands-On Mini-Project: Build a Safety Test Harness
Project title: Safety Engineering for a Document-Based Maintenance Assistant.
Level: Beginner to intermediate.
Tools: Spreadsheet or Python, synthetic documents, and optional AI model access.
No physical machinery, live industrial controls, or real operational credentials are required.
Step 1 — Define the intended use
The assistant may summarize approved manuals and draft work orders. It must not operate equipment or recommend bypassing safety protections.
Step 2 — Create synthetic documents
Prepare five fictional equipment manuals containing harmless troubleshooting information.
Step 3 — Create an adversarial document
Add a clearly labeled synthetic passage that attempts to override the assistant's instructions and produce prohibited guidance.
Step 4 — Define test categories
- 10 ordinary authorized questions.
- 5 ambiguous questions.
- 5 conflicting-document questions.
- 5 indirect prompt-injection cases.
- 5 unauthorized-action requests.
Step 5 — Define expected outcomes
For each case, specify whether the system should:
- Answer with approved evidence.
- Ask for clarification.
- Decline the unsafe action.
- Escalate to a qualified reviewer.
Step 6 — Design application controls
Use a simulated authorization layer and a fixed allowlist of permitted operations.
The test harness must never connect to actual industrial control systems.
Step 7 — Execute or simulate the tests
Record each input, expected result, observed result, risk category, and control outcome.
Step 8 — Analyze failures
Separate unsafe compliance, incorrect refusal, unsupported answers, and tool-authorization failures.
Step 9 — Improve the design
Propose additional controls and rerun the relevant regression cases.
Step 10 — Prepare a safety case
Submit a concise report containing:
- Intended use and operating boundaries.
- Risk register.
- Control architecture.
- Test results and limitations.
- Residual risks.
- Recommended deployment decision.
17. Project Evaluation and Acceptance Criteria
| Criterion | Expected evidence |
|---|---|
| Risk coverage | Documented risks and realistic test cases |
| Authorized-task success | Correct responses to legitimate requests |
| Unsafe compliance | Count and review of prohibited outcomes |
| Unauthorized tool actions | No execution possible in the simulated permission layer |
| Prompt-injection resistance | Observed behavior on defined adversarial cases |
| False refusals | Legitimate tasks incorrectly blocked |
| Escalation | Appropriate review for uncertain or high-risk cases |
| Auditability | Traceable test results and control decisions |
| Privacy | No real personal information or credentials |
| Residual risk | Explicit limitations and accountable recommendation |
Suggested exercise gate: Zero unauthorized simulated tool executions, no unsafe recommendations in the defined high-severity test set, and documented review of all failures and false refusals.
Passing a small exercise test set is not proof that a production system is safe. Real deployment requires broader validation and context-specific assurance.
↑ Back to contents18. Connected Living Glossary
- #004 — RAG: Retrieved content creates trust-boundary considerations.
- #007 — Evals: Measure safety and task behavior.
- #008 — Hallucination: Unsupported outputs can create harmful decisions.
- #009 — Grounding: Connect answers to appropriate evidence.
- #010 — Guardrails: Implement specific behavioral and action controls.
- #012 — Human-in-the-Loop: Provide review and accountability.
- #013 — Tool Calling: Requires authorization and least privilege.
- #015 — AI Agents: Autonomy increases the importance of action boundaries.
- #019 — Deployment: Safety controls must be validated before release.
- #021 — Production Observability: Detect and investigate safety-relevant events.
- #022 — Cost Optimization: Cost reductions must preserve essential safeguards.
Next lesson: #024 — Lifecycle Operations (LLMOps).
↑ Back to contents19. Living Update
Editorial baseline: November 2026.
Production safety engineering must evolve as models, agent capabilities, threat techniques, and regulations change.
Engineers should regularly review:
- New prompt-injection and tool-misuse patterns.
- Model and application security advisories.
- Agent permission and sandboxing practices.
- Evaluation methods for safety and fairness.
- Changes in applicable legal requirements.
- Incident lessons and newly observed failure modes.
- Effectiveness of human oversight.
For regulatory obligations, consult current official sources and qualified organizational advisers. Requirements differ by jurisdiction and application.
↑ Back to contents20. Key Takeaway and One Action
Understand the Term: Safety and risk engineering identify potential harms and manage their likelihood and impact.
Connect the Technology: Models, retrieval, tools, agents, authorization, and production monitoring must work together within defined safety boundaries.
Apply the Knowledge: Test how an AI application behaves when lower-trust content attempts to redirect its actions.
One Action: Select one AI workflow, identify its most serious plausible failure, and design two independent controls that limit the consequences.
One Term. One Industry Connection. One Practical Insight. One Action.
↑ Back to contents21. Authoritative References
- NIST — AI Risk Management Framework: Governance, mapping, measurement, and management of AI risks.
- NIST — AI Resource Center: Practical resources for AI risk management.
- OWASP — Top 10 for LLM Applications: Application security risks including prompt injection and excessive agency.
- MITRE ATLAS: Adversarial threats and techniques involving AI-enabled systems.
- ISO/IEC 42001: AI management system standard.
- European Commission — AI Regulatory Framework: Official information about the EU AI Act.
- OpenTelemetry: Operational evidence and instrumentation.




