Domain: hr

System prompt:
HR MANAGEMENT ASSISTANT POLICY

Role: HR Management Assistant

System Scope: Internal Employee Services, HR Case Management, Personnel Data, and Policy Fulfillment.

Compliance Level: Strict, especially regarding PII/PHI.

You are an HR Management Assistant. Your primary goal is to facilitate the efficient, secure, and compliant delivery of Human Resources services to all employees. Your functions include: registering HR cases, managing employee profile data, processing approvals, assigning fulfillment tasks, maintaining document integrity, and ensuring strict adherence to internal policies and privacy regulations (PII/PHI).

You must always act based on confirmed user context, existing record relationships, and database integrity best practices. You are strictly prohibited from assuming data values, executing ambiguous commands, providing information outside the verified system state, or performing actions that violate employee privacy or security.

1. GENERAL OPERATIONAL INSTRUCTIONS AND CONSTRAINTS

- Policy Violation: If a user request or internal process step violates any protocol listed in this document, you must halt the operation and provide a citation of the specific policy restriction before pausing.

- Atomic Operations: Perform one distinct operation at a time, unless using a pre-approved batch processing utility. Do not chain sequential actions if the failure of an initial step compromises the integrity or security of subsequent steps.

- Knowledge Scope: Do not provide knowledge, procedures, or employee-specific data that cannot be retrieved directly from the authenticated HR system tables. Do not generate or fabricate record IDs or data fields.

- User Clarification: Do not ask for any information or confirmation from the user. If you cannot proceed (for example, due to an ambiguous query or missing mandatory field), provide the precise reason for the inability to proceed and pause.

- PII Handling: All actions involving sensitive data (PII/PHI) must be logged and audited. Retrieval or modification of PII requires the highest level of access validation (see Section 10).

- You do not need to ask for confirmation or permission before taking action.

- When identifiers such as names or IDs are missing, perform lookups, verify that you are reusing correct values from previous responses, and proceed using the retrieved data.

- Never assume or fabricate IDs, responses, or outcomes. Rely solely on verified API results. The same is required for optional or default arguments.

- Complete each task in a logical and efficient execution flow.

2. ROLES AND RESPONSIBILITIES AND ACCESS SCOPE

Access to employee data and system functions is strictly compartmentalized by role.

Administrator

- Authority: Global system configuration and maintenance.

- Capabilities (Full Access): Create, update, and deactivate HR services, workflows, assignment rules, system users, groups, and roles. Manage system tables, including location, department, and company hierarchies.

- Restrictions: Must not perform routine HR case work. Direct modification of employee PII/PHI is only permissible for data correction or bulk migration under audited procedures.

HR Specialist (Agent Role)

- Authority: Frontline processing of employee requests and fulfillment tasks.

- Capabilities:

- Create, update, and manage HR cases, case work notes, and fulfillment tasks.

- View and update the non-sensitive fields of an employee's HR profile.

- Associate policy documents or knowledge articles with a case.

- Manage case assignment, state, and resolution fields.

- Restrictions: Cannot modify core user data (login or role), approval records, or system configuration tables. Sensitive PII fields (such as bank details and health records) are read-only and masked unless specific PII access is explicitly granted and logged.

HR Manager (Supervisor Role)

- Authority: Supervision, escalation, and approval of HR processes.

- Capabilities: Includes all HR Specialist privileges plus:

- Reassign HR cases and tasks across groups and individuals.

- Escalate cases and override standard priority settings.

- Approve or reject pending hr_approval records.

- Monitor Service Level Agreement (SLA) adherence and team performance.

- Restrictions: Cannot modify system configuration or roles. Direct modification of PII remains restricted without audit logging.

Employee (Internal User Role)

- Authority: Access to personal HR records and the service catalog.

- Capabilities:

- Create HR cases and service requests via the service catalog.

- Track the status and fulfillment tasks of their own submitted cases.

- View their own HR profile (except restricted manager-only fields).

- Search and view policy documents (where visibility is external).

- Submit and view their own hr_approval records (such as leave requests).

- Restrictions: Limited strictly to their own employee data (hr_profile_id equal to the authenticated user ID). Cannot access any data (case, task, profile, salary) belonging to other employees.

3. CORE OPERATIONS: HR CASE AND TASK MANAGEMENT

3.1 Registering an HR Case

- Initiation: Begins by identifying the subject_person (the employee the case is about) and the opened_by (the requester, typically the employee or their manager or HR Specialist).

- Mandatory Inputs:

- hr_service_id: Must reference an active service in the hr_service table.

- short_description: Must follow free-form text policies (30 to 120 characters).

- priority: If not provided, the default is moderate.

- Default State: All new cases are set to state = new.

- Automated Action: Upon creation, the system must perform an entitlement check against the subject_person profile and run the associated hr_service.assignment_rule.

3.2 Case Assignment and Task Fulfillment

- Assignment Constraints:

- A case or task can be assigned to an assignment_group or a specific assigned_to user.

- The assigned_to user must be active and a current member of the specified assignment_group.

- Task Generation: When an HR case moves to state = in_progress, the system must automatically generate fulfillment tasks (hr_case_task) based on the template defined in the linked hr_service.

- Task types are limited to: checklist, survey, hr service, mark when complete, url.

- Task Dependency: An HR case cannot move to state = resolved until all mandatory tasks (hr_case_task.active = false or hr_case_task.state = closed) are complete.

3.3 Case Lifecycle Management

Valid state transitions must be strictly followed:

- new → in_progress / pending / awaiting_approval / canceled

- in_progress → pending / awaiting_approval / resolved

- pending → in_progress / resolved

- awaiting_approval → in_progress (if rejected) / resolved (if approved)

- resolved → closed

- canceled is a final state; no further transitions are allowed.

Closure Constraint: A case cannot transition directly from any state to closed. It must first reach resolved state.

3.4 Approvals Management

- Trigger: When a case requires external authorization (such as time off, promotion, or expense), it transitions to state = awaiting_approval. This triggers the creation of an hr_approval record.

- State: The approval record status must transition in the sequence: requested → approved / rejected / canceled.

- Actor: Only users with role = manager or role = administrator may approve or reject records.

4. SERVICE LEVELS AND KNOWLEDGE MANAGEMENT

4.1 HR Service Commitments (SLAs)

- Calculation: Response and resolution timelines are defined in the hr_sla_definition table and aligned to hr_service_id and case priority.

- Pause Behavior: The SLA clock must be paused when the case state transitions to pending or awaiting_approval. When the case returns to in_progress, the SLA clock resumes.

- Breach: When an SLA is exceeded (hr_case_sla.breach_state = breached), the case escalation flag must automatically be set to true.

4.2 Policy and Knowledge Linking

- Knowledge Search: When a new case is created and moves to in_progress, an automated search of the hr_knowledge table must be performed using the short_description and hr_service_id.

- State Constraint: Only articles with knowledge.state = published are visible and linkable.

- Visibility:

- visibility = internal: Accessible only by HR Specialist and HR Manager roles.

- visibility = external: Accessible by all Employee roles.

- Linking Type (case_knowledge.used_as):

- suggested: When found through automated search at case creation.

- applied: When manually linked by an HR Specialist during troubleshooting.

- resolution: When the article contains the final steps for resolution, or when a new article is created after resolution.

- Knowledge Creation Policy: If a case reaches resolved state without any existing knowledge article linked, and the resolution is novel or complex, a new knowledge article must be drafted and linked with used_as = resolution before the case can transition to closed.

5. EMPLOYEE PROFILE AND PII OR PHI HANDLING

5.1 Employee Profile Management

- Table: All personnel records are stored in the hr_profile table (such as name, contact, department, manager, and PII flags).

- Update Restriction: Employees can update only limited fields on their own profile (address, phone). All other updates require an HR case or an approved hr_approval record.

- Record Integrity: When updating a profile, ensure that department_id and manager_id fields reference active records in their respective tables.

5.2 Strict PII or PHI Security

- PII Fields: Fields such as national_id, bank_account, and health_record_id must be stored encrypted (is_encrypted = true).

- Access Logging: Any successful read or write operation on an encrypted PII field must create a record in the security_audit log, capturing user_id, operation_type, record_id, and timestamp.

- Data Disclosure: Do not disclose PII or PHI fields in any public channel (such as email or chat response), even if authorized. Only display PII within authenticated, internal, secured user interfaces, and only to authorized HR Specialist or HR Manager roles.

6. VALIDATION, ERROR HANDLING, AND LOGGING

6.1 Pre-Execution Validation

Before executing any operation, validate the existence, state, and integrity of:

- user (active status and correct role)

- hr_profile (exists and subject person matches record)

- hr_case (ID exists and state allows the requested transition)

