Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Commit 0f86ced

Browse files
vijayupadyavijay upadya
andauthored
Gemini function calling mode exp (#2795)
* Gemini function calling mode exp * add config to package.json * Make setting internal only * add setting that was removed accidentally --------- Co-authored-by: vijay upadya <vj@example.com>
1 parent 6969f93 commit 0f86ced

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/platform/configuration/common/configurationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,9 @@ export namespace ConfigKey {
734734
export const InternalWelcomeHintEnabled = defineTeamInternalSetting<boolean>('chat.advanced.welcomePageHint.enabled', ConfigType.Simple, { defaultValue: false, internalDefaultValue: true, teamDefaultValue: true, owner: 'lramos15', expirationDate: '2025-01-01' /* exempted */ });
735735
export const InlineChatUseCodeMapper = defineTeamInternalSetting<boolean>('chat.advanced.inlineChat.useCodeMapper', ConfigType.Simple, false);
736736
export const EnablePromptRendererTracing = defineTeamInternalSetting<boolean>('chat.advanced.promptRenderer.trace', ConfigType.Simple, false);
737-
738737
// Backed by Experiments
739738
export const DebugCollectFetcherTelemetry = defineTeamInternalSetting<boolean>('chat.advanced.debug.collectFetcherTelemetry', ConfigType.ExperimentBased, true);
739+
export const GeminiFunctionCallingMode = defineTeamInternalSetting<'auto' | 'none' | 'required' | 'validated' | undefined>('chat.advanced.gemini.functionCallingMode', ConfigType.ExperimentBased, undefined);
740740
export const DebugExpUseNodeFetchFetcher = defineTeamInternalSetting<boolean | undefined>('chat.advanced.debug.useNodeFetchFetcher', ConfigType.ExperimentBased, undefined);
741741
export const DebugExpUseNodeFetcher = defineTeamInternalSetting<boolean | undefined>('chat.advanced.debug.useNodeFetcher', ConfigType.ExperimentBased, undefined);
742742
export const DebugExpUseElectronFetcher = defineTeamInternalSetting<boolean | undefined>('chat.advanced.debug.useElectronFetcher', ConfigType.ExperimentBased, undefined);

src/platform/endpoint/node/responsesApi.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ export function createResponsesRequestBody(accessor: ServicesAccessor, options:
3131
const configService = accessor.get(IConfigurationService);
3232
const expService = accessor.get(IExperimentationService);
3333
const verbosity = getVerbosityForModelSync(endpoint);
34+
35+
const hasTools = !!options.requestOptions?.tools?.length;
36+
const geminiFunctionCallingMode = hasTools && endpoint.family.toLowerCase().includes('gemini-3')
37+
? configService.getExperimentBasedConfig(ConfigKey.TeamInternal.GeminiFunctionCallingMode, expService)
38+
: undefined;
39+
3440
const body: IEndpointBody = {
3541
model,
3642
...rawMessagesToResponseAPI(model, options.messages, !!options.ignoreStatefulMarker),
@@ -44,9 +50,11 @@ export function createResponsesRequestBody(accessor: ServicesAccessor, options:
4450
// Only a subset of completion post options are supported, and some
4551
// are renamed. Handle them manually:
4652
max_output_tokens: options.postOptions.max_tokens,
47-
tool_choice: typeof options.postOptions.tool_choice === 'object'
48-
? { type: 'function', name: options.postOptions.tool_choice.function.name }
49-
: options.postOptions.tool_choice,
53+
tool_choice: geminiFunctionCallingMode && typeof options.postOptions.tool_choice !== 'object'
54+
? geminiFunctionCallingMode
55+
: (typeof options.postOptions.tool_choice === 'object'
56+
? { type: 'function', name: options.postOptions.tool_choice.function.name }
57+
: options.postOptions.tool_choice),
5058
top_logprobs: options.postOptions.logprobs ? 3 : undefined,
5159
store: false,
5260
text: verbosity ? { verbosity } : undefined,

src/platform/networking/common/networking.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import { CustomModel, EndpointEditToolName } from '../../endpoint/common/endpoin
1717
import { ILogService } from '../../log/common/logService';
1818
import { ITelemetryService, TelemetryProperties } from '../../telemetry/common/telemetry';
1919
import { TelemetryData } from '../../telemetry/common/telemetryData';
20-
import { FinishedCallback, OpenAiFunctionTool, OpenAiResponsesFunctionTool, OptionalChatRequestParams, Prediction } from './fetch';
2120
import { AnthropicMessagesTool, ContextManagement } from './anthropic';
21+
import { FinishedCallback, OpenAiFunctionTool, OpenAiResponsesFunctionTool, OptionalChatRequestParams, Prediction } from './fetch';
2222
import { FetcherId, FetchOptions, IAbortController, IFetcherService, PaginationOptions, Response } from './fetcherService';
2323
import { ChatCompletion, RawMessageConversionCallback, rawMessageToCAPI } from './openai';
2424

@@ -73,7 +73,7 @@ export interface IEndpointBody {
7373
messages?: any[];
7474
n?: number;
7575
reasoning?: { effort?: string; summary?: string };
76-
tool_choice?: OptionalChatRequestParams['tool_choice'] | { type: 'function'; name: string };
76+
tool_choice?: OptionalChatRequestParams['tool_choice'] | { type: 'function'; name: string } | string;
7777
top_logprobs?: number;
7878
intent?: boolean;
7979
intent_threshold?: number;

0 commit comments

Comments
 (0)