Class SandboxedExecution
java.lang.Object
com.tnsai.coordination.supervisor.SandboxedExecution
Runs agent actions in a sandboxed context with resource limits.
SandboxedExecution provides a way to execute agent tasks with constraints such as timeouts and action allow-lists. This prevents runaway agents from consuming excessive resources or performing unauthorized operations.
Usage Example
SandboxConfig config = new SandboxConfig(
Duration.ofSeconds(30), // timeout
64 * 1024 * 1024, // 64MB memory limit
Set.of("search", "read"), // allowed actions
true // read-only
);
SandboxResult result = SandboxedExecution.execute(agent, "Analyze this data", config);
if (result.completed()) {
System.out.println(result.result());
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordConfiguration for sandboxed execution.static final recordResult of a sandboxed execution. -
Method Summary
Modifier and TypeMethodDescriptionexecute(com.tnsai.agents.Agent agent, String task, SandboxedExecution.SandboxConfig config) Executes an agent task in a sandboxed context.
-
Method Details
-
execute
public static SandboxedExecution.SandboxResult execute(com.tnsai.agents.Agent agent, String task, SandboxedExecution.SandboxConfig config) Executes an agent task in a sandboxed context.The task is run in a separate thread with the configured timeout. If the timeout is exceeded, the execution is interrupted and a failed result is returned.
- Parameters:
agent- the agent to execute the tasktask- the task prompt to send to the agentconfig- sandbox configuration- Returns:
- result of the execution
- Throws:
NullPointerException- if any argument is null
-