Log flash continue (#4700)

This commit is contained in:
Sandy Tao 2025-07-22 18:01:24 -07:00 committed by GitHub
parent 67008d4643
commit 7c3a84075d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 2 deletions

View File

@ -43,7 +43,7 @@ import { ProxyAgent, setGlobalDispatcher } from 'undici';
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
import { LoopDetectionService } from '../services/loopDetectionService.js';
import { ideContext } from '../services/ideContext.js';
import { ClearcutLogger } from '../telemetry/clearcut-logger/clearcut-logger.js';
import { logFlashDecidedToContinue } from '../telemetry/loggers.js';
import { FlashDecidedToContinueEvent } from '../telemetry/types.js';
function isThinkingSupported(model: string) {
@ -388,7 +388,8 @@ export class GeminiClient {
signal,
);
if (nextSpeakerCheck?.next_speaker === 'model') {
ClearcutLogger.getInstance(this.config)?.logFlashDecidedToContinueEvent(
logFlashDecidedToContinue(
this.config,
new FlashDecidedToContinueEvent(prompt_id),
);
const nextRequest = [{ text: 'Please continue.' }];

View File

@ -13,6 +13,8 @@ export const EVENT_API_ERROR = 'gemini_cli.api_error';
export const EVENT_API_RESPONSE = 'gemini_cli.api_response';
export const EVENT_CLI_CONFIG = 'gemini_cli.config';
export const EVENT_FLASH_FALLBACK = 'gemini_cli.flash_fallback';
export const EVENT_FLASH_DECIDED_TO_CONTINUE =
'gemini_cli.flash_decided_to_continue';
export const METRIC_TOOL_CALL_COUNT = 'gemini_cli.tool.call.count';
export const METRIC_TOOL_CALL_LATENCY = 'gemini_cli.tool.call.latency';

View File

@ -15,6 +15,7 @@ import {
EVENT_TOOL_CALL,
EVENT_USER_PROMPT,
EVENT_FLASH_FALLBACK,
EVENT_FLASH_DECIDED_TO_CONTINUE,
SERVICE_NAME,
} from './constants.js';
import {
@ -25,6 +26,7 @@ import {
ToolCallEvent,
UserPromptEvent,
FlashFallbackEvent,
FlashDecidedToContinueEvent,
LoopDetectedEvent,
} from './types.js';
import {
@ -309,3 +311,24 @@ export function logLoopDetected(
};
logger.emit(logRecord);
}
export function logFlashDecidedToContinue(
config: Config,
event: FlashDecidedToContinueEvent,
): void {
ClearcutLogger.getInstance(config)?.logFlashDecidedToContinueEvent(event);
if (!isTelemetrySdkInitialized()) return;
const attributes: LogAttributes = {
...getCommonAttributes(config),
...event,
'event.name': EVENT_FLASH_DECIDED_TO_CONTINUE,
};
const logger = logs.getLogger(SERVICE_NAME);
const logRecord: LogRecord = {
body: `Flash decided to continue.`,
attributes,
};
logger.emit(logRecord);
}