Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

feat(acp): let a Custom ACP engine opt in to /steer steering

Devin AI390cb881f068
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.ts
index c9d70b995b..2c4b050384 100644
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@ -86,6 +86,8 @@ export interface AcpConfig {
cli: string;
fullAuto: boolean;
workspace?: string;
+ /** Custom ACP only: the agent advertises a `steer` command and answers `/steer <text>` during a turn as Hermes does. */
+ steer?: boolean;
}
/** Per-CLI specifics plugged into the shared ACP runtime; `askTool` is the native tool `questionRequests` come from. */
diff --git a/server/drivers/acp/custom.ts b/server/drivers/acp/custom.ts
index 40564e6b10..b379385ac3 100644
--- a/server/drivers/acp/custom.ts
+++ b/server/drivers/acp/custom.ts
@@ -2,10 +2,14 @@
// { "instances": { "my-agent": {
// "driver": "customAcp",
// "displayName": "My Agent",
-// "config": { "cli": "my-agent acp" } } } }
+// "config": { "cli": "my-agent acp", "steer": true } } } }
// `cli` is the whole command ("npx -y some-agent acp" works). No auth step: the CLI is signed in from
// a terminal. Model selection uses ACP, never -m on argv, since conventions differ per CLI.
+// `steer` (off by default) is for an agent that takes a message into its running turn the way Hermes does: it
+// advertises a `steer` command and answers `/steer <text>` with Hermes's lines. Until the session advertises the
+// command, a message sent mid-turn waits for the next turn as it does without the flag.
import { createAcpDriver, type AcpSupport } from "./core.ts";
+import { hermesSteerAnswer } from "./hermes.ts";
import { resolveCustomAcpModels } from "./custom-model-catalog.ts";
const CONFIGURE_HINT =
@@ -30,18 +34,22 @@ const support: AcpSupport = {
};
const base = createAcpDriver(support);
+const STEER = { command: "steer", answer: hermesSteerAnswer };
export const CustomAcpDriver: typeof base = {
...base,
decodeConfig(raw) {
const decoded = base.decodeConfig(raw);
if (!decoded.cli.trim()) throw new Error(CONFIGURE_HINT);
- return decoded;
+ return (raw as { steer?: unknown } | null)?.steer === true ? { ...decoded, steer: true } : decoded;
},
async create(input) {
if (!input.config.cli.trim()) throw new Error(CONFIGURE_HINT);
// What the person reads names their agent ("My Agent"), never "Custom (ACP)".
const name = input.displayName?.trim();
- return (name ? createAcpDriver({ ...support, displayName: name }) : base).create(input);
+ const steer = input.config.steer === true;
+ return (name || steer
+ ? createAcpDriver({ ...support, ...(name ? { displayName: name } : {}), ...(steer ? { steer: STEER } : {}) })
+ : base).create(input);
},
};
diff --git a/server/drivers/acp/hermes-steer.test.ts b/server/drivers/acp/hermes-steer.test.ts
index d87e9ba78c..8d3ffaca4c 100644
--- a/server/drivers/acp/hermes-steer.test.ts
+++ b/server/drivers/acp/hermes-steer.test.ts
@@ -56,13 +56,13 @@ const fixtureEnv = (extra: Record<string, string> = {}) => ({
...extra,
});
-const start = async (driver: AnyProviderDriver, extra: Record<string, string> = {}) => {
+const start = async (driver: AnyProviderDriver, extra: Record<string, string> = {}, config: Record<string, unknown> = {}) => {
instance = await driver.create({
instanceId: `steer-${driver.driverKind}`,
displayName: "Steer fixture",
enabled: true,
environment: fixtureEnv(extra),
- config: { cli: FAKE_CLI, fullAuto: true },
+ config: { cli: FAKE_CLI, fullAuto: true, ...config },
} as never) as ProviderInstance;
recorder = recordEvents(instance.adapter);
return instance;
@@ -214,3 +214,37 @@ describe("other ACP engines", () => {
expect(replyOf(turnId)).toEqual(["working. done"]);
});
});
+
+describe("Custom ACP steering, opted in with \"steer\": true", () => {
+ it("is off unless the config says true", () => {
+ expect(CustomAcpDriver.decodeConfig({ cli: "agent acp" }).steer).toBeUndefined();
+ expect(CustomAcpDriver.decodeConfig({ cli: "agent acp", steer: "yes" }).steer).toBeUndefined();
+ expect(CustomAcpDriver.decodeConfig({ cli: "agent acp", steer: true }).steer).toBe(true);
+ });
+
+ it("steers through the agent's /steer like Hermes, and keeps its line out of the reply", async () => {
+ await start(CustomAcpDriver, { FAKE_ACP_GATE_FILE: gate() }, { steer: true });
+ expect(instance!.adapter.capabilities.queueing).toBe(true);
+ const turnId = await runningTurn();
+ expect(await instance!.adapter.steer!(threadId, "Use pytest.")).toBe("steered");
+ expect(sentPrompts()).toEqual(["session/prompt", "session/prompt", "session/prompt.steer"]);
+ await finished(turnId);
+ expect(replyOf(turnId)).toEqual(["working. done; steered: Use pytest."]);
+ });
+
+ it("refuses what the agent says it could not steer", async () => {
+ await start(CustomAcpDriver, { FAKE_ACP_GATE_FILE: gate(), FAKE_ACP_STEER_FAIL: "1" }, { steer: true });
+ const turnId = await runningTurn();
+ expect(await instance!.adapter.steer!(threadId, "use pytest")).toBe("refused");
+ await finished(turnId);
+ expect(replyOf(turnId)).toEqual(["working. done"]);
+ });
+
+ it("sends nothing to a session that does not offer steer, so the message waits for the next turn", async () => {
+ await start(CustomAcpDriver, { FAKE_ACP_GATE_FILE: gate(), FAKE_ACP_HERMES_COMMANDS: "help" }, { steer: true });
+ const turnId = await runningTurn();
+ expect(await instance!.adapter.steer!(threadId, "use pytest")).toBe("refused");
+ await finished(turnId);
+ expect(sentPrompts()).toEqual(["session/prompt"]);
+ });
+});