1. Prerequisites — before you open Agent Studio
sn_aia.admin (author), sn_aia.user (run), platform admin for plugin activation only — not for production agent runtime.Minimum green light: you can open Agent Studio without 404, ACLs enforce row-level access on your lab table, and you have two test users (employee + manager) to prove invoking-user behavior.
Licensing reality: Now Assist, AI Agents, Agent Studio, and Control Tower are separate SKUs. If a URL fails, use filter navigator search — do not paste admin credentials into external LLM tools to “work around” missing product.
2. Direct URLs — bookmark these
Replace {BASE} with your instance (use the bar at top after page load). All links open in a new tab once applied.
Agent Studio
Agents, tools, agentic workflows, test traces.
Open →Control Tower
Inventory, policies, runs, third-party AI assets.
Open →Now Assist / Otto
End-user assistant surface — routes to skills, VA, agents.
Open →VA Designer
Deterministic topics — still best for high-volume scripted flows.
Open →AI Search
Indexed retrieval — native half of RAG.
Open →Predictive Intelligence
Classification / similarity ML — not generative chat.
Open →3. Lab — one read-only agent (leave or incidents)
Pick one track. Both use the same pattern: Script Include tool → register in Agent Studio → data access = invoking user → GlideRecordSecure so ACLs apply as the human who asked.
| Track | Table | What the agent may do (v1) |
|---|---|---|
| A — HR Leave | x_786686_hr_leave_req_v2 | List/count my requests; summarize dates and state — no insert, no u_state writes. |
| B — Security / ITSM | incident | List open incidents caller can see; get one by number — read-only, no assignment/state changes. |
LabAIReadTools in your app scope. Client callable: false.GlideRecordSecure + encoded query scoped to caller.3.1 Script Include — Track A (leave, read-only)
var LabAIReadTools = Class.create();
LabAIReadTools.prototype = {
initialize: function() {
this.T_REQ = 'x_786686_hr_leave_req_v2';
this.T_EMP = 'x_786686_hr_leave_employee_v2';
},
_employeeSysIdForUser: function(userId) {
var gr = new GlideRecordSecure(this.T_EMP);
gr.addQuery('user', userId);
gr.setLimit(1);
gr.query();
return gr.next() ? gr.getUniqueValue() : null;
},
/** AI Agent tool — list leave requests visible to invoking user via ACLs */
listLeaveForUser: function() {
var userId = gs.getUserID();
var empId = this._employeeSysIdForUser(userId);
if (!empId) return { ok: true, rows: [], note: 'no_employee_profile' };
var out = [];
var req = new GlideRecordSecure(this.T_REQ);
req.addQuery('u_employee_ref', empId);
req.orderByDesc('sys_created_on');
req.setLimit(25);
req.query();
while (req.next()) {
out.push({
number: req.getValue('number'),
state: req.getDisplayValue('u_state'),
type: req.getDisplayValue('u_leave_type'),
start: req.getValue('u_start_date'),
end: req.getValue('u_end_date'),
days: req.getValue('u_days')
});
}
return { ok: true, count: out.length, rows: out };
},
type: 'LabAIReadTools'
};
3.2 Script Include — Track B (incidents, read-only)
var LabAIReadTools = Class.create();
LabAIReadTools.prototype = {
initialize: function() {},
/** AI Agent tool — open incidents the invoking user may read (ACL-enforced) */
listOpenIncidents: function(limit) {
var max = Math.min(parseInt(limit, 10) || 10, 25);
var out = [];
var inc = new GlideRecordSecure('incident');
inc.addActiveQuery();
inc.orderByDesc('opened_at');
inc.setLimit(max);
inc.query();
while (inc.next()) {
out.push({
number: inc.getValue('number'),
short_description: inc.getValue('short_description'),
state: inc.getDisplayValue('state'),
priority: inc.getDisplayValue('priority'),
assignment_group: inc.getDisplayValue('assignment_group')
});
}
return { ok: true, count: out.length, rows: out };
},
getIncidentByNumber: function(number) {
if (!number) return { ok: false, error: 'number_required' };
var inc = new GlideRecordSecure('incident');
inc.addQuery('number', number);
inc.setLimit(1);
inc.query();
if (!inc.next()) return { ok: false, error: 'not_found_or_denied' };
return {
ok: true,
number: inc.getValue('number'),
description: inc.getValue('description'),
state: inc.getDisplayValue('state'),
opened_at: inc.getValue('opened_at')
};
},
type: 'LabAIReadTools'
};
v1 rule: do not register requestLeave, state changes, or Flow actions yet. First release = read + summarize only. Add writes only after ACL review and Control Tower registration.
Pass criteria: test trace shows tool call → JSON rows → natural language answer; impersonating a user with no rows returns empty list, not an error stack; no field named u_state or incident.state is updated by the tool.
4. Agentic workflow vs single agent
| Pattern | When to use | Where in UI |
|---|---|---|
| Single AI Agent | One domain, few tools, conversational Q&A (this lab). | Agent Studio → AI Agents |
| Agentic workflow | Multi-step process with branches, hand-offs, or separate “specialist” agents (triage → enrich → notify). | Agent Studio → Agentic Workflows |
| Virtual Agent topic | Fixed dialog, predictable utterances, compliance scripts. | VA Designer / topics |
Start with a single agent. Promote to agentic workflow when you can draw the steps on a whiteboard and name which agent owns each step.
5. RAG — practical steps (high level)
Retrieval Augmented Generation = give the model relevant text at question time; do not rely on training memory. On ServiceNow you usually implement retrieval first, generation second.
search_retrieval / custom Script Include).Deep implementation (three patterns A/B/C): AI Full Demo Master — Part 7 (RAG).
6. MCP — practical pointer
Model Context Protocol connects AI clients (Cursor, Claude Desktop, agent frameworks) to tools through a standard interface. For ServiceNow labs, the security boundary stays on the instance: allow-listed Script Includes or Scripted REST, not ad-hoc SQL from a laptop.
Do this next on a PDI: follow AI_SERVICENOW_FULL_DEMO_MASTER.html — Part 8 (MCP) — Scripted REST tool surface on the instance, thin local MCP server, editor config. Control Tower can inventory MCP servers as governed AI assets when licensed.
7. Define data access — invoking user vs AI User
| Mode | Runtime identity | Use when | Risk |
|---|---|---|---|
| Invoking user | Same roles/ACLs as the human who triggered the agent. | Default for employee/manager self-service (this lab). | Low — behavior matches portal ACLs. |
| AI User | Dedicated service account with its own roles. | Scheduled/unattended jobs where no human is in session. | High if over-roled — never admin for convenience. |
Production incident pattern: AI User granted admin to unblock a demo → agent summarizes restricted records into a public channel. Default invoking user unless you can explain why not in one sentence.
8. Best practices — do / don’t
First release contract: agents may read and explain; humans or approved Flows still commit state changes until security sign-off.
9. ServiceNow SDK — what it CAN and CANNOT do (AI agents)
From SDK 4.4+, Fluent APIs include AiAgent, agent tools, triggers, and agentic workflow artefacts — same governance tables as UI (sn_aia_*), expressed as TypeScript in your repo.
| SDK CAN | SDK CANNOT |
|---|---|
Define agents, tools, triggers as code; review in PRs; deploy with npx @servicenow/sdk build/deploy.Follow official topics: building-ai-agents-guide, building-ai-agents-tools-guide, building-ai-agents-advanced-guide (see SDK Cursor documentation topic list).
|
Replace AI Control Tower governance (inventory, policy, monitoring still required). Invent arbitrary tools without ACL allow-list and scoped Script Includes — runtime still enforces platform security. Skip licensing — SKUs must exist on the target instance. |
// Conceptual Fluent shape — see building-ai-agents-guide in SDK docs
import { AiAgent } from '@servicenow/sdk/core'
export const leaveReadAgent = AiAgent({
name: 'Leave Read Assistant (lab)',
description: 'Read-only leave visibility for invoking user',
// tools, instructions, triggers: defined alongside Script Include APIs in repo
})
Full SDK + MCP pairing: Full Demo Part 10 · Local SDK walkthrough: 16 SDK from scratch.
10. Related guides — go deeper
AI ServiceNow Full Demo Master
2–3 h · Agent Studio, workflows, Control Tower, RAG, MCP, Python + LLM, SDK commands.
Open master →Agentic AI + Control Tower (3 min)
Fast instance click-path for Tower and Studio screens.
Open 3-min →14 — AI in ServiceNow + Agents
Full HR Leave AI layer: skills, HRLXAIAgentTools, search, VA, governance.
Open ch.14 →Practical SecOps + VRO
Security + vulnerability lifecycle for AI read tools.
Open →Practical Flow Designer
Approvals and VI triage automation.
Open →SDK Windows Full Cycle
Install · auth · deploy · AiAgent can/cannot.
Open →