fix(agents): align sandboxed ACP prompt guidance

This commit is contained in:
Peter Steinberger
2026-03-02 23:23:56 +00:00
parent 3bf19d6f40
commit c703aa0fe9
3 changed files with 8 additions and 5 deletions

View File

@@ -295,6 +295,8 @@ describe("buildAgentSystemPrompt", () => {
},
});
expect(prompt).not.toContain('runtime="acp" requires `agentId`');
expect(prompt).not.toContain("ACP harness ids follow acp.allowedAgents");
expect(prompt).not.toContain(
'For requests like "do this in codex/claude code/gemini", treat it as ACP harness intent',
);

View File

@@ -233,6 +233,8 @@ export function buildAgentSystemPrompt(params: {
memoryCitationsMode?: MemoryCitationsMode;
}) {
const acpEnabled = params.acpEnabled !== false;
const sandboxedRuntime = params.sandboxInfo?.enabled === true;
const acpSpawnRuntimeEnabled = acpEnabled && !sandboxedRuntime;
const coreToolSummaries: Record<string, string> = {
read: "Read file contents",
write: "Create or overwrite files",
@@ -252,13 +254,13 @@ export function buildAgentSystemPrompt(params: {
cron: "Manage cron jobs and wake events (use for reminders; when scheduling a reminder, write the systemEvent text as something that will read like a reminder when it fires, and mention that it is a reminder depending on the time gap between setting and firing; include recent context in reminder text if appropriate)",
message: "Send messages and channel actions",
gateway: "Restart, apply config, or run updates on the running OpenClaw process",
agents_list: acpEnabled
agents_list: acpSpawnRuntimeEnabled
? 'List OpenClaw agent ids allowed for sessions_spawn when runtime="subagent" (not ACP harness ids)'
: "List OpenClaw agent ids allowed for sessions_spawn",
sessions_list: "List other sessions (incl. sub-agents) with filters/last",
sessions_history: "Fetch history for another session/sub-agent",
sessions_send: "Send a message to another session/sub-agent",
sessions_spawn: acpEnabled
sessions_spawn: acpSpawnRuntimeEnabled
? 'Spawn an isolated sub-agent or ACP coding session (runtime="acp" requires `agentId` unless `acp.defaultAgent` is configured; ACP harness ids follow acp.allowedAgents, not agents_list)'
: "Spawn an isolated sub-agent session",
subagents: "List, steer, or kill sub-agent runs for this requester session",
@@ -310,8 +312,7 @@ export function buildAgentSystemPrompt(params: {
const normalizedTools = canonicalToolNames.map((tool) => tool.toLowerCase());
const availableTools = new Set(normalizedTools);
const hasSessionsSpawn = availableTools.has("sessions_spawn");
const sandboxedRuntime = params.sandboxInfo?.enabled === true;
const acpHarnessSpawnAllowed = hasSessionsSpawn && acpEnabled && !sandboxedRuntime;
const acpHarnessSpawnAllowed = hasSessionsSpawn && acpSpawnRuntimeEnabled;
const externalToolSummaries = new Map<string, string>();
for (const [key, value] of Object.entries(params.toolSummaries ?? {})) {
const normalized = key.trim().toLowerCase();