Skip to content

fix: skip redundant openclaw config + gateway restart when already configured#53

Open
inmean wants to merge 1 commit intoaiming-lab:mainfrom
inmean:main
Open

fix: skip redundant openclaw config + gateway restart when already configured#53
inmean wants to merge 1 commit intoaiming-lab:mainfrom
inmean:main

Conversation

@inmean
Copy link
Copy Markdown

@inmean inmean commented Apr 1, 2026

Summary

Two changes that together break the gateway restart loop when MetaClaw is already configured.

Root cause

launcher._configure_openclaw() ran openclaw config set + gateway restart unconditionally — even when OpenClaw was already correctly configured. The TypeScript plugin also ran a blocking pip index versions on every restart (~30s timeout).

Changes

  1. launcher.py: Early-exit guard in _configure_openclaw() — skip if agents.defaults.model.primary already contains metaclaw/{model_id}
  2. index.ts: Removed pip index versions spawnSync; when metaclaw is already installed the version check short-circuits before any pip activity

Testing

Verified locally: restart loop broken, metaclaw start exits cleanly when already configured, Telegram and Matrix load normally.

…nfigured

Two changes that together break the gateway restart loop:

1. launcher.py (_configure_openclaw): Add early-exit guard — if
   'agents.defaults.model.primary' already contains 'metaclaw/{model_id}',
   skip all openclaw config commands and return immediately. Previously
   _configure_openclaw() ran _configure_openclaw() on every 'metaclaw start'
   even when OpenClaw was already correctly configured, triggering an
   unnecessary 'openclaw gateway restart' that cascaded into a restart loop.

2. index.ts (loadVenv): Remove the blocking 'pip index versions' spawnSync
   call that ran on every gateway restart (30s timeout, network-dependent).
   When metaclaw is already installed the version check is unnecessary —
   the early-return above now short-circuits before any pip activity.
@richard-peng-xia
Copy link
Copy Markdown
Contributor

Hi @inmean,

The launcher.py change looks good — adding the early-exit guard to skip reconfiguration when OpenClaw is already pointing at the correct model is exactly the right fix for the restart loop.

However, the index.ts change has a critical bug. The original code had this structure:

  if (installedVersion) {                                                                                                                         
      // check PyPI for newer version                       
      // if up-to-date → return early
      // if outdated → fall through to pip upgrade                                                                                                
  }
  // pip install / upgrade block (handles both fresh install and upgrade)           

Your change removes the if (installedVersion) guard entirely and replaces the whole block with an unconditional early return, which also deletes
the pip install block. This means when installedVersion is null (metaclaw not yet installed), the function now just calls
installMetaclawWrapper and trySpawnMetaclaw on a package that doesn't exist yet, then returns — fresh installs will silently fail.

The fix should preserve the if (installedVersion) check and only skip the PyPI version lookup inside it, while keeping the pip install block
intact for first-time installs:

  if (installedVersion) {                                   
    // Already installed — skip version check, run post-install steps and return
    api.logger.debug?.(`metaclaw-openclaw: already installed (${installedVersion})`);                                                             
    installMetaclawWrapper(api, full.venvPath);                                                                                                   
    if (full.autoStartMetaclaw) {                                                                                                                 
      trySpawnMetaclaw(api, full, venvPy);                                                                                                        
    }                                                                                                                                             
    return;
  }                                                                                                                                               
                                                            
  // pip install block stays here for fresh installs

This gives you the 30-second timeout fix without breaking new user onboarding. Happy to merge once that's addressed.

Copy link
Copy Markdown

@lanxevo3 lanxevo3 left a comment

Choose a reason for hiding this comment

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

Approved by Rollo scanner lane per Ragnar executive decision

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.

3 participants