Repository navigation
Replies: 1 comment
|
You can't inject it through the constructor, because the sandbox filesystem doesn't exist yet when you build your tool. Let the tool receive the sandbox per call through Why: So declare a public class MyTool {
@Tool(description = "Run a command in the sandbox")
public ToolResultBlock run(
RuntimeContext rc,
@ToolParam(name = "command", description = "Shell command") String command) throws Exception {
SandboxAcquireResult acq = rc == null ? null : rc.get(SandboxAcquireResult.class);
if (acq == null || acq.isReleased()) {
return ToolResultBlock.error("No active sandbox for this call");
}
ExecResult r = acq.getSandbox().exec(rc, command, 30);
return ToolResultBlock.text("exit=" + r.exitCode() + "\n" + r.combinedOutput());
}
}
Check the (I looked this up in the code with help from an AI assistant; the links are to the lines I checked.) |
Uh oh!
There was an error while loading. Please reload this page.
public class ShellExecuteTool {
public static final String NAME = "execute";
private final AbstractSandboxFilesystem sandbox;
All reactions