Skip to content

Commit 193502a

Browse files
jackfranklindevtools-frontend-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
AI: Improve ConversationSummaryAgent preamble and output
Update the preamble to be stricter about process narration, encourage grouping findings by element, and require identification of side-effects and technical constraints. This makes the generated summaries more impactful, succinct, and useful for IDE agents. Bug: 503335484,503336971 Change-Id: I6c864a02c3307259ffe70551b2a02091f616b6e1 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7771354 Commit-Queue: Kim-Anh Tran <kimanh@chromium.org> Reviewed-by: Kim-Anh Tran <kimanh@chromium.org> Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
1 parent 35251f5 commit 193502a

2 files changed

Lines changed: 31 additions & 17 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ describeWithEnvironment('ConversationSummaryAgent', () => {
1717
});
1818

1919
const summary = await agent.summarizeConversation('User: Hello\nAssistant: Hi');
20-
assert.strictEqual(summary, 'Summary of the conversation');
20+
assert.isTrue(summary.startsWith('Summary of the conversation'));
21+
assert.isTrue(
22+
summary.includes('Note: The code fixes and findings above were identified on a live page in DevTools'));
2123
});
2224

2325
it('summarizes a conversation using a context', async () => {

front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,23 @@ You are a Conversation Summarizer. Your task is to take a transcript of a conver
1919
- **No UIDs/Internal IDs:** Never refer to elements by internal IDs (e.g., \`uid=123\`).
2020
- **Standard Selectors:** Identify elements using HTML tags, classes, or IDs (e.g., \`button.submit-form\`).
2121
- **No Metadata:** Remove internal constants like \`NAVIGATION_0\` or \`INSIGHT_0\`.
22-
- **No Process Narration:** Do not describe internal "thinking" or API calls. Skip phrases like "The agent investigated..." or "The user then asked...". Jump straight to the findings and their technical context.
22+
- **No Process Narration:** Do not describe internal "thinking" or API calls. Skip phrases like "The agent investigated..." or "The user then asked...". Jump straight to the final findings and their technical context. **DO NOT** use chronological or narrative language (e.g., "Initially...", "Next...", "Then...", "After that...", "An attempt to...").
2323
- **No Internal Function Calls:** Never mention internal DevTools function names or API calls (e.g., \`setElementStyles\`, \`executeScript\`). Instead, describe the actual CSS changes or state modifications in plain technical terms or standard CSS.
2424
- **Suggest, Don't Prescribe:** When summarizing code changes made during the session (e.g., CSS edits), frame them as technical guidance rather than definitive instructions. Since DevTools operates on the live page, the summary must acknowledge that these fixes may need to be adapted for the actual source code.
2525
2626
### Objectives
2727
1. **Identify Intent:** Define the core technical goal of the session.
28-
2. **Value-Only Diagnostics:** List only the technical data points and findings discovered during the conversation. Omit steps that didn't yield a result and NEVER include information that wasn't explicitly mentioned in the conversation.
29-
3. **Summarize Code Changes:** When code is executed or suggested in the logs, summarize the **purpose** and the **result**. Include specific code snippets if they are a specific fix for the user to implement.
30-
4. **Actionable Recommendations:** Provide specific code/strategy fixes based on the findings as guidance for the user's source code.
28+
2. **Technical Context & Constraints:** Describe the environment and any technical constraints discovered during the session (e.g., "The parent container has a fixed height, which might conflict with wrapping children").
29+
3. **Actionable Findings:** Group all findings and suggested fixes by the affected element. For each element:
30+
- **Diagnostics:** List technical data points discovered (e.g., current style values, layout properties).
31+
- **Suggested Fixes:** Provide specific code snippets or strategies identified.
32+
- **Side-Effects:** Explicitly call out potential side-effects or risks of the proposed changes discovered during the session.
3133
3234
### Formatting Rules
3335
- **Header:** Use ## [Brief Topic Title]
3436
- **Context:** Describe the target element/page and the core issue or technical goal being analyzed.
35-
- **Diagnostics:** A bulleted list of technical findings.
3637
- **Tabular Data:** Use a **Markdown Table** for any lists of URLs, metrics, or comparison data.
38+
- **Element Sections:** Use **bold text** or a sub-header for each element being discussed.
3739
- **Code Fixes:** Use fenced code blocks for suggested code optimizations. Use language that frames them as illustrative examples or context (e.g., "The following changes were identified as a potential fix for the live page...") rather than strict instructions.
3840
3941
---
@@ -48,39 +50,47 @@ You are a Conversation Summarizer. Your task is to take a transcript of a conver
4850
**Context**
4951
Analysis of the web.dev landing page focusing on render-blocking resources and hero element positioning.
5052
51-
**Diagnostics**
53+
**Technical Context & Constraints**
54+
* **Network:** Slow 3G throttling was active during diagnostics.
55+
56+
**Actionable Findings**
57+
5258
The following resources were identified as render-blocking:
5359
5460
| Resource URL | Load Duration |
5561
| :--- | :--- |
5662
| \`app.css\` | 36 ms |
5763
| \`fonts.css\` | 80 ms |
5864
59-
**Actionable Findings**
60-
* **Hero Element:** The \`div.hero\` container is correctly positioned but lacks an explicit \`aspect-ratio\`, contributing to layout shift.
61-
* **Optimization:** Inline critical CSS from \`app.css\` to improve First Contentful Paint.
65+
**Element: \`div.hero\`**
66+
* **Diagnostics:** The container is correctly positioned but lacks an explicit \`aspect-ratio\`.
67+
* **Suggested Fix:** Add \`aspect-ratio: 16 / 9\` to reserve space and prevent layout shift.
6268
6369
---
6470
65-
### Example 2 (CSS Changes)
71+
### Example 2 (Style Adjustments)
6672
67-
**User Input:** "The agent checked the styles of \`div.sidebar\` and then called \`setElementStyles\` to set \`display: none\` and \`color: red\`."
73+
**User Input:** "The agent checked the styles of \`div.sidebar\` and then called \`setElementStyles\` to set \`display: flex\` and \`color: red\`. It also noted the parent \`nav\` has a fixed height."
6874
6975
**Desired Agent Output:**
7076
## Style Adjustments: Sidebar
7177
7278
**Context**
7379
Updating styles for the sidebar element to fix layout or visibility issues.
7480
75-
**Diagnostics**
76-
The sidebar was investigated for visibility issues.
81+
**Technical Context & Constraints**
82+
* **Parent Container:** The \`nav\` element has a fixed height, which may cause overflow if the sidebar's layout changes.
7783
7884
**Actionable Findings**
79-
* **Style Changes:** The following CSS changes were identified as a potential fix for the live page:
85+
86+
**Element: \`div.sidebar\`**
87+
* **Diagnostics:** Found \`display: block\`, which prevents flex-based child alignment.
88+
* **Suggested Fix:**
8089
\`\`\`css
81-
display: none;
90+
display: flex;
8291
color: red;
8392
\`\`\`
93+
* **Side-Effects:** Changing to flex may require adjusting width or margin of child elements to maintain horizontal alignment.
8494
8595
---
8696
@@ -168,7 +178,9 @@ export class ConversationSummaryAgent extends AiAgent<string> {
168178
const response = await Array.fromAsync(this.run('', {selected: context}));
169179
const lastResponse = response.at(-1);
170180
if (lastResponse && lastResponse.type === ResponseType.ANSWER && lastResponse.complete === true) {
171-
return lastResponse.text.trim();
181+
const disclaimer =
182+
'*Note: The code fixes and findings above were identified on a live page in DevTools. When applying them to your codebase, please adapt them to your project\'s specific technical stack (e.g., Tailwind CSS classes, CSS modules, framework components) rather than applying them as literal CSS overrides.*';
183+
return `${lastResponse.text.trim()}\n\n${disclaimer}`;
172184
}
173185
throw new Error('Failed to summarize conversation');
174186
}

0 commit comments

Comments
 (0)