Skip to content

🤯 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.

🐛 fix(antigravity): show ACP question cards and validate thinking levels (#23782)

Mocha4be931285b05
diff --git a/apps/cli/src/commands/hetero/index.ts b/apps/cli/src/commands/hetero/index.ts
index 9b94bc882c9..e0a41c003f2 100644
--- a/apps/cli/src/commands/hetero/index.ts
+++ b/apps/cli/src/commands/hetero/index.ts
@@ -564,34 +564,32 @@ const exec = async (options: ExecOptions): Promise<void> => {
let askBridge: AskUserBridge | undefined;
let askMcpConfigPath: string | undefined;
const askPollAbort = new AbortController();
- if (
- serverIngest &&
- (agentType === 'claude-code' ||
- (agentType === 'codex' && options.codexAppServer) ||
- agentType === 'copilot' ||
- agentType === 'cursor' ||
- agentType === 'droid' ||
- agentType === 'devin' ||
- agentType === 'qoder') &&
- serverIngester
- ) {
- if (
- agentType === 'codex' ||
- agentType === 'copilot' ||
- agentType === 'cursor' ||
- agentType === 'devin' ||
- agentType === 'droid'
- ) {
+ const mcpAskUserProvider =
+ agentType === 'claude-code' || agentType === 'qoder' ? agentType : undefined;
+ const nativeAskUserProvider =
+ agentType === 'antigravity' ||
+ (agentType === 'codex' && options.codexAppServer) ||
+ agentType === 'copilot' ||
+ agentType === 'cursor' ||
+ agentType === 'devin' ||
+ agentType === 'droid'
+ ? agentType
+ : undefined;
+ if (serverIngest && serverIngester && (mcpAskUserProvider || nativeAskUserProvider)) {
+ if (nativeAskUserProvider) {
askBridge = new AskUserBridge(operationId, {
- identifier: agentType === 'cursor' ? 'claude-code' : agentType,
- provider: agentType,
+ identifier: nativeAskUserProvider === 'cursor' ? 'claude-code' : nativeAskUserProvider,
+ provider: nativeAskUserProvider,
});
- } else {
+ } else if (mcpAskUserProvider) {
askServer = new LobeBuiltinMcpServer();
await askServer.start();
askBridge = askServer.registerOperation(
operationId,
- new AskUserBridge(operationId, { identifier: agentType, provider: agentType }),
+ new AskUserBridge(operationId, {
+ identifier: mcpAskUserProvider,
+ provider: mcpAskUserProvider,
+ }),
);
askMcpConfigPath = path.join(os.tmpdir(), `lobe-cc-mcp-${operationId}.json`);
await writeFile(
diff --git a/apps/desktop/src/main/controllers/heterogeneousAgentSession.ts b/apps/desktop/src/main/controllers/heterogeneousAgentSession.ts
index 7399b9da698..8beaaf1dc42 100644
--- a/apps/desktop/src/main/controllers/heterogeneousAgentSession.ts
+++ b/apps/desktop/src/main/controllers/heterogeneousAgentSession.ts
@@ -674,8 +674,14 @@ export const sendPromptWithAcpSession = async (
await host.completeCancelledSessionBeforeLaunch(session);
return;
}
+ const intervention = host.setupAcpInterventionForOp(
+ params.operationId,
+ session.sessionId,
+ 'antigravity',
+ );
const antigravityAcpSession = new AntigravityAcpSession({
...createCommonOptions(traceSession),
+ askUserBridge: intervention.bridge,
onModel: (model) => {
session.model = model;
session.modelSource = 'antigravity-acp';
@@ -686,6 +692,7 @@ export const sendPromptWithAcpSession = async (
await runInteractiveAcpSession(host, {
acpSession: antigravityAcpSession,
activeSessionKey: 'antigravityAcpSession',
+ cleanup: intervention.cleanup,
isResumeError: isAntigravityAcpSessionNotFoundError,
session,
stderrChunks,
diff --git a/apps/server/src/services/heterogeneousAgent/HeterogeneousPersistenceHandler/intervention.ts b/apps/server/src/services/heterogeneousAgent/HeterogeneousPersistenceHandler/intervention.ts
index 0556e554107..4aa16413cb0 100644
--- a/apps/server/src/services/heterogeneousAgent/HeterogeneousPersistenceHandler/intervention.ts
+++ b/apps/server/src/services/heterogeneousAgent/HeterogeneousPersistenceHandler/intervention.ts
@@ -141,6 +141,7 @@ export const INTERVENTION_KINDS = new Set<AgentInterventionInteractionKind>([
]);
export const INTERVENTION_PROVIDERS = new Set<AgentInterventionProvider>([
+ 'antigravity',
'claude-code',
'codex',
'copilot',
diff --git a/packages/agent-gateway-client/src/intervention.ts b/packages/agent-gateway-client/src/intervention.ts
index a7d0e4bcbda..8f2bbe3bcf0 100644
--- a/packages/agent-gateway-client/src/intervention.ts
+++ b/packages/agent-gateway-client/src/intervention.ts
@@ -12,6 +12,7 @@ const INTERACTION_KINDS = new Set<AgentInterventionInteractionKind>([
'question',
]);
const PROVIDERS = new Set<AgentInterventionProvider>([
+ 'antigravity',
'claude-code',
'codex',
'copilot',
diff --git a/packages/agent-gateway-client/src/types.ts b/packages/agent-gateway-client/src/types.ts
index 2d729ad8cd4..b6f17b708f3 100644
--- a/packages/agent-gateway-client/src/types.ts
+++ b/packages/agent-gateway-client/src/types.ts
@@ -297,7 +297,15 @@ export type AgentInterventionInteractionKind = 'permission' | 'plan' | 'question
/** Producer that owns the blocked interaction. */
export type AgentInterventionProvider =
- 'claude-code' | 'codex' | 'copilot' | 'cursor' | 'devin' | 'droid' | 'opencode' | 'qoder';
+ | 'antigravity'
+ | 'claude-code'
+ | 'codex'
+ | 'copilot'
+ | 'cursor'
+ | 'devin'
+ | 'droid'
+ | 'opencode'
+ | 'qoder';
/** Whitelisted option surface that may be persisted for cold-start review. */
export interface AgentInterventionRenderOption {
diff --git a/packages/builtin-tools/src/register.ts b/packages/builtin-tools/src/register.ts
index 57c9c1782c4..3b3b5d3c99c 100644
--- a/packages/builtin-tools/src/register.ts
+++ b/packages/builtin-tools/src/register.ts
@@ -225,6 +225,7 @@ import { registerBuiltinStreamings } from './streamings';
import { TwitterIdentifier, TwitterInspectors } from './twitter';
const COPILOT_IDENTIFIER = 'copilot';
+const ANTIGRAVITY_IDENTIFIER = 'antigravity';
const DROID_IDENTIFIER = 'droid';
const DEVIN_IDENTIFIER = 'devin';
const QODER_IDENTIFIER = 'qoder';
@@ -289,6 +290,9 @@ export const registerBuiltinToolSurfaces = (): void => {
[AgentDocumentsManifest.identifier]: AgentDocumentsRenders as Record<string, BuiltinRender>,
[AgentManagementManifest.identifier]: AgentManagementRenders as Record<string, BuiltinRender>,
[ClaudeCodeIdentifier]: ClaudeCodeRenders as Record<string, BuiltinRender>,
+ [ANTIGRAVITY_IDENTIFIER]: {
+ [ClaudeCodeApiName.AskUserQuestion]: ClaudeCodeRenders[ClaudeCodeApiName.AskUserQuestion],
+ },
[COPILOT_IDENTIFIER]: {
execute: RunCommandRender as BuiltinRender,
[ClaudeCodeApiName.AskUserQuestion]: ClaudeCodeRenders[ClaudeCodeApiName.AskUserQuestion],
@@ -364,6 +368,9 @@ export const registerBuiltinToolSurfaces = (): void => {
BuiltinInspector
>,
[ClaudeCodeIdentifier]: ClaudeCodeInspectors as Record<string, BuiltinInspector>,
+ [ANTIGRAVITY_IDENTIFIER]: {
+ [ClaudeCodeApiName.AskUserQuestion]: ClaudeCodeInspectors[ClaudeCodeApiName.AskUserQuestion],
+ },
[COPILOT_IDENTIFIER]: {
execute: createRunCommandInspector(
'builtins.lobe-local-system.apiName.runCommand',
@@ -482,6 +489,10 @@ export const registerBuiltinToolSurfaces = (): void => {
BuiltinIntervention
>,
[ClaudeCodeIdentifier]: ClaudeCodeInterventions as Record<string, BuiltinIntervention>,
+ [ANTIGRAVITY_IDENTIFIER]: {
+ [ClaudeCodeApiName.AskUserQuestion]:
+ ClaudeCodeInterventions[ClaudeCodeApiName.AskUserQuestion],
+ },
codex: {
[ClaudeCodeApiName.AskUserQuestion]:
ClaudeCodeInterventions[ClaudeCodeApiName.AskUserQuestion],
diff --git a/packages/heterogeneous-agents/src/askUser/AskUserBridge.ts b/packages/heterogeneous-agents/src/askUser/AskUserBridge.ts
index bf9474031d6..53f93e6dac9 100644
--- a/packages/heterogeneous-agents/src/askUser/AskUserBridge.ts
+++ b/packages/heterogeneous-agents/src/askUser/AskUserBridge.ts
@@ -46,6 +46,8 @@ export interface PendingArgs {
}
export interface PendingOptions {
+ /** Deliver this call's events on the producer's ordered stream. */
+ onEvent?: (event: AgentStreamEvent) => void;
/**
* Called every `progressIntervalMs` while the call is pending. Use it to
* push MCP `notifications/progress` to keep the SSE channel from timing
@@ -73,6 +75,7 @@ export const NO_DEADLINE_MS = 365 * 24 * 60 * 60 * 1000;
interface PendingEntry {
cleanup: () => void;
+ emit: (event: AgentStreamEvent) => void;
reject: (err: unknown) => void;
resolve: (answer: InterventionAnswer) => void;
}
@@ -164,6 +167,7 @@ export class AskUserBridge {
const startedAt = Date.now();
const expires = Number.isFinite(timeoutMs);
const deadline = startedAt + (expires ? timeoutMs : NO_DEADLINE_MS);
+ const emit = options.onEvent ?? ((event: AgentStreamEvent) => this.emit(event));
return new Promise<InterventionAnswer>((resolve, reject) => {
const onTimeout = () => {
@@ -174,7 +178,7 @@ export class AskUserBridge {
// finishes and gets garbage-collected. Without this, the renderer
// would still show the form as pending after the bridge has already
// given up.
- this.emitResponse(toolCallId, { cancelReason: 'timeout', cancelled: true });
+ this.emitResponse(emit, toolCallId, { cancelReason: 'timeout', cancelled: true });
resolve({ cancelled: true, cancelReason: 'timeout' });
};
const timeoutTimer = expires ? setTimeout(onTimeout, timeoutMs) : undefined;
@@ -192,7 +196,7 @@ export class AskUserBridge {
if (progressTimer) clearInterval(progressTimer);
};
- this.pending_.set(toolCallId, { cleanup, reject, resolve });
+ this.pending_.set(toolCallId, { cleanup, emit, reject, resolve });
// Emit the intervention request AFTER setting up the pending entry,
// so any synchronous resolve from a test fixture finds the slot.
@@ -208,7 +212,7 @@ export class AskUserBridge {
provider: this.provider,
toolCallId,
};
- this.emit({
+ emit({
data,
operationId: this.operationId,
stepIndex: this.getStepIndex(),
@@ -240,7 +244,7 @@ export class AskUserBridge {
// the consumer has already optimistically updated, but emitting keeps
// the wire contract symmetric (request → response) and lets late
// subscribers reconstruct the terminal state purely from events.
- this.emitResponse(toolCallId, {
+ this.emitResponse(entry.emit, toolCallId, {
cancelReason: payload.cancelled ? (payload.cancelReason ?? 'user_cancelled') : undefined,
cancelled: payload.cancelled,
result: payload.cancelled ? undefined : payload.result,
@@ -275,7 +279,7 @@ export class AskUserBridge {
// immediately after.
for (const [toolCallId, entry] of this.pending_) {
entry.cleanup();
- this.emitResponse(toolCallId, { cancelReason: reason, cancelled: true });
+ this.emitResponse(entry.emit, toolCallId, { cancelReason: reason, cancelled: true });
entry.resolve({ cancelReason: reason, cancelled: true });
}
this.pending_.clear();
@@ -326,6 +330,7 @@ export class AskUserBridge {
}
private emitResponse(
+ emit: (event: AgentStreamEvent) => void,
toolCallId: string,
payload: {
cancelReason?: InterventionAnswer['cancelReason'];
@@ -342,7 +347,7 @@ export class AskUserBridge {
resolutionRequestId: payload.resolutionRequestId,
toolCallId,
};
- this.emit({
+ emit({
data,
operationId: this.operationId,
stepIndex: this.getStepIndex(),
diff --git a/packages/heterogeneous-agents/src/spawn/acpSpawnAgent.ts b/packages/heterogeneous-agents/src/spawn/acpSpawnAgent.ts
index 7191fc2d17d..febaaba5d88 100644
--- a/packages/heterogeneous-agents/src/spawn/acpSpawnAgent.ts
+++ b/packages/heterogeneous-agents/src/spawn/acpSpawnAgent.ts
@@ -175,6 +175,7 @@ export const spawnAntigravityAcpAgent = async (
const bridge = createAcpSpawnBridge();
const session = new AntigravityAcpSession({
args: options.extraArgs ?? [],
+ askUserBridge: options.askUserBridge,
clientVersion: 'lobehub-cli',
commandPath: command,
cwd,
diff --git a/packages/heterogeneous-agents/src/spawn/antigravityAcpElicitation.ts b/packages/heterogeneous-agents/src/spawn/antigravityAcpElicitation.ts
new file mode 100644
index 00000000000..bba3b0146b3
--- /dev/null
+++ b/packages/heterogeneous-agents/src/spawn/antigravityAcpElicitation.ts
@@ -0,0 +1,101 @@
+import type { AgentInterventionRenderQuestion } from '@lobechat/agent-gateway-client';
+import { isRecord } from '@lobechat/utils/object';
+
+import type { InterventionAnswer } from '../askUser/AskUserBridge';
+
+interface AntigravityQuestion {
+ key: string;
+ otherKey: string;
+ question: AgentInterventionRenderQuestion;
+}
+
+/** agy encodes each ask_question prompt as qN choices and a qN_other text field. */
+export const parseAntigravityQuestions = (schema: unknown): AntigravityQuestion[] | undefined => {
+ if (!isRecord(schema) || schema.type !== 'object' || !isRecord(schema.properties)) return;
+ const { properties } = schema;
+ const keys = Object.keys(properties).filter((key) => /^q[1-9]\d*$/.test(key));
+ if (!keys.length || keys.length > 4 || Object.keys(properties).length !== keys.length * 2) return;
+
+ const questions: AntigravityQuestion[] = [];
+ const questionTexts = new Set(['__freeform__', '__supplement__', '__proto__']);
+ for (const key of keys) {
+ const property = properties[key];
+ const otherKey = `${key}_other`;
+ const other = properties[otherKey];
+ if (!isRecord(property) || !isRecord(other) || other.type !== 'string') return;
+ const title = property.title;
+ if (
+ typeof title !== 'string' ||
+ !title.trim() ||
+ title.length > 4000 ||
+ questionTexts.has(title)
+ )
+ return;
+ questionTexts.add(title);
+
+ const multiSelect = property.type === 'array';
+ const choices = multiSelect
+ ? isRecord(property.items) && property.items.anyOf
+ : property.type === 'string' && property.oneOf;
+ if (!Array.isArray(choices) || choices.length === 0 || choices.length > 16) return;
+
+ const options: AgentInterventionRenderQuestion['options'] = [];
+ const ids = new Set<string>();
+ for (const choice of choices) {
+ if (!isRecord(choice)) return;
+ const { const: id, title: label, description } = choice;
+ if (typeof id !== 'string' || !id.trim() || id.length >= 200 || ids.has(id)) return;
+ if (typeof label !== 'string' || !label.trim() || label.length > 200) return;
+ ids.add(id);
+ options.push({
+ description:
+ typeof description === 'string' && description.length <= 1000
+ ? description || undefined
+ : undefined,
+ // The shared form trims custom answers, but sends selected IDs verbatim.
+ // Reserve a leading space so typed "2" cannot select preset option "2".
+ id: ` ${id}`,
+ label,
+ });
+ }
+ questions.push({
+ key,
+ otherKey,
+ question: { header: '', multiSelect, options, question: title },
+ });
+ }
+ return questions;
+};
+
+export const buildAntigravityElicitationResponse = (
+ questions: AntigravityQuestion[],
+ answer: InterventionAnswer,
+) => {
+ if (answer.cancelled) {
+ return { action: answer.cancelReason === 'user_cancelled' ? 'decline' : 'cancel' };
+ }
+ if (!isRecord(answer.result)) return { action: 'decline' };
+
+ const content: Record<string, string | string[]> = {};
+ const freeform =
+ typeof answer.result.__freeform__ === 'string' ? answer.result.__freeform__.trim() : '';
+ const supplement =
+ typeof answer.result.__supplement__ === 'string' ? answer.result.__supplement__.trim() : '';
+ for (const { key, otherKey, question } of questions) {
+ const value = answer.result[question.question];
+ const ids = new Set<string>();
+ const other = [];
+ if (freeform) other.push(freeform);
+ else {
+ for (const selection of Array.isArray(value) ? value : [value]) {
+ if (typeof selection !== 'string' || !selection.trim()) continue;
+ if (question.options.some(({ id }) => id === selection)) ids.add(selection.slice(1));
+ else other.push(selection.trim());
+ }
+ if (supplement) other.push(supplement);
+ }
+ if (ids.size) content[key] = question.multiSelect ? [...ids] : [...ids][0];
+ if (other.length) content[otherKey] = other.join('\n');
+ }
+ return Object.keys(content).length ? { action: 'accept', content } : { action: 'decline' };
+};
diff --git a/packages/heterogeneous-agents/src/spawn/antigravityAcpSession.test.ts b/packages/heterogeneous-agents/src/spawn/antigravityAcpSession.test.ts
index c994ed5d3e5..b57cefec2c9 100644
--- a/packages/heterogeneous-agents/src/spawn/antigravityAcpSession.test.ts
+++ b/packages/heterogeneous-agents/src/spawn/antigravityAcpSession.test.ts
@@ -5,6 +5,7 @@ import { PassThrough } from 'node:stream';
import type { AgentStreamEvent } from '@lobechat/agent-gateway-client';
import { afterEach, describe, expect, it, vi } from 'vitest';
+import { AskUserBridge } from '../askUser/AskUserBridge';
import {
AntigravityAcpSession,
type AntigravityAcpSessionOptions,
@@ -37,6 +38,8 @@ const MODEL_OPTIONS = [
];
/** Models whose thinking tier is fixed: agy offers no `thought_level` for them. */
const FIXED_TIER_MODELS = new Set(['gemini-pro-orchestrator', 'gpt-oss-120b-medium']);
+const thinkingLevels = (model: string) =>
+ model === 'gemini-4-neon' ? ['low', 'medium', 'high', 'xhigh'] : ['low', 'medium', 'high'];
const configOptions = (model: string, level: string, mode = 'default') => [
{
@@ -46,7 +49,13 @@ const configOptions = (model: string, level: string, mode = 'default') => [
},
...(FIXED_TIER_MODELS.has(model)
? []
- : [{ currentValue: level, id: 'thought_level', options: [] }]),
+ : [
+ {
+ currentValue: level,
+ id: 'thought_level',
+ options: thinkingLevels(model).map((value) => ({ name: value, value })),
+ },
+ ]),
{ currentValue: mode, id: 'mode', options: [] },
];
@@ -60,7 +69,11 @@ const AVAILABLE_MODELS = [
type PromptHandler = (
prompt: RpcMessage,
- agent: { finish: (id: RpcMessage['id'], result: unknown) => void; update: (u: unknown) => void },
+ agent: {
+ finish: (id: RpcMessage['id'], result: unknown) => void;
+ request: (request: RpcMessage) => void;
+ update: (u: unknown) => void;
+ },
) => void;
/**
@@ -71,6 +84,7 @@ type PromptHandler = (
const createAgy = ({
newError,
loadError,
+ onClientResponse,
onPrompt,
replayOnLoad = false,
resumeError,
@@ -78,6 +92,7 @@ const createAgy = ({
}: {
loadError?: { code: number; message: string };
newError?: { code: number; message: string };
+ onClientResponse?: (message: RpcMessage, finish: () => void) => void;
onPrompt?: PromptHandler;
replayOnLoad?: boolean;
resumeError?: { code: number; message: string };
@@ -120,6 +135,12 @@ const createAgy = ({
queueMicrotask(() => {
const params = message.params ?? {};
switch (message.method) {
+ case undefined: {
+ const prompt = pendingPrompt;
+ if (prompt)
+ onClientResponse?.(message, () => finish(prompt.id, { stopReason: 'end_turn' }));
+ return;
+ }
case 'initialize': {
send({
id: message.id,
@@ -168,6 +189,7 @@ const createAgy = ({
const variant = /^(.*)-(low|medium|high|xhigh)$/.exec(params.value);
if (MODEL_OPTIONS.includes(params.value)) {
model = params.value;
+ if (!thinkingLevels(model).includes(level)) level = 'high';
} else if (variant && MODEL_OPTIONS.includes(variant[1])) {
[, model, level] = variant;
} else {
@@ -179,7 +201,7 @@ const createAgy = ({
}
}
if (params.configId === 'thought_level') {
- if (FIXED_TIER_MODELS.has(model)) {
+ if (FIXED_TIER_MODELS.has(model) || !thinkingLevels(model).includes(params.value)) {
send({
error: {
code: -32_602,
@@ -229,7 +251,7 @@ const createAgy = ({
finish(pendingPrompt.id, ended);
}
pendingPrompt = message;
- onPrompt?.(message, { finish, update });
+ onPrompt?.(message, { finish, request: (request) => send({ ...request }), update });
return;
}
}
@@ -285,6 +307,159 @@ afterEach(() => {
});
describe('AntigravityAcpSession', () => {
+ it('keeps the new model’s thinking level when the requested tier is unavailable', async () => {
+ const agy = createAgy({
+ onPrompt: (prompt, { finish }) => finish(prompt.id, { stopReason: 'end_turn' }),
+ });
+ const { session } = createSession(agy, {
+ args: ['--model', 'gemini-3.8-flash', '--effort', 'xhigh'],
+ });
+
+ await expect(session.run()).resolves.toBeUndefined();
+ expect(agy.requests.some(({ params }) => params?.configId === 'thought_level')).toBe(false);
+ expect(methods(agy.requests)).toContain('session/prompt');
+ });
+
+ it.each([
+ {
+ answer: { result: { 'Channels?': [' 1', '2'], 'Region?': '2' } },
+ result: { action: 'accept', content: { q1_other: '2', q2: ['1'], q2_other: '2' } },
+ },
+ {
+ answer: { cancelled: true, cancelReason: 'user_cancelled' as const },
+ result: { action: 'decline' },
+ },
+ ])('answers an agy form with the same tool id: $result.action', async ({ answer, result }) => {
+ const toolCallId = 'call-ask-1';
+ const askUserBridge = new AskUserBridge('op-1', {
+ identifier: 'antigravity',
+ provider: 'antigravity',
+ });
+ const onAnswer = vi.fn();
+ const agy = createAgy({
+ onClientResponse: (message, finish) => {
+ onAnswer(message);
+ agy.update({
+ name: 'ask_question',
+ sessionUpdate: 'tool_call_update',
+ status: 'completed',
+ toolCallId,
+ });
+ finish();
+ },
+ onPrompt: (_prompt, { request, update }) => {
+ update({ name: 'read_file', sessionUpdate: 'tool_call', toolCallId: 'previous-tool' });
+ update({
+ sessionUpdate: 'tool_call_update',
+ status: 'completed',
+ toolCallId: 'previous-tool',
+ });
+ update({
+ name: 'ask_question',
+ sessionUpdate: 'tool_call',
+ status: 'in_progress',
+ toolCallId,
+ });
+ request({
+ id: 'elicitation-1',
+ method: 'elicitation/create',
+ params: {
+ mode: 'form',
+ requestedSchema: {
+ properties: {
+ q1: {
+ oneOf: [
+ { const: '1', title: 'EU' },
+ { const: '2', title: 'US' },
+ ],
+ title: 'Region?',
+ type: 'string',
+ },
+ q1_other: { title: 'Other', type: 'string' },
+ q2: {
+ items: {
+ anyOf: [
+ { const: '1', title: 'Email' },
+ { const: '2', title: 'SMS' },
+ ],
+ },
+ title: 'Channels?',
+ type: 'array',
+ },
+ q2_other: { title: 'Other', type: 'string' },
+ },
+ type: 'object',
+ },
+ sessionId: SESSION_ID,
+ toolCallId,
+ },
+ });
+ },
+ });
+ const { events: sessionEvents, session } = createSession(agy, { askUserBridge });
+ const run = session.run();
+ try {
+ await vi.waitFor(() => {
+ expect(agy.requests[0]?.params?.clientCapabilities).toMatchObject({
+ elicitation: { form: {} },
+ });
+ expect(sessionEvents.some((event) => event.type === 'agent_intervention_request')).toBe(
+ true,
+ );
+ });
+ const requestIndex = sessionEvents.findIndex(
+ (event) => event.type === 'agent_intervention_request',
+ );
+ const request = sessionEvents[requestIndex];
+ expect(sessionEvents.slice(0, requestIndex)).toContainEqual(
+ expect.objectContaining({
+ data: expect.objectContaining({ toolCallId }),
+ type: 'tool_start',
+ }),
+ );
+ expect(request.data).toMatchObject({
+ apiName: 'askUserQuestion',
+ provider: 'antigravity',
+ toolCallId,
+ });
+ expect(JSON.parse(request.data.arguments).questions).toMatchObject([
+ {
+ multiSelect: false,
+ options: [
+ { id: ' 1', label: 'EU' },
+ { id: ' 2', label: 'US' },
+ ],
+ question: 'Region?',
+ },
+ { multiSelect: true, question: 'Channels?' },
+ ]);
+ askUserBridge.resolve(toolCallId, answer);
+ await run;
+ expect(onAnswer).toHaveBeenCalledWith(
+ expect.objectContaining({ id: 'elicitation-1', result }),
+ );
+ expect(
+ sessionEvents.filter(
+ (event) => event.type === 'tool_start' && event.data.toolCallId === toolCallId,
+ ),
+ ).toMatchObject([
+ {
+ data: {
+ toolCallId,
+ toolCalling: { apiName: 'askUserQuestion', identifier: 'antigravity' },
+ },
+ },
+ ]);
+ expect(sessionEvents).toContainEqual(
+ expect.objectContaining({ type: 'tool_end', data: { isSuccess: true, toolCallId } }),
+ );
+ } finally {
+ askUserBridge.cancelAll();
+ session.close();
+ await run.catch(() => {});
+ }
+ });
+
it('starts agy acp, applies the selected model, effort and mode, then streams the turn', async () => {
const agy = createAgy({
onPrompt: (prompt, { finish, update }) => {
diff --git a/packages/heterogeneous-agents/src/spawn/antigravityAcpSession.ts b/packages/heterogeneous-agents/src/spawn/antigravityAcpSession.ts
index 67805bc7fff..0c9442d39cb 100644
--- a/packages/heterogeneous-agents/src/spawn/antigravityAcpSession.ts
+++ b/packages/heterogeneous-agents/src/spawn/antigravityAcpSession.ts
@@ -1,5 +1,6 @@
import { isRecord } from '@lobechat/utils/object';
+import type { AskUserBridge } from '../askUser/AskUserBridge';
import type { AgentPromptInput } from '../protocol';
import type { AcpAgentSessionOptions } from './acpAgentSession';
import {
@@ -10,6 +11,10 @@ import {
import type { AcpRpcMessage } from './acpStdioClient';
import { AcpRpcResponseError, AcpServerRequestError } from './acpStdioClient';
import { buildAntigravityAcpLaunch } from './antigravity';
+import {
+ buildAntigravityElicitationResponse,
+ parseAntigravityQuestions,
+} from './antigravityAcpElicitation';
import type { BuildAgentInputOptions } from './input';
import type { TraeAcpPromptBlock } from './traeAcpSession';
import { buildTraeAcpPrompt } from './traeAcpSession';
@@ -107,6 +112,7 @@ const resolveModelValue = (
};
export interface AntigravityAcpSessionOptions extends AcpAgentSessionOptions {
+ askUserBridge?: AskUserBridge;
onModel?: (model: string) => void;
prompt: AntigravityAcpPromptBlock[];
}
@@ -210,7 +216,11 @@ export class AntigravityAcpSession extends AcpAgentSession<
protected buildInitializeParams(): unknown {
return {
- clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false },
+ clientCapabilities: {
+ ...(this.options.askUserBridge && { elicitation: { form: {} } }),
+ fs: { readTextFile: false, writeTextFile: false },
+ terminal: false,
+ },
clientInfo: { name: 'lobehub', title: 'LobeHub', version: this.options.clientVersion },
protocolVersion: ACP_PROTOCOL_VERSION,
};
@@ -318,6 +328,17 @@ export class AntigravityAcpSession extends AcpAgentSession<
if (!isRecord(params?.update)) return;
// Subagent conversations must never leak into the parent's assistant bubble.
if (typeof params.sessionId === 'string' && params.sessionId !== this.acpSessionId) return;
+ // agy starts the raw tool before the form request, whose schema supplies
+ // the arguments for the same card. A terminal update still closes it or
+ // shows the original tool when agy fell back to asking in chat.
+ const { name, sessionUpdate, status } = params.update;
+ if (
+ this.options.askUserBridge &&
+ name === 'ask_question' &&
+ (sessionUpdate === 'tool_call' || sessionUpdate === 'tool_call_update') &&
+ (status === 'in_progress' || status === 'pending' || status === undefined)
+ )
+ return;
await this.pushToPipeline(params.update);
}
@@ -326,6 +347,7 @@ export class AntigravityAcpSession extends AcpAgentSession<
* still ask, approve as the print-mode runs did.
*/
protected handleServerRequest(message: AcpRpcMessage): unknown {
+ if (message.method === 'elicitation/create') return this.handleElicitation(message.params);
if (message.method !== 'session/request_permission') {
throw new AcpServerRequestError(-32_601, `Unsupported ACP client request: ${message.method}`);
}
@@ -338,6 +360,37 @@ export class AntigravityAcpSession extends AcpAgentSession<
: { outcome: { outcome: 'cancelled' } };
}
+ private async handleElicitation(params: unknown): Promise<unknown> {
+ const bridge = this.options.askUserBridge;
+ if (!bridge || !isRecord(params) || params.mode !== 'form') {
+ throw new AcpServerRequestError(-32_602, 'Unsupported Antigravity elicitation mode');
+ }
+ if (!this.steerable || params.sessionId !== this.acpSessionId) return { action: 'cancel' };
+ const { toolCallId } = params;
+ const questions = parseAntigravityQuestions(params.requestedSchema);
+ if (typeof toolCallId !== 'string' || !toolCallId || !questions) return { action: 'decline' };
+
+ const args = { questions: questions.map(({ question }) => question) };
+ await this.pushToPipeline({
+ name: 'askUserQuestion',
+ rawInput: args,
+ sessionUpdate: 'tool_call',
+ toolCallId,
+ });
+ if (!this.steerable) return { action: 'cancel' };
+ const answer = await bridge.pending(
+ { arguments: args, toolCallId },
+ {
+ // Queue the request and ACK alongside the tool events. An independent
+ // bridge pump can persist the question before the new assistant step.
+ onEvent: (event) => {
+ void this.emitEvents([event]).catch(() => this.interrupt());
+ },
+ },
+ );
+ return buildAntigravityElicitationResponse(questions, answer);
+ }
+
/**
* Resume without replaying history; agy points sessions it cannot resume to
* `session/load`, whose replay arrives before the prompt and is dropped.
@@ -394,9 +447,8 @@ export class AntigravityAcpSession extends AcpAgentSession<
? resolveModelValue(this.launch.model, effort, sessionResult)
: undefined;
if (model) await set('model', model);
- // Models with a fixed thinking tier (GPT-OSS, Orchestrator) offer no
- // thought_level, and agy rejects setting one.
- if (effort && findConfigOption(configOptions, 'thought_level')) {
+ // Changing models can replace or remove the thinking-level choices.
+ if (effort && configOptionValues(configOptions, 'thought_level').includes(effort)) {
await set('thought_level', effort);
}
if (mode) await set('mode', mode);
diff --git a/packages/types/src/tool/intervention.ts b/packages/types/src/tool/intervention.ts
index 1515b10f0ed..da1b9192934 100644
--- a/packages/types/src/tool/intervention.ts
+++ b/packages/types/src/tool/intervention.ts
@@ -163,6 +163,7 @@ export type ToolInterventionPresentation = {
};
const ASK_USER_QUESTION_IDENTIFIERS = new Set([
+ 'antigravity',
'claude-code',
'codex',
'copilot',
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/customInteractionHandlers.ts b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/customInteractionHandlers.ts
index a2152dc8576..d2529cd0812 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/customInteractionHandlers.ts
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/customInteractionHandlers.ts
@@ -170,6 +170,7 @@ const findCustomInteractionSubmitHandler = (identifier: string, apiName?: string
* turn.
*/
const HETERO_CUSTOM_INTERACTION_IDENTIFIERS = new Set<string>([
+ 'antigravity',
ClaudeCodeIdentifier,
'codex',
COPILOT_IDENTIFIER,