SandboxedSkillScriptRunner
AgentPrism.Core.dllAgentPrism’s single script execution path, which runs skill scripts in an isolated operating-system process.
public sealed class SandboxedSkillScriptRunner : IDisposableInheritance
Section titled “Inheritance”object ← SandboxedSkillScriptRunner
Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Microsoft Agent Framework never runs a script on its own.
AgentFileSkillScriptRunner is a call point; the sandbox, timeout,
resource limits, and audit trail are entirely AgentPrism’s responsibility.
Every run passes through these gates in order. If one is closed, the script never starts at all:
- Is the feature enabled (AgentPrismSkillScriptOptions.Enabled)
- Is there a valid SkillScriptGrant for the tenant
- Is the extension on the interpreter allow-list
- Did the arguments pass size and schema validation
- Was the audit trail entry written
The last item is a deliberate exception to the “observability does not break functionality” rule: a script run that cannot be written to the audit trail would be a remote code execution with no record at all.
MAF’s approval flow stays active: DisableRunSkillScriptApproval is
not set, meaning every script call waits for user approval first.
Constructors
Section titled “Constructors”SandboxedSkillScriptRunner(IOptions<AgentPrismOptions>, ITenantContext, ISkillScriptGrantStore, IAuditLog, IAuditActorResolver, ILogger<SandboxedSkillScriptRunner>, IRunStore?, AgentPrismMetrics?, TimeProvider?)
Section titled “ SandboxedSkillScriptRunner(IOptions<AgentPrismOptions>, ITenantContext, ISkillScriptGrantStore, IAuditLog, IAuditActorResolver, ILogger<SandboxedSkillScriptRunner>, IRunStore?, AgentPrismMetrics?, TimeProvider?)”Creates a new runner.
public SandboxedSkillScriptRunner(IOptions<AgentPrismOptions> options, ITenantContext tenantContext, ISkillScriptGrantStore grantStore, IAuditLog auditLog, IAuditActorResolver actorResolver, ILogger<SandboxedSkillScriptRunner> logger, IRunStore? runStore = null, AgentPrismMetrics? metrics = null, TimeProvider? timeProvider = null)Parameters
Section titled “Parameters”options IOptions<AgentPrismOptions>
The AgentPrism settings.
tenantContext ITenantContext
The tenant context.
grantStore ISkillScriptGrantStore
The grant record store.
auditLog IAuditLog
The audit trail.
actorResolver IAuditActorResolver
The actor resolver.
logger ILogger<SandboxedSkillScriptRunner>
The logger.
runStore IRunStore?
The store the tool call record is written to. Not written if null.
metrics AgentPrismMetrics?
The metrics instruments. No metrics are emitted if null.
timeProvider TimeProvider?
The time source. The system clock is used if null.
Exceptions
Section titled “Exceptions”One of the required dependencies is null.
Methods
Section titled “Methods”Dispose()
Section titled “ Dispose()”public void Dispose()RunFileScriptAsync(AgentFileSkill, AgentFileSkillScript, JsonElement?, IServiceProvider?, CancellationToken)
Section titled “ RunFileScriptAsync(AgentFileSkill, AgentFileSkillScript, JsonElement?, IServiceProvider?, CancellationToken)”Runs a skill script from disk. Wired to MAF’s
AgentFileSkillScriptRunner delegate.
public Task<object?> RunFileScriptAsync(AgentFileSkill skill, AgentFileSkillScript script, JsonElement? arguments, IServiceProvider? serviceProvider, CancellationToken cancellationToken)Parameters
Section titled “Parameters”skill AgentFileSkill
The skill that carries the script.
script AgentFileSkillScript
The script to run.
arguments JsonElement?
The arguments produced by the model.
serviceProvider IServiceProvider?
The service provider given by MAF. Not used.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The text result to return to the model.
Exceptions
Section titled “Exceptions”One of the gates is closed.
RunStoredScriptAsync(string, AgentSkillScriptDefinition, JsonElement?, CancellationToken)
Section titled “ RunStoredScriptAsync(string, AgentSkillScriptDefinition, JsonElement?, CancellationToken)”Runs a skill script stored in the database.
public Task<object?> RunStoredScriptAsync(string skillName, AgentSkillScriptDefinition script, JsonElement? arguments, CancellationToken cancellationToken)Parameters
Section titled “Parameters”skillName string
The skill’s name.
script AgentSkillScriptDefinition
The script definition.
arguments JsonElement?
The arguments produced by the model.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The text result to return to the model.
Remarks
Section titled “Remarks”This path is used only when AgentPrismSkillScriptOptions.AllowStoredScripts is enabled. The content is written to a temporary directory accessible only to its owner, only for the duration of the run, and deleted afterward.
Exceptions
Section titled “Exceptions”One of the gates is closed.