Skip to content

SandboxedSkillScriptRunner

Namespace AgentPrism · Assembly AgentPrism.Core.dll

AgentPrism’s single script execution path, which runs skill scripts in an isolated operating-system process.

public sealed class SandboxedSkillScriptRunner : IDisposable

objectSandboxedSkillScriptRunner

IDisposable

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

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:

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.

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)

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.

ArgumentNullException

One of the required dependencies is null.

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)

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.

Task<object?>

The text result to return to the model.

AgentPrismException

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)

skillName string

The skill’s name.

script AgentSkillScriptDefinition

The script definition.

arguments JsonElement?

The arguments produced by the model.

cancellationToken CancellationToken

The cancellation token.

Task<object?>

The text result to return to the model.

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.

AgentPrismException

One of the gates is closed.