mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 13:22:35 -07:00
feat(plan): create metrics for usage of AskUser tool (#18820)
Co-authored-by: Jerop Kipruto <jerop@google.com>
This commit is contained in:
@@ -192,16 +192,35 @@ export class AskUserInvocation extends BaseToolInvocation<
|
||||
}
|
||||
|
||||
async execute(_signal: AbortSignal): Promise<ToolResult> {
|
||||
const questionTypes = this.params.questions.map(
|
||||
(q) => q.type ?? QuestionType.CHOICE,
|
||||
);
|
||||
|
||||
if (this.confirmationOutcome === ToolConfirmationOutcome.Cancel) {
|
||||
return {
|
||||
llmContent: 'User dismissed ask_user dialog without answering.',
|
||||
returnDisplay: 'User dismissed dialog',
|
||||
data: {
|
||||
ask_user: {
|
||||
question_types: questionTypes,
|
||||
dismissed: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const answerEntries = Object.entries(this.userAnswers);
|
||||
const hasAnswers = answerEntries.length > 0;
|
||||
|
||||
const metrics: Record<string, unknown> = {
|
||||
ask_user: {
|
||||
question_types: questionTypes,
|
||||
dismissed: false,
|
||||
empty_submission: !hasAnswers,
|
||||
answer_count: answerEntries.length,
|
||||
},
|
||||
};
|
||||
|
||||
const returnDisplay = hasAnswers
|
||||
? `**User answered:**\n${answerEntries
|
||||
.map(([index, answer]) => {
|
||||
@@ -219,6 +238,7 @@ export class AskUserInvocation extends BaseToolInvocation<
|
||||
return {
|
||||
llmContent: JSON.stringify({ answers: this.userAnswers }),
|
||||
returnDisplay,
|
||||
data: metrics,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user