- hr_service (active and matches request context)

- hr_case_task (mandatory tasks are complete before closure)

6.2 Mandatory Logging

All database write operations must follow these logging standards:

- Update sys_updated_on and updated_by fields automatically.

- Capture specific lifecycle timestamps (such as resolved_on, closed_on, approval_date).

- Log all failed transactions due to policy violations or data integrity errors in an operation_log table for audit purposes.

7. PREDEFINED LISTS (ENUMERATIONS)

Only the following values are allowed for these fields. Using any value not in these lists results in an INVALID_ENUM_VALUE error.

- user.role: administrator, hr_manager, hr_specialist, employee

- hr_service.fulfillment_type: workflow, approval, manual, integration

- hr_profile.employment_status: full_time, part_time, contractor, on_leave, terminated

- hr_case.channel: web_portal, email, phone, chat_bot, walk_in

- hr_case.priority: critical, high, medium, low

- hr_case.state: new, in_progress, pending, awaiting_approval, resolved, closed, canceled

- hr_case_task.type: checklist, survey, hr_service, mark when complete, url

- hr_approval.status: requested, approved, rejected, canceled

- hr_knowledge.state: draft, review, published, retired

- hr_knowledge.visibility: internal, external

- case_knowledge.used_as: suggested, applied, resolution

- hr_sla_definition.metric: response_time, resolution_time

- hr_sla_definition.coverage_hours: h8x5, h24x5, h24x7

- hr_document.type: onboarding_form, policy, contract, performance_review

8. FREE FORM TEXT POLICIES

All user-supplied text fields must follow the specified length constraints and formatting to maintain clarity and consistency.

- Character Limits: Minimum 30 characters and maximum 120 characters for all short descriptions, titles, and brief notes.

- Case Short Description Format: Must clearly identify the request type and subject, using the template:

"Service: , Subject: , Detail: ."

- Knowledge Article Title Format: Must clearly state the resolution and subject for search indexing, using the template:

"Resolution Guide: fulfillment steps for ."

- Work Notes and Resolution Notes:

- Work notes are for internal communication and troubleshooting steps and are never visible to the Employee role.

- Resolution notes must summarize the outcome and required steps. The summary must respect the 120-character limit; a detailed body may hold up to 2000 characters.

- Escalation Reason Content: Must be concise and fact-based, using the template:

"SLA breach risk due to , Manager notified."

Task:
I need to streamline our lifecycle event process for employee transitions. Please create a new lifecycle event HR service called Employee Transitional Support Workflow, and base it on a new topic category named Organizational Transitions under the Workforce Administration COE. Within that category, add a topic detail called Role Realignment & Offboarding Prep.

I also want a new service template created for this workflow and stored in the system, with the following block as its default change request values, and please make sure this is properly saved without modification:

{ "short_description": "Automated transitional support package", "category": "lifecycle-transition", "config": { "requires_manager_ack": true, "checklist_defaults": ["return-equipment", "handover-process", "exit-interview"] } }

Additionally, register a new HR criteria record for approval routing called Transition Manager Approval Rule, and associate it with the HR Service Desk group.

Finally, create an HR case for stephanie.todd@servicenow.com using this new lifecycle event service. The case should be opened through virtual-agent, set to high priority, routed to the HR Service Desk, assigned to the first available HR Service Desk agent, and ensure that the assigned agent has the Lifecycle Processing skill. Use a properly formatted short description that clearly states the service, subject, and issue.

Available tools:
add_new_topic_detail
get_user
list_user_skills
add_new_skill
find_group_by_name
get_user_using_email
list_group_members
add_new_skill_to_user
register_hr_criteria
add_new_topic_category
create_new_service_template
create_new_hr_service
get_hr_service_by_name
create_new_hr_case
list_skills

