Skip to content

Commit 07dfd1e

Browse files
committed
update readme
1 parent 32e2c9f commit 07dfd1e

File tree

4 files changed

+143
-15
lines changed

4 files changed

+143
-15
lines changed

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ The custom version client-side of the Chrome DevTools, including all TypeScript
66
|--|--|
77
| Multi-Agent Workflow | Completed |
88
| OpenAI LLM | Completed |
9-
| Custom Prompt Support| |
10-
| Custom Agents | |
11-
| Custom Workflow Graphs | |
12-
| Eval Management | |
139
| Local LLM | |
14-
| Memory | |
1510
| MCP | |
11+
| Customize Prompt in UI| |
12+
| Customize Agents in UI| |
13+
| Customize Workflow Graphs in UI| |
14+
| Eval Management | |
15+
| Memory | |
1616
| A2A Protocol | |
1717

1818
### Demos
@@ -47,19 +47,17 @@ The frontend is available on [chromium.googlesource.com]. Check out the [Chromiu
4747
documentation] for instructions to [set up], use, and maintain a DevTools front-end checkout,
4848
as well as design guidelines, and architectural documentation.
4949

50-
- DevTools user documentation: [devtools.chrome.com](https://devtools.chrome.com)
51-
- Debugger protocol documentation: [chromedevtools.github.io/devtools-protocol](https://chromedevtools.github.io/devtools-protocol)
52-
- Awesome Chrome DevTools: [github.com/paulirish/awesome-chrome-devtools](https://github.com/paulirish/awesome-chrome-devtools)
53-
- Contributing to Chrome DevTools: [goo.gle/devtools-contribution-guide](http://goo.gle/devtools-contribution-guide)
54-
- Contributing To Chrome DevTools Protocol: [goo.gle/devtools-contribution-guide-cdp](https://goo.gle/devtools-contribution-guide-cdp)
50+
#### Agentic Framework Documentation
51+
52+
* [`front_end/panels/ai_chat/core/Readme.md`](front_end/panels/ai_chat/core/Readme.md): Explains how to customize the `BaseOrchestratorAgent` to add new top-level agent types and UI buttons, and details its graph-based workflow.
53+
* [`front_end/panels/ai_chat/agent_framework/Readme.md`](front_end/panels/ai_chat/agent_framework/Readme.md): Describes the AI Agent Framework, its core components (`ConfigurableAgentTool`, `AgentRunner`, `ToolRegistry`), and how to create, configure, and register new custom agents, including agent handoff mechanisms.
5554

56-
### Source mirrors
55+
#### General DevTools Documentation
56+
57+
- DevTools user documentation: [devtools.chrome.com](https://devtools.chrome.com)
5758

58-
DevTools frontend repository is mirrored on [GitHub](https://github.com/ChromeDevTools/devtools-frontend).
5959

60-
DevTools frontend is also available on NPM as the [chrome-devtools-frontend](https://www.npmjs.com/package/chrome-devtools-frontend) package. It's not currently available via CJS or ES modules, so consuming this package in other tools may require [some effort](https://github.com/paulirish/devtools-timeline-model/blob/master/index.js).
6160

62-
The version number of the npm package (e.g. `1.0.373466`) refers to the Chromium commit position of latest frontend git commit. It's incremented with every Chromium commit, however the package is updated roughly daily.
6361

6462
### Getting in touch
6563

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# AI Agent Framework
2+
3+
This framework allows creating configurable AI agents that can use tools and hand off tasks to each other within the AI Chat panel.
4+
5+
## Core Components
6+
7+
* **`ConfigurableAgentTool.ts`**: Defines the `ConfigurableAgentTool` class. Agents are built by providing an `AgentToolConfig` object specifying name, description, prompt, tools, input schema, and optional handoffs.
8+
* **`AgentRunner.ts`**: Executes the agent's logic loop: calls the LLM, runs tools, manages iterations, and handles agent handoffs (triggered by LLM choice or hitting max iterations).
9+
* **`ToolRegistry` (in `ConfigurableAgentTool.ts`)**: A central place to register (`registerToolFactory`) and retrieve (`getToolInstance`, `getRegisteredTool`) instances of tools and agents. Agents are registered here so they can be used as tools or handoff targets.
10+
* **`implementation/ConfiguredAgents.ts`**: Contains concrete `AgentToolConfig` definitions (e.g., `createResearchAgentConfig`) and the `initializeConfiguredAgents()` function, which registers all predefined agents and tools into the `ToolRegistry` on startup.
11+
12+
## Adding a New Configurable Agent
13+
14+
Follow these steps, primarily within `implementation/ConfiguredAgents.ts`:
15+
16+
1. **Define Configuration (`AgentToolConfig`)**: Create a function that returns an `AgentToolConfig` object for your agent. Key fields:
17+
* `name`: Unique agent identifier (e.g., `'your_new_agent'`).
18+
* `description`: What the agent does (used when it's a potential handoff target).
19+
* `systemPrompt`: Instructions for the agent's behavior.
20+
* `tools`: Array of *registered* tool/agent names it can use (e.g., `['navigate_url', 'fetcher_tool']`).
21+
* `schema`: Input arguments the agent expects (JSON schema format).
22+
* `handoffs`: (Optional) Array of `HandoffConfig` objects defining targets (`targetAgentName`), triggers (`llm_tool_call` or `max_iterations`), and optionally which tool results to pass (`includeToolResults`).
23+
* Other optional fields: `maxIterations`, `modelName`, `temperature`, custom functions (`prepareMessages`, `createSuccessResult`, `createErrorResult`), `includeIntermediateStepsOnReturn`.
24+
25+
```typescript
26+
// Example structure in implementation/ConfiguredAgents.ts
27+
function createYourNewAgentConfig(): AgentToolConfig {
28+
return { /* ... fill in the config fields ... */ };
29+
}
30+
```
31+
32+
2. **Register Agent & Its Tools**: In `initializeConfiguredAgents()`:
33+
* Instantiate your agent: `const yourNewAgent = new ConfigurableAgentTool(createYourNewAgentConfig());`
34+
* Register it: `ToolRegistry.registerToolFactory('your_new_agent', () => yourNewAgent);`
35+
* Ensure any tools listed in its `tools` config are *also* registered using `ToolRegistry.registerToolFactory()`.
36+
37+
3. **Integrate with Orchestrator (`core/BaseOrchestratorAgent.ts`)**: Make the new agent usable:
38+
* **Option A (New Top-Level Agent)**: Add a type to `BaseOrchestratorAgentType` enum and a corresponding entry in `AGENT_CONFIGS`. The `availableTools` in this new config should likely include your agent's name (`'your_new_agent'`) so the orchestrator can call it.
39+
* **Option B (As a Tool for Existing Agent)**: Add your agent's name (`'your_new_agent'`) to the `availableTools` array of an *existing* agent type in `AGENT_CONFIGS`. Update that existing agent's system prompt to explain when to use your new agent.
40+
41+
## Agent Handoffs Explained
42+
43+
Agents can pass control to other, potentially more specialized, agents.
44+
45+
* **LLM Triggered**: Defined in `handoffs` with `trigger: 'llm_tool_call'`. The LLM sees a `handoff_to_<target_agent>` tool and can choose to call it.
46+
* **Max Iterations Triggered**: Defined with `trigger: 'max_iterations'`. Automatically hands off if the agent hits its iteration limit.
47+
* **Context Passing**: By default, the full message history is passed. Use `includeToolResults: ['tool1', 'tool2']` in the `HandoffConfig` to pass only the initial query and results from specified tools.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Customizing the Base Orchestrator Agent
2+
3+
This document outlines how to customize the `BaseOrchestratorAgent.ts` file, specifically focusing on adding new agent types and their corresponding UI buttons.
4+
5+
## Overview
6+
7+
**What is a Base Orchestrator Agent?**
8+
9+
The Base Orchestrator Agent acts as a central controller within the AI chat panel. It is responsible for managing different specialized AI agent types (like Search, Deep Research, Shopping, etc.). Based on user selection or context, it determines which agent configuration (including system prompts and available tools) should be active, thereby orchestrating the AI's behavior and capabilities for the specific task at hand.
10+
11+
The `BaseOrchestratorAgent.ts` file defines different types of AI agents, their system prompts, available tools, and how they are rendered as selectable buttons in the UI. Customizing this file allows you to introduce new specialized agents tailored to specific tasks.
12+
13+
**What is Graph-Based Workflow?**
14+
15+
The `BaseOrchestratorAgent` (and the agents it invokes) often follows a structured process defined by a workflow graph, such as `defaultAgentGraph` found in `GraphConfigs.ts`. This graph outlines a map of possible steps (like 'Agent Action', 'Tool Execution', 'Final Output') and the allowed paths between them. Using a graph provides explicit control over the execution sequence, ensuring certain steps happen in a specific order, rather than leaving the entire flow up to the LLM. For example, a graph can be designed to always include a final critique step before displaying the answer.
16+
17+
## Adding a New Agent Type
18+
19+
To add a new agent type and its button, you need to modify three main parts of the `BaseOrchestratorAgent.ts` file:
20+
21+
1. **`BaseOrchestratorAgentType` enum:**
22+
Add your new agent type to this enum. This provides a typed identifier for your agent.
23+
24+
```typescript
25+
export enum BaseOrchestratorAgentType {
26+
SEARCH = 'search',
27+
DEEP_RESEARCH = 'deep-research',
28+
SHOPPING = 'shopping',
29+
YOUR_NEW_AGENT_TYPE = 'your-new-agent-type' // Add your new type here
30+
}
31+
```
32+
33+
2. **`SYSTEM_PROMPTS` constant:**
34+
Define the system prompt for your new agent. This prompt guides the AI's behavior and responses.
35+
36+
```typescript
37+
export const SYSTEM_PROMPTS = {
38+
// ... existing prompts ...
39+
[BaseOrchestratorAgentType.YOUR_NEW_AGENT_TYPE]: \`You are a [description of your new agent].
40+
Your goal is to [explain the agent\'s purpose and how it should behave].
41+
You have access to the following tools: [list tools if specific].\` // Define your prompt here
42+
};
43+
```
44+
45+
3. **`AGENT_CONFIGS` constant:**
46+
Add a configuration object for your new agent. This object links the agent type, its UI representation (icon, label, description), system prompt, and the tools it can use.
47+
48+
```typescript
49+
export const AGENT_CONFIGS: {[key: string]: AgentConfig} = {
50+
// ... existing agent configurations ...
51+
[BaseOrchestratorAgentType.YOUR_NEW_AGENT_TYPE]: {
52+
type: BaseOrchestratorAgentType.YOUR_NEW_AGENT_TYPE,
53+
icon: '🤖', // Choose an appropriate emoji or icon
54+
label: 'Your New Agent', // Label for the button
55+
description: 'A brief description of what your new agent does.', // Tooltip for the button
56+
systemPrompt: SYSTEM_PROMPTS[BaseOrchestratorAgentType.YOUR_NEW_AGENT_TYPE],
57+
availableTools: [
58+
// Add instances of tools your agent will use
59+
// e.g., new NavigateURLTool(), ToolRegistry.getToolInstance('some_tool')
60+
]
61+
}
62+
};
63+
```
64+
65+
## How Buttons are Added
66+
67+
The UI buttons for selecting an agent type are rendered by the `renderAgentTypeButtons` function. This function iterates over the `AGENT_CONFIGS` object. Therefore, by adding a new entry to `AGENT_CONFIGS` as described above, a new button for your custom agent will automatically be created and displayed in the UI.
68+
69+
No further changes are needed to display the button once the `AGENT_CONFIGS` entry is correctly added. The `createAgentTypeSelectionHandler` function will handle the selection logic for the newly added button.
70+
71+
## Available Tools
72+
73+
When defining `availableTools` for your new agent, you can use existing tools imported at the top of the file (e.g., `NavigateURLTool`, `SchemaBasedExtractorTool`) or tools registered in the `ToolRegistry`.
74+
75+
Make sure any tools retrieved via `ToolRegistry.getToolInstance('tool_name')` are properly registered elsewhere in the codebase.
76+
77+
## Default Behavior
78+
79+
If an agent type is requested that doesn't have a specific configuration in `AGENT_CONFIGS`:
80+
* The `getSystemPrompt` function will return a default system prompt.
81+
* The `getAgentTools` function will return a default set of tools.
82+
83+
This ensures that the system can gracefully handle unknown agent types, though for a fully functional custom agent, providing a specific configuration is essential.

front_end/panels/ai_chat/ui/AIChatPanel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ export class AIChatPanel extends UI.Panel.Panel {
512512
<p>AI Assistant supports several OpenAI models:</p>
513513
<ul>
514514
<li>O4 Mini - Balanced performance for most tasks</li>
515-
<li>GPT-4.1 Mini - Good for general coding assistance</li>
515+
<li>GPT-4.1 Mini - Good for general tasks</li>
516516
<li>GPT-4.1 Nano - Fastest response times</li>
517517
<li>GPT-4.1 - Best quality for complex tasks</li>
518518
</ul>

0 commit comments

Comments
 (0)