Skip to content

Commit 5211c83

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
Revert "RPP: create new annotations AI agent"
This reverts commit 9995b96. Reason for revert: I forgot that the backend CL needs to land before this can land! Original change's description: > RPP: create new annotations AI agent > > Required mostly for metrics so we can track its usage accurately rather > than bundled in with the existing "Ask AI" integration. > > (Googlers: see the attached bug for a link to the backend CL, this needs > to land first before this can land). > > Bug: 406795908 > Change-Id: Ibf0fff042f72a6e622e9d9d9e87769a71feb23af > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6407494 > Reviewed-by: Nikolay Vitkov <[email protected]> > Commit-Queue: Jack Franklin <[email protected]> Bug: 406795908 No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Ic85d030aa8542818168b23b6c60f582aa68eaf52 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6405418 Bot-Commit: Rubber Stamper <[email protected]> Auto-Submit: Jack Franklin <[email protected]> Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Rubber Stamper <[email protected]>
1 parent 9995b96 commit 5211c83

File tree

10 files changed

+53
-88
lines changed

10 files changed

+53
-88
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,6 @@ grd_files_debug_sources = [
989989
"front_end/models/ai_assistance/agents/NetworkAgent.js",
990990
"front_end/models/ai_assistance/agents/PatchAgent.js",
991991
"front_end/models/ai_assistance/agents/PerformanceAgent.js",
992-
"front_end/models/ai_assistance/agents/PerformanceAnnotationsAgent.js",
993992
"front_end/models/ai_assistance/agents/PerformanceInsightsAgent.js",
994993
"front_end/models/ai_assistance/agents/StylingAgent.js",
995994
"front_end/models/ai_assistance/data_formatters/FileFormatter.js",

front_end/core/host/AidaClient.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ export enum ClientFeature {
124124
CHROME_NETWORK_AGENT = 7,
125125
// Chrome AI Assistance Performance Agent.
126126
CHROME_PERFORMANCE_AGENT = 8,
127-
// Chrome AI Annotations Performance Agent
128-
CHROME_PERFORMANCE_ANNOTATIONS_AGENT = 20,
129127
// Chrome AI Assistance File Agent.
130128
CHROME_FILE_AGENT = 9,
131129
// Chrome AI Patch Agent.

front_end/models/ai_assistance/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ devtools_module("ai_assistance") {
1919
"agents/NetworkAgent.ts",
2020
"agents/PatchAgent.ts",
2121
"agents/PerformanceAgent.ts",
22-
"agents/PerformanceAnnotationsAgent.ts",
2322
"agents/PerformanceInsightsAgent.ts",
2423
"agents/StylingAgent.ts",
2524
"data_formatters/FileFormatter.ts",
@@ -77,7 +76,6 @@ ts_library("unittests") {
7776
"agents/NetworkAgent.test.ts",
7877
"agents/PatchAgent.test.ts",
7978
"agents/PerformanceAgent.test.ts",
80-
"agents/PerformanceAnnotationsAgent.test.ts",
8179
"agents/PerformanceInsightsAgent.test.ts",
8280
"agents/StylingAgent.test.ts",
8381
"data_formatters/FileFormatter.test.ts",

front_end/models/ai_assistance/agents/PerformanceAgent.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,22 @@ self: 3
226226
assert.isFalse(enhancedQuery3.includes(mockAiCallTree.serialize()));
227227
});
228228
});
229+
230+
describe('generating an AI entry label', () => {
231+
it('generates a label from the final answer and trims newlines', async function() {
232+
const agent = new PerformanceAgent({
233+
aidaClient: mockAidaClient([[{
234+
explanation: 'hello world\n',
235+
}]]),
236+
});
237+
const {parsedTrace} = await TraceLoader.traceEngine(this, 'web-dev-with-commit.json.gz');
238+
const evalScriptEvent = parsedTrace.Renderer.allTraceEntries.find(
239+
event => event.name === Trace.Types.Events.Name.EVALUATE_SCRIPT && event.ts === 122411195649);
240+
assert.exists(evalScriptEvent);
241+
const aiCallTree = TimelineUtils.AICallTree.AICallTree.fromEvent(evalScriptEvent, parsedTrace);
242+
assert.isOk(aiCallTree);
243+
const label = await agent.generateAIEntryLabel(aiCallTree);
244+
assert.strictEqual(label, 'hello world');
245+
});
246+
});
229247
});

front_end/models/ai_assistance/agents/PerformanceAgent.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,7 @@ export class CallTreeContext extends ConversationContext<TimelineUtils.AICallTre
201201
export class PerformanceAgent extends AiAgent<TimelineUtils.AICallTree.AICallTree> {
202202
override readonly type = AgentType.PERFORMANCE;
203203
readonly preamble = preamble;
204-
205-
// We have to set the type of clientFeature here to be the entire enum
206-
// because in PerformanceAnnotationsAgent.ts we override it.
207-
// TODO(b/406961576): split the agents apart rather than have one extend the other.
208-
readonly clientFeature: Host.AidaClient.ClientFeature = Host.AidaClient.ClientFeature.CHROME_PERFORMANCE_AGENT;
204+
readonly clientFeature = Host.AidaClient.ClientFeature.CHROME_PERFORMANCE_AGENT;
209205
get userTier(): string|undefined {
210206
return Root.Runtime.hostConfig.devToolsAiAssistancePerformanceAgent?.userTier;
211207
}
@@ -255,4 +251,33 @@ export class PerformanceAgent extends AiAgent<TimelineUtils.AICallTree.AICallTre
255251
const perfEnhancementQuery = treeStr ? `${treeStr}\n\n# User request\n\n` : '';
256252
return `${perfEnhancementQuery}${query}`;
257253
}
254+
255+
/**
256+
* Used in the Performance panel to automatically generate a label for a selected entry.
257+
*/
258+
async generateAIEntryLabel(callTree: TimelineUtils.AICallTree.AICallTree): Promise<string> {
259+
const context = new CallTreeContext(callTree);
260+
const response = await Array.fromAsync(this.run(AI_LABEL_GENERATION_PROMPT, {selected: context}));
261+
const lastResponse = response.at(-1);
262+
if (lastResponse && lastResponse.type === ResponseType.ANSWER && lastResponse.complete === true) {
263+
return lastResponse.text.trim();
264+
}
265+
throw new Error('Failed to generate AI entry label');
266+
}
258267
}
268+
269+
const AI_LABEL_GENERATION_PROMPT = `## Instruction:
270+
Generate a concise label (max 60 chars, single line) describing the *user-visible effect* of the selected call tree's activity, based solely on the provided call tree data.
271+
272+
## Strict Constraints:
273+
- Output must be a single line of text.
274+
- Maximum 60 characters.
275+
- No full stops.
276+
- Focus on user impact, not internal operations.
277+
- Do not include the name of the selected event.
278+
- Do not make assumptions about when the activity happened.
279+
- Base the description only on the information present within the call tree data.
280+
- Prioritize brevity.
281+
- Only include third-party script names if their identification is highly confident.
282+
- Always use "responsiveness" rather than "user interaction responsiveness".
283+
`;

front_end/models/ai_assistance/agents/PerformanceAnnotationsAgent.test.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

front_end/models/ai_assistance/agents/PerformanceAnnotationsAgent.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

front_end/models/ai_assistance/ai_assistance.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export * from './agents/AiAgent.js';
88
export * from './agents/FileAgent.js';
99
export * from './agents/NetworkAgent.js';
1010
export * from './agents/PerformanceAgent.js';
11-
export * from './agents/PerformanceAnnotationsAgent.js';
1211
export * from './agents/PerformanceInsightsAgent.js';
1312
export * from './agents/StylingAgent.js';
1413
export * from './agents/PatchAgent.js';

front_end/panels/timeline/overlays/OverlaysImpl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ describeWithEnvironment('Overlays', () => {
590590
const generateButton = elementsWrapper.querySelector<HTMLElement>('.ai-label-button');
591591
assert.isOk(generateButton, 'could not find "Generate label" button');
592592
assert.isTrue(generateButton.classList.contains('enabled'));
593-
const agent = new AiAssistanceModels.PerformanceAnnotationsAgent({
593+
const agent = new AiAssistanceModels.PerformanceAgent({
594594
aidaClient: mockAidaClient([[{
595595
explanation: 'This is an interesting entry',
596596
metadata: {

front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class EntryLabelOverlay extends HTMLElement {
189189
#callTree: Utils.AICallTree.AICallTree|null = null;
190190
// Creates or gets the setting if it exists.
191191
#aiAnnotationsEnabledSetting = Common.Settings.Settings.instance().createSetting('ai-annotations-enabled', false);
192-
#agent = new AiAssistanceModels.PerformanceAnnotationsAgent({
192+
#performanceAgent = new AiAssistanceModels.PerformanceAgent({
193193
aidaClient: new Host.AidaClient.AidaClient(),
194194
serverSideLoggingEnabled: isAiAssistanceServerSideLoggingEnabled(),
195195
});
@@ -249,8 +249,8 @@ export class EntryLabelOverlay extends HTMLElement {
249249
/**
250250
* So we can provide a mocked agent in tests. Do not call this method outside of a test!
251251
*/
252-
overrideAIAgentForTest(agent: AiAssistanceModels.PerformanceAnnotationsAgent): void {
253-
this.#agent = agent;
252+
overrideAIAgentForTest(agent: AiAssistanceModels.PerformanceAgent): void {
253+
this.#performanceAgent = agent;
254254
}
255255

256256
connectedCallback(): void {
@@ -521,7 +521,7 @@ export class EntryLabelOverlay extends HTMLElement {
521521
this.#focusInputBox();
522522
void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#boundRender);
523523

524-
this.#label = await this.#agent.generateAIEntryLabel(this.#callTree);
524+
this.#label = await this.#performanceAgent.generateAIEntryLabel(this.#callTree);
525525
this.dispatchEvent(new EntryLabelChangeEvent(this.#label));
526526
this.#inputField.innerText = this.#label;
527527

0 commit comments

Comments
 (0)