Skip to content

fix(openclaw): keep the Python launcher fallback off the working directory - #4843

Open
chopratejas wants to merge 5 commits into
mainfrom
fix/openclaw-python-launcher-path
Open

chopratejas wants to merge 5 commits into
mainfrom
fix/openclaw-python-launcher-path

Conversation

@chopratejas

@chopratejas chopratejas commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

ProxyManager.buildLaunchSpecs() (plugins/openclaw/src/proxy-manager.ts) has a Python fallback: it probes with python -c "...find_spec('headroom')..." and starts the proxy with python -m headroom.cli proxy .... Both put the current directory first on sys.path, and the spawned process inherits OpenClaw's working directory, so a headroom/ folder there was found and run instead of the installed package.

Both the probe and the launch now pass -P (Python 3.11+: do not prepend the cwd to sys.path). Interpreters older than 3.11 reject -P, so their probe fails and the launcher moves on; headroom-ai requires 3.11+ so they could not hold a real install. -P rather than -I keeps PYTHONPATH and user-site installs working.

Companion to the same change in plugins/headroom-agent-hooks/bin/headroom-hook.sh (#4842); kept separate because this plugin has its own test suite.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • plugins/openclaw/src/proxy-manager.ts: -P on the configured-python and fallback-python launch and probe args.
  • plugins/openclaw/test/proxy-manager.test.ts: updated expected args; new test that runs each Python spec's probe with a real Python 3.11+ (site-packages disabled) from a directory containing a headroom/ package and expects "not found".

Testing

  • Unit tests pass (vitest)
  • Linting passes (ruff check .) (no Python changed)
  • Type checking passes (npm run typecheck)
  • New tests added for new functionality
  • Manual testing performed

Test Output

# new test on origin/main (fix stashed), python3 = 3.12
$ npx vitest run test/proxy-manager.test.ts -t "working directory"
AssertionError: expected +0 to be 1 // Object.is equality
      Tests  1 failed | 34 skipped (35)

# with the fix
$ npx vitest run test/proxy-manager.test.ts
      Tests  35 passed (35)
$ npx vitest run
      Tests  2 failed | 161 passed (163)
# the 2 failures are test/advancement-key-store.test.ts "...two separate OS processes..."; they fail identically on origin/main (2 failed | 160 passed) and are unrelated.
$ npm run typecheck
(no output, exit 0)

Real Behavior Proof

  • Environment: macOS, Node + vitest from the plugin's lockfile, Python 3.12.
  • Exact command / steps: in a temp dir containing headroom/__init__.py, run each Python launch spec's probe as python3 -S <checkArgs> (-S so no installed headroom can be seen).
  • Observed result: main exits 0 (the folder in the cwd is accepted as headroom); this branch exits 1 (not found), so the launcher would move to the next spec.
  • Not tested: Windows py launcher (it forwards -P to the interpreter).

Runtime Rollout Safety

  • Rollout-managed feature(s): none
  • Minimum rollout channel: n/a
  • Stable/default behavior changed: the Python fallback only starts an installed headroom; a source checkout reachable only through the cwd is no longer picked up (set pythonPath/PYTHONPATH, or put headroom on PATH).
  • Kill switch / disable path: a headroom executable on PATH or an explicit proxyUrl bypasses the fallback.
  • Unsafe override required: no
  • Qualification impact: none
  • Rollback path: revert this PR

Review Readiness

  • I have performed a self-review
  • This PR is ready for human review

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I did not edit CHANGELOG.md

Additional Notes

No docs change needed.

🤖 Generated with Claude Code


Devin Review

Reported by @JoaoMarcos44. Thank you for your contribution! 🩵

…ctory

The proxy manager's Python fallback checked for headroom with
`python -c` and started it with `python -m headroom.cli`, both of which
put the current directory first on sys.path, so a headroom/ folder in
the directory OpenClaw runs from was used instead of the installed
package. Both now pass -P (Python 3.11+); older interpreters reject it
and the launcher moves on.

Assay-Kind: bugfix
Assay-Ask: The OpenClaw plugin's Python launcher fallback could import a headroom package from the working directory instead of the installed one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chopratejas chopratejas added bug Something isn't working javascript Pull requests that update javascript code size: small At most 100 added/deleted lines. risk: low Scope estimate: documentation/tests-only change; verification still required. area: integrations Touches integrations files; triage routing, not a CODEOWNERS assignment. labels Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR governance

This PR follows the template and is marked ready for human review.

@github-actions github-actions Bot added status: ready for review Pull request body is complete and the author marked it ready for human review status: ci failing Required or reported CI checks are failing and removed status: ready for review Pull request body is complete and the author marked it ready for human review labels Nov 13, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

With PYTHONPATH pointing at a headroom checkout the probe found that
package and the test failed for a reason unrelated to the working
directory. The probe now also runs with -E.

Assay-Kind: tests
Assay-Ask: The OpenClaw working-directory probe test failed whenever PYTHONPATH contained a headroom package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the status: ready for review Pull request body is complete and the author marked it ready for human review label Nov 13, 2026
@github-actions github-actions Bot removed the status: ci failing Required or reported CI checks are failing label Nov 13, 2026
Picks up the dependency updates from #4835 so the audit checks pass.

Assay-Kind: deps
Assay-Ask: The dependency audit checks failed on this PR because the branch predates the dependency updates on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Python fallback change looks correct. I independently ran all 35 proxy-manager tests and TypeScript checking successfully. Real Python probes from a directory containing headroom/init.py exit 0 with the target-branch implementation and exit 1 with this change, confirming that cwd discovery is excluded. The PYTHONPATH review finding is resolved by -E in the regression test. I found no additional code defect. Qualification remains held by the inherited shared workflow provenance audit. Separately, the current commitlint job failed; its diagnostic log is needed to determine the cause before readiness can be established. Windows py and the full plugin suite were not independently tested.

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Python launcher fix and its regression test remain supported by the prior independent 35-test run, TypeScript check, and real Python head/base probes at this same commit. The newly available CI log identifies the remaining blocker: commit e75532b (chore: merge main into fix/openclaw-python-launcher-path) has a 116-character Assay-Ask footer. Commitlint job 132208024108 in run 43518951621 fails with footer-max-line-length; it requires at most 100 characters per footer line. Please reword that commit to wrap the footer and obtain a passing commitlint result. For example:

Assay-Ask: The dependency audit failed because this branch predates
 the dependency updates on main.

No additional source defect found. Windows py and the full plugin suite were not independently tested. Inherited workflow provenance issues remain separately recorded and do not drive this change request under the supplied review-only baseline.

@github-actions github-actions Bot removed the status: ready for review Pull request body is complete and the author marked it ready for human review label Nov 14, 2026

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The previously reported commit-message blocker remains at the current head. CI run 43547215469, commitlint job 132301219755, fails with footer-max-line-length on commit e75532b. Its Assay-Ask footer is 116 characters; the limit is 100. Please reword that commit to wrap the footer and obtain a passing commitlint result. For example:

Assay-Ask: The dependency audit checks failed because this branch predates
 the dependency updates on main.

I rechecked both changed files against the current target and found no additional source defect. Earlier-head passing tests are context only; no new unit-test run is claimed. Inherited workflow provenance holds are recorded separately and are not the reason for this change request.

@github-actions github-actions Bot added status: ready for review Pull request body is complete and the author marked it ready for human review and removed status: ready for review Pull request body is complete and the author marked it ready for human review labels Nov 14, 2026
@JerrettDavis JerrettDavis added status: ci failing Required or reported CI checks are failing status: code changes requested labels Nov 14, 2026
@chopratejas

Copy link
Copy Markdown
Collaborator Author

Jerrett, the commitlint blocker is cleared. The footer-length rule fix (#4868) is merged into main, and I merged main into this branch, so commitlint now passes on this head. No code changes in this update.

@github-actions github-actions Bot added status: ready for review Pull request body is complete and the author marked it ready for human review and removed status: ci failing Required or reported CI checks are failing status: ready for review Pull request body is complete and the author marked it ready for human review labels Nov 14, 2026

This branch was successfully deployed

1 active deployment
Preview — ccd53a49 Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: integrations Touches integrations files; triage routing, not a CODEOWNERS assignment. bug Something isn't working javascript Pull requests that update javascript code risk: low Scope estimate: documentation/tests-only change; verification still required. size: small At most 100 added/deleted lines. status: code changes requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants