Skip to content

fix(acp): retry npx cache warm online and surface npm stderr - #6831

Open
peterzhang987723 wants to merge 1 commit into
OpenHands:mainfrom
peterzhang987723:fix/acp-npx-cache-warm-retry
Open

peterzhang987723 wants to merge 1 commit into
OpenHands:mainfrom
peterzhang987723:fix/acp-npx-cache-warm-retry

Conversation

@peterzhang987723

@peterzhang987723 peterzhang987723 commented Nov 14, 2026 •

Copy link
Copy Markdown

HUMAN:
Fixes #6809 by adding an online fallback to _warm_npx_cache when --prefer-offline fails, capturing npm stderr, and propagating cache-warm errors to ACP startup.


AGENT:

Why

When the local npm cache (_npx) already holds an outdated package metadata index, npm exec --prefer-offline --yes <package>@<version> inside _warm_npx_cache fails with ETARGET and never falls back to online resolution. In addition, stderr from npm was discarded (DEVNULL), and failures were downgraded to a warning before _start_acp_server launched npx --prefer-offline again, surfacing a misleading Connection closed error.

Summary

  • Retry _warm_npx_cache once without --prefer-offline when the offline warm pass fails so stale npm metadata caches are refreshed.
  • Capture npm stderr and include the package spec, npm_config_cache path, exit code, and trailing stderr lines in warnings and raised RuntimeErrors.
  • Propagate the cache-warm RuntimeError from _warm_npx_cache in _start_acp_server instead of continuing to launch a broken npx --prefer-offline subprocess.

Issue Number

Fixes #6809

How to Test

uv run pytest tests/sdk/agent/test_acp_agent.py -q
uv run ruff check openhands-sdk tests/sdk/agent/test_acp_agent.py
uv run ruff format --check openhands-sdk tests/sdk/agent/test_acp_agent.py

Observed results on branch HEAD 1b4f253:

  • tests/sdk/agent/test_acp_agent.py: 502 passed (covers mocked npm offline/online fallback, stderr surfacing, and ACPAgent startup propagation; live npm registry downloads were not executed offline).
  • ruff check and ruff format --check: passed.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Jev-Fast-Audit

⚡ Jev fast audit · estimates · 0.24s · commit 1b4f253
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage: ⚠️ reduced context — partial coverage; 6/6 hunks, 2/2 files (missing context: 8).

All estimates and evidence
Estimate Likelihood / value Direct evidence
SQL injection 3.0% No direct hunk selected
Command injection 8.0% F001H001 · openhands-sdk/openhands/sdk/agent/acp_agent.py:2788–2904
Weakened authentication 4.0% No direct hunk selected
Weakened authorization 5.0% No direct hunk selected
Contract regression 30.0% F001H002 · openhands-sdk/openhands/sdk/agent/acp_agent.py:3297–3314
Data loss 4.0% No direct hunk selected
Sensitive data disclosure 6.0% No direct hunk selected
Unexpected data transfer 4.0% No direct hunk selected
Credential misuse 4.0% No direct hunk selected
Untrusted instruction authority 2.0% No direct hunk selected
Package source redirection 4.0% No direct hunk selected
Unverified remote execution 21.0% No direct hunk selected
Privileged environment access 5.0% No direct hunk selected
Security assessment bypass 5.0% No direct hunk selected
Prohibited workload 2.0% No direct hunk selected
Primary concern None selected; confidence 53.0% No primary concern to locate

Signed-off-by: Shoufa Zhang <peterzhang987723@users.noreply.github.com>
@peterzhang987723
peterzhang987723 marked this pull request as draft November 14, 2026 05:27
@peterzhang987723

Copy link
Copy Markdown
Author

@DevinVinson Could you confirm the scope and add the ready-for-dev label to #6809 if agreed? Branch head 1b4f253 retries _warm_npx_cache online when --prefer-offline fails, surfaces npm stderr with the cache path, and propagates cache-warm failures on ACP startup.

@peterzhang987723

Copy link
Copy Markdown
Author

@DevinVinson Following up on #6809: all-hands-bot verified the reproduction on Nov 17 and applied the ready for dev label (with spaces), whereas .github/scripts/check_pr_description.py checks for the exact hyphenated label ready-for-dev. Could a maintainer add ready-for-dev on #6809 so this PR can be marked ready for review and pass Validate PR description?

@DevinVinson

Copy link
Copy Markdown
Member

Thanks for flagging that @peterzhang987723 . I just manually set the label to ready-for-dev and if it gets flipped again I'll fix it.

@peterzhang987723
peterzhang987723 marked this pull request as ready for review November 21, 2026 00:35
@peterzhang987723

Copy link
Copy Markdown
Author

Thanks @DevinVinson! Marked this PR ready for review and Validate PR description is now green — ready whenever a maintainer has a moment to take a look.

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.

[Bug]: ACP npx cache warm uses --prefer-offline with an outdated cache, hides npm's error, and startup fails with 'Connection closed'

2 participants