fix(exec): apply per-agent exec defaults for opaque session keys

Co-authored-by: brin-tapcart <brin-tapcart@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-02-22 23:32:00 +01:00
parent 427b4360b9
commit 394a1af70f
9 changed files with 90 additions and 19 deletions

View File

@@ -690,4 +690,44 @@ describe("Agent-specific tool filtering", () => {
}),
).rejects.toThrow("exec host=sandbox is configured");
});
it("applies explicit agentId exec defaults when sessionKey is opaque", async () => {
const cfg: OpenClawConfig = {
tools: {
exec: {
host: "sandbox",
security: "full",
ask: "off",
},
},
agents: {
list: [
{
id: "main",
tools: {
exec: {
host: "gateway",
},
},
},
],
},
};
const tools = createOpenClawCodingTools({
config: cfg,
agentId: "main",
sessionKey: "run-opaque-123",
workspaceDir: "/tmp/test-main-opaque-session",
agentDir: "/tmp/agent-main-opaque-session",
});
const execTool = tools.find((tool) => tool.name === "exec");
expect(execTool).toBeDefined();
const result = await execTool!.execute("call-main-opaque-session", {
command: "echo done",
yieldMs: 1000,
});
const details = result?.details as { status?: string } | undefined;
expect(details?.status).toBe("completed");
});
});