Skip to content

Commit 1cf91cc

Browse files
update md
1 parent 93ff534 commit 1cf91cc

File tree

1 file changed

+36
-40
lines changed

1 file changed

+36
-40
lines changed

examples/toolkits/browser_skills_example/CAMEL_BROWSER_SKILLS.md

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ The Main Agent is the core of task execution, responsible for:
8484
- Deciding when to invoke existing Skills vs. executing atomic operations
8585
- Coordinating Skill composition and parameter passing
8686

87-
```python
88-
# Usage example
89-
agent = SkillsAgent(
90-
skills_dir="./browser_skills", # Skill directory, defaults to ./browser_skills
91-
)
92-
await agent.initialize()
93-
result = await agent.run("Search for one-way flights from Beijing to Shanghai")
94-
```
95-
9687
### 2. Subtask Extractor (Task Agent)
9788

9889
**File**: `subtask_extractor.py`
@@ -106,12 +97,6 @@ The Task Agent analyzes successfully executed task logs and splits them into reu
10697
- Configurable parameters (variables)
10798
- Execution preconditions
10899

109-
```python
110-
# Analysis flow
111-
groups = extract_consecutive_individual_actions(session_log_path)
112-
subtasks = analyze_subtask_candidates(groups, existing_subtasks)
113-
```
114-
115100
### 3. Recovery Agent
116101

117102
**File**: `action_replayer.py`
@@ -127,10 +112,10 @@ When element location fails during Skill replay, the Recovery Agent intervenes:
127112

128113
```python
129114
# Recovery Agent workflow
130-
result_ref = await replayer.consult_recovery_agent(
131-
current_snapshot=page_snapshot,
132-
target_label="Where from?",
115+
result_ref = await replayer.agent_recovery(
133116
failed_action="click",
117+
target_label="Where from?",
118+
current_snapshot=page_snapshot,
134119
error_message="Element not found"
135120
)
136121
```
@@ -265,25 +250,6 @@ Reasons:
265250
- Consecutive `individual_action` entries indicate scenarios not covered by the skill library
266251
- These new interaction patterns are exactly what needs to be learned and encapsulated
267252

268-
```python
269-
# Extraction logic in subtask_extractor.py
270-
def extract_consecutive_individual_actions(timeline):
271-
"""Extract consecutive individual_action groups"""
272-
groups = []
273-
current_group = []
274-
275-
for entry in timeline:
276-
if entry.get('action_type') == 'individual_action':
277-
current_group.append(entry)
278-
else:
279-
# Upon encountering subtask_replay, save current group (at least 2 actions)
280-
if len(current_group) >= 2:
281-
groups.append(current_group)
282-
current_group = []
283-
284-
return groups
285-
```
286-
287253
### Example: Mixed Execution Timeline
288254

289255
```json
@@ -483,6 +449,21 @@ When element locating fails, the Recovery Agent will:
483449

484450
## Usage
485451

452+
### 0. Prerequisites: Start Chrome with CDP
453+
454+
Before running, start Chrome with Chrome DevTools Protocol (CDP) enabled:
455+
456+
```bash
457+
# macOS
458+
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9223
459+
460+
# Linux
461+
google-chrome --remote-debugging-port=9223
462+
463+
# Windows
464+
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9223
465+
```
466+
486467
### 1. Install Dependencies
487468

488469
Same with CAMEL framework.
@@ -493,17 +474,32 @@ Same with CAMEL framework.
493474
from browser_skills_example import SkillsAgent
494475
import asyncio
495476
477+
496478
async def main():
479+
# Create agent with skills directory
497480
agent = SkillsAgent(
498481
skills_dir="./browser_skills", # Optional, defaults to ./browser_skills
499482
)
500-
await agent.initialize()
483+
484+
# Initialize agent (connects to browser via CDP)
485+
success = await agent.initialize()
486+
if not success:
487+
print("Failed to initialize. Make sure Chrome is running with CDP enabled.")
488+
return
489+
490+
# Run the task
501491
result = await agent.run(
502492
"Search for one-way flights from Tokyo to Osaka on Feb 20"
503493
)
504494
print(result)
505495
506-
asyncio.run(main())
496+
# Print statistics and save logs
497+
agent.print_statistics()
498+
agent.save_communication_log()
499+
500+
501+
if __name__ == "__main__":
502+
asyncio.run(main())
507503
```
508504

509505
### 3. Analyze New Tasks and Extract Subtasks
@@ -525,7 +521,7 @@ python subtask_to_skill_converter.py --clean
525521

526522
### 5. Verify Skill Loading
527523

528-
```bash``
524+
```bash
529525
python skill_loader.py
530526
```
531527

0 commit comments

Comments
 (0)