Skip to content

Commit 986293b

Browse files
feat(core): add agent protocol UI types and experimental flag (#24275)
Co-authored-by: Adam Weidman <adamfweidman@gmail.com> Co-authored-by: Adam Weidman <adamfweidman@google.com>
1 parent adf7b3b commit 986293b

7 files changed

Lines changed: 65 additions & 0 deletions

File tree

docs/reference/configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,12 @@ their corresponding top-level category object in your `settings.json` file.
16061606
- **Default:** `false`
16071607
- **Requires restart:** Yes
16081608

1609+
- **`experimental.adk.agentSessionInteractiveEnabled`** (boolean):
1610+
- **Description:** Enable the agent session implementation for the interactive
1611+
CLI.
1612+
- **Default:** `false`
1613+
- **Requires restart:** Yes
1614+
16091615
- **`experimental.enableAgents`** (boolean):
16101616
- **Description:** Enable local and remote subagents.
16111617
- **Default:** `true`

packages/cli/src/config/settingsSchema.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,16 @@ const SETTINGS_SCHEMA = {
19701970
description: 'Enable non-interactive agent sessions.',
19711971
showInDialog: false,
19721972
},
1973+
agentSessionInteractiveEnabled: {
1974+
type: 'boolean',
1975+
label: 'Interactive Agent Session Enabled',
1976+
category: 'Experimental',
1977+
requiresRestart: true,
1978+
default: false,
1979+
description:
1980+
'Enable the agent session implementation for the interactive CLI.',
1981+
showInDialog: false,
1982+
},
19731983
},
19741984
},
19751985
enableAgents: {

packages/cli/src/nonInteractiveCliAgentSession.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
LegacyAgentSession,
3838
ToolErrorType,
3939
geminiPartsToContentParts,
40+
debugLogger,
4041
} from '@google/gemini-cli-core';
4142

4243
import type { Part } from '@google/genai';
@@ -599,6 +600,7 @@ export async function runNonInteractive({
599600
// Explicitly ignore these non-interactive events
600601
break;
601602
default:
603+
debugLogger.error('Unknown agent event type:', event);
602604
event satisfies never;
603605
break;
604606
}

packages/core/src/agent/event-translator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ function isStructuredError(error: unknown): error is StructuredError {
432432
return (
433433
typeof error === 'object' &&
434434
error !== null &&
435+
'status' in error &&
435436
'message' in error &&
436437
typeof error.message === 'string'
437438
);

packages/core/src/agent/types.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
import type { Kind } from '../tools/tools.js';
8+
79
export type WithMeta = { _meta?: Record<string, unknown> };
810

911
export type Unsubscribe = () => void;
@@ -180,6 +182,16 @@ export interface ToolRequest {
180182
name: string;
181183
/** The arguments for the tool. */
182184
args: Record<string, unknown>;
185+
/** UI specific metadata */
186+
_meta?: {
187+
legacyState?: {
188+
displayName?: string;
189+
isOutputMarkdown?: boolean;
190+
description?: string;
191+
kind?: Kind;
192+
};
193+
[key: string]: unknown;
194+
};
183195
}
184196

185197
/**
@@ -192,6 +204,18 @@ export interface ToolUpdate {
192204
displayContent?: ContentPart[];
193205
content?: ContentPart[];
194206
data?: Record<string, unknown>;
207+
/** UI specific metadata */
208+
_meta?: {
209+
legacyState?: {
210+
status?: string;
211+
progressMessage?: string;
212+
progress?: number;
213+
progressTotal?: number;
214+
pid?: number;
215+
description?: string;
216+
};
217+
[key: string]: unknown;
218+
};
195219
}
196220

197221
export interface ToolResponse {
@@ -205,6 +229,13 @@ export interface ToolResponse {
205229
data?: Record<string, unknown>;
206230
/** When true, the tool call encountered an error that will be sent to the model. */
207231
isError?: boolean;
232+
/** UI specific metadata */
233+
_meta?: {
234+
legacyState?: {
235+
outputFile?: string;
236+
};
237+
[key: string]: unknown;
238+
};
208239
}
209240

210241
export type ElicitationRequest = {

packages/core/src/config/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ export interface GemmaModelRouterSettings {
225225

226226
export interface ADKSettings {
227227
agentSessionNoninteractiveEnabled?: boolean;
228+
agentSessionInteractiveEnabled?: boolean;
228229
}
229230

230231
export interface ExtensionSetting {
@@ -894,6 +895,7 @@ export class Config implements McpContext, AgentLoopContext {
894895

895896
private readonly gemmaModelRouter: GemmaModelRouterSettings;
896897
private readonly agentSessionNoninteractiveEnabled: boolean;
898+
private readonly agentSessionInteractiveEnabled: boolean;
897899

898900
private readonly continueOnFailedApiCall: boolean;
899901
private readonly retryFetchErrors: boolean;
@@ -1325,6 +1327,8 @@ export class Config implements McpContext, AgentLoopContext {
13251327

13261328
this.agentSessionNoninteractiveEnabled =
13271329
params.adk?.agentSessionNoninteractiveEnabled ?? false;
1330+
this.agentSessionInteractiveEnabled =
1331+
params.adk?.agentSessionInteractiveEnabled ?? false;
13281332
this.retryFetchErrors = params.retryFetchErrors ?? true;
13291333
this.maxAttempts = Math.min(
13301334
params.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
@@ -3396,6 +3400,10 @@ export class Config implements McpContext, AgentLoopContext {
33963400
return this.agentSessionNoninteractiveEnabled;
33973401
}
33983402

3403+
getAgentSessionInteractiveEnabled(): boolean {
3404+
return this.agentSessionInteractiveEnabled;
3405+
}
3406+
33993407
/**
34003408
* Get override settings for a specific agent.
34013409
* Reads from agents.overrides.<agentName>.

schemas/settings.schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,6 +2775,13 @@
27752775
"markdownDescription": "Enable non-interactive agent sessions.\n\n- Category: `Experimental`\n- Requires restart: `yes`\n- Default: `false`",
27762776
"default": false,
27772777
"type": "boolean"
2778+
},
2779+
"agentSessionInteractiveEnabled": {
2780+
"title": "Interactive Agent Session Enabled",
2781+
"description": "Enable the agent session implementation for the interactive CLI.",
2782+
"markdownDescription": "Enable the agent session implementation for the interactive CLI.\n\n- Category: `Experimental`\n- Requires restart: `yes`\n- Default: `false`",
2783+
"default": false,
2784+
"type": "boolean"
27782785
}
27792786
},
27802787
"additionalProperties": false

0 commit comments

Comments
 (0)