Skip to content

feat: browser_external_cdp#696

Open
nitpicker55555 wants to merge 62 commits intomainfrom
feat/browser_external_cdp
Open

feat: browser_external_cdp#696
nitpicker55555 wants to merge 62 commits intomainfrom
feat/browser_external_cdp

Conversation

@nitpicker55555
Copy link
Collaborator

Description

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@nitpicker55555 nitpicker55555 marked this pull request as draft November 19, 2025 15:50
@nitpicker55555 nitpicker55555 self-assigned this Nov 19, 2025
@nitpicker55555
Copy link
Collaborator Author

Need this camel pr https://github.com/camel-ai/camel/pull/3666/files

@nitpicker55555 nitpicker55555 marked this pull request as ready for review January 14, 2026 12:09
@a7m-1st a7m-1st self-requested a review January 14, 2026 12:19
Copy link
Collaborator

@a7m-1st a7m-1st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nitpicker55555 for the PR, I have added some enhancements in #849, I figured ListenerAgent.clone is the main focus (btw according to the callstack its mostly triggered when workforce.reset() is called :) ) but generally can't find logic issues.

I analyzed if the cdp clone operation was only happening for search agents only as it should be and bcz of the _cdp_acquire_callback it seems search_agent is the only one that has it 👍

@a7m-1st
Copy link
Collaborator

a7m-1st commented Jan 15, 2026

Clone Operation Overview

%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor':'#ffffff', 'primaryBorderColor':'#cccccc', 'background':'#ffffff', 'mainBkg':'#ffffff', 'secondBkg':'#ffffff', 'tertiaryColor':'#ffffff'}}}%%
sequenceDiagram
  participant P as Parent Agent (ListenChatAgent)
  participant M as CDP Manager (_cdp_pool_manager)
  participant TK as Toolkit (HybridBrowserToolkit)
  participant A as New Agent (Cloned)

  Note over P: clone(with_memory=True/False)
  P->>P: Generate Clone ID & unique Session ID
  
  rect rgb(230, 240, 255)
    Note right of P: CDP Pre-acquisition (If callback exists)
    P->>M: acquire_browser(cdp_browsers, new_session_id)
    M-->>P: Return Port (e.g., 9223)
    P->>TK: Temporarily change CDP URL to localhost:9223
  end

  P->>P: _clone_tools() (Deep copy of tool definitions)
  
  rect rgb(255, 240, 230)
    Note right of P: Restore Parent State
    P->>TK: Restore original CDP URL (e.g., localhost:9222)
  end

  P->>A: Instantiate ListenChatAgent with cloned tools
  P->>A: Copy Metadata (task_id, callbacks, options)

  Note over A: Post-Init Configuration
  A->>A: find HybridBrowserToolkit in cloned tools
  A->>A: Set _browser_toolkit & _cleanup_callback

  alt with_memory is True
    P->>P: memory.retrieve() (Get all records)
    P->>A: memory.write_record() (Populate history)
  end

  P-->>User: Return New Agent
Loading

nitpicker55555 and others added 15 commits January 15, 2026 23:47
# Conflicts:
#	backend/app/service/chat_service.py
#	backend/app/utils/agent.py
#	backend/app/utils/single_agent_worker.py
#	backend/app/utils/toolkit/hybrid_browser_toolkit.py
#	electron/main/index.ts
#	electron/preload/index.ts
#	src/pages/Dashboard/Browser.tsx
#	src/store/chatStore.ts
…nt into feat/browser_external_cdp

# Conflicts:
#	backend/app/agent/toolkit/hybrid_browser_toolkit.py
#	backend/app/service/chat_service.py
#	backend/app/utils/agent.py
#	backend/app/utils/listen/toolkit_listen.py
- listen_chat_agent.py: keep lock-protected clone with try/except/finally
- workforce.py: adopt release_by_task instead of clear_all for precise cleanup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants