🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(heterogeneous-agents): always run Devin ACP sessions in bypass mode (#22913)
Lobehub Coderdde1824f8bec
diff --git a/apps/cli/src/commands/hetero.test.ts b/apps/cli/src/commands/hetero.test.tsindex f5b8e972d49..283edb13e8f 100644--- a/apps/cli/src/commands/hetero.test.ts+++ b/apps/cli/src/commands/hetero.test.ts@@ -772,10 +772,10 @@ describe('hetero exec command', () => {command: 'devin',extraArgs: ['--agent-type', 'coding', '--model', 'claude-sonnet-4-6-thinking'],initialModel: 'claude-sonnet-4-6-thinking',- permissionMode: 'bypass',prompt: 'do thing',}),);+ expect(mockSpawnAgent.mock.calls[0]?.[0]).not.toHaveProperty('permissionMode');});it('runs TRAE Enterprise with ACP model selection and only native provider arguments', async () => {@@ -1167,9 +1167,9 @@ describe('hetero exec command', () => {expect.objectContaining({agentType: 'devin',askUserBridge: expect.objectContaining({ pending: expect.any(Function) }),- permissionMode: 'bypass',}),);+ expect(mockSpawnAgent.mock.calls[0]?.[0]).not.toHaveProperty('permissionMode');});it('runs OpenCode with model, resume, and native args while ignoring effort and speed', async () => {diff --git a/apps/cli/src/commands/hetero.ts b/apps/cli/src/commands/hetero.tsindex b0d9d492d15..64692e5007c 100644--- a/apps/cli/src/commands/hetero.ts+++ b/apps/cli/src/commands/hetero.ts@@ -1248,11 +1248,6 @@ const exec = async (options: ExecOptions): Promise<void> => {pathEnv: resolvedCommand.pathEnv,topicId: options.topic,});- // Devin ACP's `--permission-mode` is a global flag; default to bypass so- // headless connected-device runs do not block on permission prompts. The mode- // response must not overwrite the model selected by `initialModel`.- const permissionMode = options.type === 'devin' ? 'bypass' : undefined;-const spawnOptions = {agentType: options.type,askUserBridge: askBridge,@@ -1271,7 +1266,6 @@ const exec = async (options: ExecOptions): Promise<void> => {// early makes print mode kill background tasks after 10 minutes.liveInput: options.type === 'claude-code',operationId,- permissionMode,uploadImage,};diff --git a/packages/heterogeneous-agents/src/spawn/acpSpawnAgent.ts b/packages/heterogeneous-agents/src/spawn/acpSpawnAgent.tsindex a555d1985bd..89a34d04022 100644--- a/packages/heterogeneous-agents/src/spawn/acpSpawnAgent.ts+++ b/packages/heterogeneous-agents/src/spawn/acpSpawnAgent.ts@@ -272,7 +272,6 @@ export const spawnDevinAcpAgent = async (env: { ...process.env, ...options.env },initialModel: options.initialModel,onEvents: bridge.onEvents,- permissionMode: options.permissionMode,onRawMessage: teeAcpRawStdout(options.onRawStdout),onRuntimeStatus: () => {},onSessionId: () => {},diff --git a/packages/heterogeneous-agents/src/spawn/devinAcpSession.test.ts b/packages/heterogeneous-agents/src/spawn/devinAcpSession.test.tsindex 912fbcac018..28a443ec4f8 100644--- a/packages/heterogeneous-agents/src/spawn/devinAcpSession.test.ts+++ b/packages/heterogeneous-agents/src/spawn/devinAcpSession.test.ts@@ -34,16 +34,20 @@ const createAcpProcess = ({configOptions,configOptionsByModel,configUpdateOnPrompt,+ configUpdateOnPromptCount = 1,initializeResult,loadError,+ modeSetError,permissionRequest = false,promptAutoComplete = true,}: {configOptions?: Record<string, unknown>[];configOptionsByModel?: Record<string, Record<string, unknown>[]>;configUpdateOnPrompt?: Record<string, unknown>[];+ configUpdateOnPromptCount?: number;initializeResult?: Record<string, unknown>;loadError?: { code: number; data?: unknown; message: string };+ modeSetError?: { code: number; data?: unknown; message: string };permissionRequest?: boolean;promptAutoComplete?: boolean;} = {}) => {@@ -121,6 +125,10 @@ const createAcpProcess = ({}case 'session/set_config_option': {const params = message.params as { configId?: string; value?: string } | undefined;+ if (params?.configId === 'mode' && modeSetError) {+ send({ error: modeSetError, id: message.id });+ return;+ }if (params?.configId === 'model' && params.value) {configOptions = configOptionsByModel?.[params.value] ?? configOptions;}@@ -151,7 +159,7 @@ const createAcpProcess = ({}case 'session/prompt': {promptRequest = message;- if (configUpdateOnPrompt) {+ for (let i = 0; configUpdateOnPrompt && i < configUpdateOnPromptCount; i += 1) {send({method: 'session/update',params: {@@ -346,6 +354,7 @@ describe('DevinAcpSession', () => {expect(fake.requests.map(({ method }) => method).filter(Boolean)).toEqual(['initialize','session/new',+ 'session/set_config_option','session/prompt',]);expect(options.onSessionId).toHaveBeenCalledWith('devin-session-1');@@ -470,11 +479,11 @@ describe('DevinAcpSession', () => {});});- it('sets the ACP session mode when a permission mode is configured', async () => {+ it('forces the bypass ACP session mode without any permission parameters', async () => {const fake = createAcpProcess();spawnMock.mockReturnValue(fake.child);vi.spyOn(process, 'kill').mockImplementation(() => true);- const options = createSessionOptions({ permissionMode: 'bypass' });+ const options = createSessionOptions();await new DevinAcpSession(options).run();@@ -499,17 +508,40 @@ describe('DevinAcpSession', () => {expect(options.onSessionId).toHaveBeenCalledWith('devin-session-1');});- it('lets a user-supplied --permission-mode in args override the default', async () => {+ it('forces bypass in the desktop direct-ACP shape (no args, no permission options)', async () => {+ const fake = createAcpProcess();+ spawnMock.mockReturnValue(fake.child);+ vi.spyOn(process, 'kill').mockImplementation(() => true);+ // Mirrors apps/desktop heterogeneousAgentSession: `new DevinAcpSession({...})`+ // with no permission-related input at all.+ const options = createSessionOptions({ args: [] });++ await new DevinAcpSession(options).run();++ expect(spawnMock).toHaveBeenCalledWith(+ 'devin',+ ['acp'],+ expect.objectContaining({ cwd: '/workspace' }),+ );+ expect(+ fake.requests+ .filter(({ method }) => method === 'session/set_config_option')+ .map(({ params }) => params),+ ).toEqual([{ configId: 'mode', sessionId: 'devin-session-1', value: 'bypass' }]);+ expect(options.onSessionId).toHaveBeenCalledWith('devin-session-1');+ });++ it('does not let a --permission-mode in args change the ACP session mode', async () => {const fake = createAcpProcess();spawnMock.mockReturnValue(fake.child);vi.spyOn(process, 'kill').mockImplementation(() => true);const options = createSessionOptions({args: ['--permission-mode', 'dangerous', '--model', 'sonnet'],- permissionMode: 'bypass',});await new DevinAcpSession(options).run();+ // The CLI flag is still forwarded unchanged, but it has no effect on ACP.expect(spawnMock).toHaveBeenCalledWith('devin',['--permission-mode', 'dangerous', 'acp', '--model', 'sonnet'],@@ -520,18 +552,92 @@ describe('DevinAcpSession', () => {).toEqual({configId: 'mode',sessionId: 'devin-session-1',- value: 'dangerous',+ value: 'bypass',+ });+ });++ it('still establishes the session when setting the session mode fails', async () => {+ const fake = createAcpProcess({+ modeSetError: { code: -32_602, message: 'Invalid mode: bypass' },+ });+ spawnMock.mockReturnValue(fake.child);+ vi.spyOn(process, 'kill').mockImplementation(() => true);+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const options = createSessionOptions({ initialModel: 'glm-5-2' });++ await expect(new DevinAcpSession(options).run()).resolves.not.toThrow();++ expect(fake.requests.map(({ method }) => method).filter(Boolean)).toEqual([+ 'initialize',+ 'session/new',+ 'session/set_config_option',+ 'session/set_config_option',+ 'session/prompt',+ ]);+ expect(+ fake.requests.filter(({ method }) => method === 'session/set_config_option')[1]?.params,+ ).toEqual({ configId: 'mode', sessionId: 'devin-session-1', value: 'bypass' });+ expect(warn).toHaveBeenCalledWith(+ expect.stringContaining('Failed to set session mode "bypass"'),+ {+ error: expect.any(AcpRpcResponseError),+ operationId: 'operation-1',+ sessionId: 'devin-session-1',+ },+ );+ expect(options.onSessionId).toHaveBeenCalledWith('devin-session-1');+ expect(options.onModel).toHaveBeenCalledWith('glm-5-2');+ });++ it('re-asserts bypass once when a config update reports a different mode', async () => {+ const fake = createAcpProcess({+ configUpdateOnPrompt: [{ currentValue: 'accept-edits', id: 'mode' }],+ configUpdateOnPromptCount: 2,+ });+ spawnMock.mockReturnValue(fake.child);+ vi.spyOn(process, 'kill').mockImplementation(() => true);+ const options = createSessionOptions();++ await new DevinAcpSession(options).run();+ // The re-assert is fire-and-forget; let its write land.+ await new Promise((resolve) => setTimeout(resolve, 0));++ const modeRequests = fake.requests.filter(+ ({ method, params }) => method === 'session/set_config_option' && params?.configId === 'mode',+ );+ // 1 from establishSession + exactly 1 re-assert, despite two drifted updates.+ expect(modeRequests.map(({ params }) => params)).toEqual([+ { configId: 'mode', sessionId: 'devin-session-1', value: 'bypass' },+ { configId: 'mode', sessionId: 'devin-session-1', value: 'bypass' },+ ]);+ const promptIndex = fake.requests.findIndex(({ method }) => method === 'session/prompt');+ expect(fake.requests.indexOf(modeRequests[1]!)).toBeGreaterThan(promptIndex);+ });++ it('does not re-assert the mode when a config update already reports bypass', async () => {+ const fake = createAcpProcess({+ configUpdateOnPrompt: [{ currentValue: 'bypass', id: 'mode' }],+ configUpdateOnPromptCount: 2,});+ spawnMock.mockReturnValue(fake.child);+ vi.spyOn(process, 'kill').mockImplementation(() => true);++ await new DevinAcpSession(createSessionOptions()).run();+ await new Promise((resolve) => setTimeout(resolve, 0));++ expect(+ fake.requests.filter(+ ({ method, params }) =>+ method === 'session/set_config_option' && params?.configId === 'mode',+ ),+ ).toHaveLength(1);});it('sets the ACP session mode on a resumed session', async () => {const fake = createAcpProcess();spawnMock.mockReturnValue(fake.child);vi.spyOn(process, 'kill').mockImplementation(() => true);- const options = createSessionOptions({- permissionMode: 'bypass',- resumeSessionId: 'saved-session',- });+ const options = createSessionOptions({ resumeSessionId: 'saved-session' });await new DevinAcpSession(options).run();@@ -562,6 +668,7 @@ describe('DevinAcpSession', () => {'initialize','session/new','session/set_config_option',+ 'session/set_config_option','session/prompt',]);expect(@@ -600,18 +707,19 @@ describe('DevinAcpSession', () => {await new DevinAcpSession(options).run();- expect(fake.requests.map(({ method }) => method).filter(Boolean)).toEqual([- 'initialize',- 'session/new',- 'session/prompt',- ]);+ // Only the forced session mode is set; the model is left untouched.+ expect(+ fake.requests+ .filter(({ method }) => method === 'session/set_config_option')+ .map(({ params }) => params?.configId),+ ).toEqual(['mode']);});- it('sets both permission mode and model when both are configured', async () => {+ it('sets the model first and then the forced bypass mode', async () => {const fake = createAcpProcess();spawnMock.mockReturnValue(fake.child);vi.spyOn(process, 'kill').mockImplementation(() => true);- const options = createSessionOptions({ initialModel: 'glm-5-2', permissionMode: 'bypass' });+ const options = createSessionOptions({ initialModel: 'glm-5-2' });await new DevinAcpSession(options).run();@@ -687,7 +795,7 @@ describe('DevinAcpSession', () => {fake.requests.filter(({ method }) => method === 'session/set_config_option').map(({ params }) => [params?.configId, params?.value]),- ).toEqual(expectedChanges);+ ).toEqual([...expectedChanges, ['mode', 'bypass']]);expect(options.onModel).toHaveBeenLastCalledWith(initialModel);expect(fake.requests.at(-1)?.method).toBe('session/prompt');},diff --git a/packages/heterogeneous-agents/src/spawn/devinAcpSession.ts b/packages/heterogeneous-agents/src/spawn/devinAcpSession.tsindex a93b50926f1..0daae6e4161 100644--- a/packages/heterogeneous-agents/src/spawn/devinAcpSession.ts+++ b/packages/heterogeneous-agents/src/spawn/devinAcpSession.ts@@ -16,6 +16,9 @@ import { buildTraeAcpPrompt, parseTraeAcpModelCatalog } from './traeAcpSession';const TRANSPORT = 'devin-acp' as const;+// LobeHub 内的 Devin 会话模式不对外暴露:恒为 bypass。+const DEVIN_FORCED_SESSION_MODE = 'bypass';+// Devin's CLI exposes thinking variants, while ACP exposes one representative// model per family plus `thought_level`. Fusion IDs also contain a sidekick's// effort, so they must not be interpreted as a single-model thinking variant.@@ -29,6 +32,11 @@ const getThinkingConfig = (configOptions: unknown) =>? configOptions.filter(isRecord).find((option) => option.id === 'thought_level'): undefined;+const getModeConfigValue = (configOptions: unknown): unknown =>+ Array.isArray(configOptions)+ ? configOptions.filter(isRecord).find((option) => option.id === 'mode')?.currentValue+ : undefined;+export type DevinAcpTextPromptBlock = TraeAcpTextPromptBlock;export type DevinAcpImagePromptBlock = TraeAcpImagePromptBlock;export type DevinAcpPromptBlock = TraeAcpPromptBlock;@@ -82,8 +90,6 @@ export interface DevinAcpSessionOptions extends AcpAgentSessionOptions {askUserBridge?: AskUserBridge;initialModel?: string;onModel?: (model: string) => void;- /** Devin ACP permission mode, applied via `session/set_config_option`. */- permissionMode?: string;prompt: DevinAcpPromptBlock[];}@@ -132,18 +138,15 @@ export class DevinAcpSession extends AcpAgentSession<DevinAcpSessionOptions> {private acceptUpdates = false;- private readonly resolvedPermissionMode?: string;+ private modeReasserted = false;constructor(options: DevinAcpSessionOptions) {- const devinArgs = buildDevinAcpArgs(options.args);super(options, {- args: devinArgs,+ args: buildDevinAcpArgs(options.args),pipeline: { agentType: 'devin', cwd: options.cwd },processLabel: 'Devin ACP',transport: TRANSPORT,});- this.resolvedPermissionMode =- devinArgs[0] === '--permission-mode' ? devinArgs[1] : (options.permissionMode ?? undefined);}get sessionId(): string | undefined {@@ -196,15 +199,10 @@ export class DevinAcpSession extends AcpAgentSession<if (!sessionId) throw new Error('Devin ACP returned no session id');const model = await this.applyInitialModel(sessionId, sessionResult);- if (this.resolvedPermissionMode) {- await this.client.request<DevinAcpSetConfigOptionResult>('session/set_config_option', {- configId: 'mode',- sessionId,- value: this.resolvedPermissionMode,- });- // Permission mode should not clobber the model selected above. The model- // resolved from the model set_config_option is authoritative.- }+ // The forced session mode is applied after the model and must not clobber+ // the model selected above: the model resolved from the model+ // set_config_option stays authoritative.+ await this.applyForcedSessionMode(sessionId);if (model) {this.pipeline.configureSession({ model });this.options.onModel?.(model);@@ -254,10 +252,55 @@ export class DevinAcpSession extends AcpAgentSession<this.pipeline.configureSession({ model });this.options.onModel?.(model);}+ this.reassertForcedSessionMode(update.configOptions);}await this.pushToPipeline(update);}+ /**+ * `--permission-mode` has no effect on Devin ACP sessions (they always start+ * in `accept-edits`), so the mode is forced through `session/set_config_option`.+ * A failure only degrades to Devin's default mode; it must never prevent the+ * session from starting.+ */+ private async applyForcedSessionMode(sessionId: string): Promise<void> {+ try {+ await this.client.request<DevinAcpSetConfigOptionResult>('session/set_config_option', {+ configId: 'mode',+ sessionId,+ value: DEVIN_FORCED_SESSION_MODE,+ });+ } catch (error) {+ // Kept on console.warn rather than a `debug` namespace on purpose: a+ // silent fallback to Devin's default (approval-gated) mode must be+ // visible without opting into DEBUG, like the package's other degraded+ // paths. The ids let concurrent desktop / CLI sessions be told apart.+ console.warn(+ `[DevinAcpSession] Failed to set session mode "${DEVIN_FORCED_SESSION_MODE}"; continuing with Devin's default mode:`,+ { error, operationId: this.options.operationId, sessionId },+ );+ }+ }++ /**+ * Devin pushes `config_option_update` whenever a config changes. If the mode+ * drifted away from the forced value, set it back — once per session, so a+ * peer that rejects the value but keeps echoing updates cannot cause a+ * set → update → set loop.+ */+ private reassertForcedSessionMode(configOptions: unknown): void {+ const mode = getModeConfigValue(configOptions);+ if (mode === undefined || mode === DEVIN_FORCED_SESSION_MODE || this.modeReasserted) return;++ const sessionId = this.acpSessionId;+ if (!sessionId) return;++ this.modeReasserted = true;+ // Fire-and-forget: this runs on the ACP client's serial message queue, and+ // the response is resolved on that same queue, so awaiting here would deadlock.+ void this.applyForcedSessionMode(sessionId);+ }+protected async handleServerRequest(message: AcpRpcMessage): Promise<unknown> {if (message.method !== 'session/request_permission') {throw new AcpServerRequestError(-32_601, `Unsupported ACP client request: ${message.method}`);diff --git a/packages/heterogeneous-agents/src/spawn/spawnAgent.test.ts b/packages/heterogeneous-agents/src/spawn/spawnAgent.test.tsindex aa0e658b587..547bc8cf2a5 100644--- a/packages/heterogeneous-agents/src/spawn/spawnAgent.test.ts+++ b/packages/heterogeneous-agents/src/spawn/spawnAgent.test.ts@@ -616,6 +616,7 @@ describe('spawnAgent', () => {'initialize','session/new','session/set_config_option',+ 'session/set_config_option','session/prompt',]);expect(@@ -632,7 +633,7 @@ describe('spawnAgent', () => {}});- it('applies a permission mode through ACP session/set_config_option', async () => {+ it('forces the Devin bypass session mode through ACP session/set_config_option', async () => {const fake = createFakeAcpProc({responseText: 'Devin response',sessionId: 'devin-session-1',@@ -647,7 +648,6 @@ describe('spawnAgent', () => {extraArgs: ['--model', 'sonnet'],initialModel: 'sonnet',operationId: 'op-devin',- permissionMode: 'bypass',prompt: 'do a thing',});const events = [];diff --git a/packages/heterogeneous-agents/src/spawn/spawnAgent.ts b/packages/heterogeneous-agents/src/spawn/spawnAgent.tsindex 93c09b2ccec..77df323fc9c 100644--- a/packages/heterogeneous-agents/src/spawn/spawnAgent.ts+++ b/packages/heterogeneous-agents/src/spawn/spawnAgent.ts@@ -92,8 +92,6 @@ export interface SpawnAgentOptions {* events still carry the conventional shape.*/operationId: string;- /** (Devin ACP only) Global `--permission-mode` value, placed before `acp`. */- permissionMode?: string;/*** User prompt. A plain string is sugar for a single text block; the array* form supports mixed text + image content blocks (URL / path / base64).