Skip to content

Lazy-load the heavy runtime behind a lightweight extension entrypoint #144

Description

@leo-cheron

Problem

Installing pi-agent-browser-native as a normal Pi/OMP extension eagerly imports its large runtime graph during every session startup, even when no browser work is requested.

Controlled OMP 18.0.3 RPC benchmark (--no-session --no-skills --no-rules, isolated profile/cwd, 5 warmups, 30 samples):

Configuration Median
No extensions 1.28 s
pi-agent-browser-native@0.5.0 loaded directly 1.69 s
Same 0.5.0 entrypoint behind a dynamic-import façade 1.23 s

The eager entrypoint adds about 410 ms. This is import/initialization cost, not browser launch; the package already avoids spawning browser subprocesses during registration.

Proposal

Split the extension into:

  1. A lightweight entrypoint that registers the public tool schema and essential lifecycle hooks.
  2. A heavy runtime module loaded once, via a shared dynamic-import promise, when agent_browser is first executed or browser-specific prompt handling is required.

The façade should preserve current lifecycle behavior by retaining/replaying the active session context when the runtime initializes. Please account for session_start, session_tree, session_shutdown, prompt guidance, conditional agent_browser_web_search registration, and cleanup behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions