ServiceNow AI agents
Beta: find the AI agents in AI Agent Studio, then have their tools ask Intertrace before they act.
Status
What you get
Discovery (read-only). Every agent in AI Agent Studio with who can start it (public, any signed-in user, specific roles, Virtual Agent chat, email or record triggers), who it runs as and that user's roles (admin, security_admin and other elevated roles are flagged), each tool and what it invokes (script, record operation, subflow, flow action, catalog item, web search, knowledge search, MCP), and whether a person confirms the tool first (Supervised) or it runs on its own (Autonomous).
Risk reasons include an agent people outside IT can start that can change records, a run-as user with admin roles, script tools (more when the script evaluates text as code or switches users), tools that change records without a person confirming, and tools that change records without calling the Intertrace guard.
Runtime guard. ServiceNow runs the agent's model inside the instance and has no outside pre-tool hook, so each tool that changes records calls a Script Include first. It asks the enforcer (POST /v1/actions/authorize) and the tool goes on only on allow.
1. Connect for discovery
- 1
Turn on the client credentials grant
System Properties: createglide.oauth.inbound.client.credential.grant_type.enabled=true(global scope). - 2
Create the OAuth application
System OAuth → Application Registry → New → OAuth API endpoint for external clients. Set the grant type to Client Credentials and pick an OAuth Application User: a dedicated, non-interactive integration user. On newer releases this lives under Machine Identity Console → Inbound Integrations. - 3
Give the user read roles
sn_aia_viewerreads every AI Agent Studio table. For who-can-start and run-as roles, the user also needs read onsys_security_acl_role,sys_user,sys_user_has_role,sys_user_roleandsys_agent_access_role_configuration; reading ACL roles usually needssecurity_adminor a read ACL you add. Without them the source shows as limited and names each table. Intertrace never writes. - 4
Connect in Intertrace
Discovery → ServiceNow AI agents → Connect: the instance URL (https://<instance>.service-now.comonly), client ID and secret. Intertrace gets a token and reads one agent row before saving; the secret is encrypted at rest.
Tables read: sn_aia_agent, sn_aia_agent_config, sn_aia_agent_tool_m2m, sn_aia_tool (the script is read to classify the tool and is not stored), sn_aia_team_member, sn_aia_usecase, sn_aia_trigger_agent_usecase_m2m, sn_aia_trigger_configuration, the ACL and role tables above, and the property sn_aia.enable_usecase_tool_execution_mode_override.
2. Install the guard
- 1
Mint the runtime key
Import the agent from Discovery, open its agent page and create a runtime key (itr_rt_…). The agent page's id is what the guard sends as agent.id. - 2
Store it in a Connection & Credential alias
An HTTP connection with Connection URLhttps://intertrace.fly.devand an API Key credential holding the runtime key (a Basic Auth credential's password also works). Allow outboundintertrace.fly.dev:443if the instance restricts hosts. - 3
Add the Script Include
Create Script IncludeIntertraceGuardfromruntime-plugins/servicenow-intertrace/IntertraceGuard.jsand set the propertyintertrace.guard.connection_aliasto the alias's sys_id. Map ServiceNow agents to Intertrace agents withintertrace.guard.agent_mapor passagentIdin each call.
3. Call it from each tool that changes records
Script tool:
(function (inputs) {
var verdict = new IntertraceGuard().check({
agentId: 'INTERTRACE_AGENT_ID',
tool: 'reassign_incident',
operation: 'write',
arguments: { number: inputs.number, assignment_group: inputs.assignment_group },
purpose: inputs.reason
});
if (!verdict.allowed) return verdict.message;
// ... the tool's own work
})(inputs);Subflow or flow action tool: a Flow Designer action Intertrace guard (inputs agent_id, tool, operation, arguments_json, purpose; outputs allowed, message) with this Script step, as the first step, and an If that ends the subflow with message when allowed is false:
(function execute(inputs, outputs) {
var verdict = new IntertraceGuard().check({
agentId: inputs.agent_id,
tool: inputs.tool,
operation: inputs.operation || 'write',
arguments: inputs.arguments_json,
purpose: inputs.purpose
});
outputs.allowed = verdict.allowed === true;
outputs.message = verdict.message;
})(inputs, outputs);A record-operation (CRUD) tool runs a script ServiceNow generates: replace it with a script tool that calls the guard first. Keep tools that change records on Supervised as well; ServiceNow's confirmation and Intertrace's approval are separate.
Discovery reads a script tool that calls IntertraceGuard as guarded. It can't see inside flows; the agent shows as protected once the guard's first check reaches Intertrace.
Audit on the ServiceNow side
sn_aia_execution_plan (one per request), sn_aia_execution_task (its steps), sn_aia_tools_execution (tools run, kept 13 months) and sn_aia_message hold what the agent did inside ServiceNow. Intertrace records each check the guard makes on the agent's Activity and in Runtime.