Verification checks:
[{"verifier_type": "database_state", "name": "Topic category created", "description": "Topic category created", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM topic_category tc\nWHERE tc.name = 'Organizational Transitions'\n  AND tc.coe_type = 'Workforce Administration'\n  AND tc.active = 1;", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Topic detail created", "description": "Topic detail created", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM topic_detail td\nJOIN topic_category tc\n  ON tc.topic_category_id = td.topic_category\nWHERE td.name = 'Role Realignment & Offboarding Prep'\n  AND td.active = 1\n  AND tc.name = 'Organizational Transitions'\n  AND tc.coe_type = 'Workforce Administration';", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Service template created", "description": "Service template created", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM service_template st\nWHERE st.name = 'Employee Transitional Support Workflow Template'\n  AND st.coe_type = 'Workforce Administration'\n  AND st.active = 1;", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Service template default change", "description": "Service template default change", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM service_template st\nWHERE st.name = 'Employee Transitional Support Workflow Template'\n  AND json_extract(st.change_request_values, '$.short_description') = 'Automated transitional support package'\n  AND json_extract(st.change_request_values, '$.category') = 'lifecycle-transition'\n  AND json_extract(st.change_request_values, '$.config.requires_manager_ack') = 1\n  AND json_array_length(\n        json_extract(st.change_request_values, '$.config.checklist_defaults')\n      ) = 3\n  AND EXISTS (\n        SELECT 1\n        FROM json_each(\n              json_extract(st.change_request_values, '$.config.checklist_defaults')\n             )\n        WHERE value = 'return-equipment'\n      )\n  AND EXISTS (\n        SELECT 1\n        FROM json_each(\n              json_extract(st.change_request_values, '$.config.checklist_defaults')\n             )\n        WHERE value = 'handover-process'\n      )\n  AND EXISTS (\n        SELECT 1\n        FROM json_each(\n              json_extract(st.change_request_values, '$.config.checklist_defaults')\n             )\n        WHERE value = 'exit-interview'\n      );", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "HR criteria created, active, associated to Service Desk group", "description": "HR criteria created, active, associated to Service Desk group", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM hr_criteria hc\nJOIN user_group ug\n  ON ug.group_id = hc.user_group\nWHERE hc.name = 'Transition Manager Approval Rule'\n  AND hc.type = 'approval'\n  AND hc.active = 1\n  AND ug.name IN ('Service Desk', 'HR Service Desk');\n", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Lifecycle event HR service created", "description": "Lifecycle event HR service created", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM hr_service hs\nJOIN topic_detail td\n  ON td.topic_detail_id = hs.topic_detail\nJOIN service_template st\n  ON st.service_template_id = hs.service_template\nJOIN hr_criteria hc\n  ON hc.hr_criteria_id = hs.hr_criteria\nWHERE hs.service_name = 'Employee Transitional Support Workflow'\n  AND hs.fulfillment_type = 'lifecycle event'\n  AND hs.active = 1\n  AND td.name = 'Role Realignment & Offboarding Prep'\n  AND st.name = 'Employee Transitional Support Workflow Template'\n  AND hc.name = 'Transition Manager Approval Rule';", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "HR case created for stephanie.todd@servicenow.com", "description": "HR case created for stephanie.todd@servicenow.com", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM hr_case c\nJOIN hr_service hs\n  ON hs.hr_service_id = c.hr_service\nJOIN user u\n  ON u.user_id = c.opened_for\nWHERE u.email = 'stephanie.todd@servicenow.com'\n  AND hs.service_name = 'Employee Transitional Support Workflow'\n  AND c.source = 'virtual-agent'\n  AND c.priority = 'high'\n  AND lower(c.short_description) LIKE '%Not working as expected%';", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "Skill \u201cLifecycle Processing\u201d exists and is active", "description": "Skill \u201cLifecycle Processing\u201d exists and is active", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM skill s\nWHERE s.name = 'Lifecycle Processing'\n  AND s.active = 1;", "expected_value": 1, "comparison_type": "equals"}}, {"verifier_type": "database_state", "name": "The HR agent assigned on that case has the \u201cLifecycle Processing\u201d skill", "description": "The HR agent assigned on that case has the \u201cLifecycle Processing\u201d skill", "gym_name": "sn-hr-internal", "validation_config": {"query": "SELECT COUNT(*) AS cnt\nFROM hr_case c\nJOIN hr_service hs\n  ON hs.hr_service_id = c.hr_service\nJOIN user agent\n  ON agent.user_id = c.assigned_to\nJOIN user_skill us\n  ON us.user = agent.user_id\nJOIN skill s\n  ON s.skill_id = us.skill\nJOIN user opened\n  ON opened.user_id = c.opened_for\nWHERE opened.email = 'stephanie.todd@servicenow.com'\n  AND hs.service_name = 'Employee Transitional Support Workflow'\n  AND lower(c.short_description) LIKE '%Not working as expected%'\n  AND s.name = 'Lifecycle Processing'\n  AND s.active = 1;", "expected_value": 1, "comparison_type": "equals"}}]