Skip to content

fix: externalize playwright-core in Bun build for browser automation - #723

Closed
alejandroOPI wants to merge 1 commit into
openclaw:mainfrom
alejandroOPI:fix/playwright-externalize
Closed

alejandroOPI wants to merge 1 commit into
openclaw:mainfrom
alejandroOPI:fix/playwright-externalize

Conversation

@alejandroOPI

Copy link
Copy Markdown

Problem

The clawdis_browser tool returns HTTP 501 "Playwright is not available in this gateway build" when trying to use navigate/act actions.

Root Cause

The Bun build script bundles playwright-core into the compiled relay binary. When Bun bundles a module, the dynamic import("./pw-ai.js") can't properly load playwright-core because the module resolution points to the bundled (incomplete) version.

Solution

  • Add -e playwright-core to the Bun build command to externalize the module
  • Copy playwright-core and chromium-bidi to Relay/node_modules/ at build time
  • Bun resolves the external module from the adjacent node_modules directory at runtime

Changes

  • scripts/package-mac-app.sh: Added -e playwright-core and module copy logic
  • docs/mac/bun.md: Updated documentation

Testing

After rebuild, browser automation actions (navigate, click, type, etc.) work via Playwright CDP connection on port 18792.

The browser tool returns 501 'Playwright is not available' because playwright-core
was being bundled by Bun, breaking the dynamic import.

Changes:
- Add -e playwright-core to bun build externals
- Copy playwright-core and chromium-bidi to Relay/node_modules at build time
- Update docs/mac/bun.md with externals explanation

This enables navigate, click, type and other browser automation actions
via Playwright CDP connection.
@alejandroOPI

Copy link
Copy Markdown
Author

Closing - the fix is already included in version 2026.1.10

amittell added a commit to amittell/openclaw that referenced this pull request Aug 25, 2026
MAX_COMPACTION_SUMMARY_CHARS was a fixed 16,000 chars regardless of
context window, so large sessions (~300k+ tokens) were truncated to
~1.5% of history; the quality audit ran on the truncated artifact,
failed missing sections, and retries could not recover truncation —
compaction was structurally guaranteed to fail above a certain size.

resolveCompactionSummaryBudgetChars(contextWindowTokens):
  floor(contextWindowTokens * 0.0125 * 4) clamped to [16_000, 128_000]
Anchors to today's behavior at the 200k default window (existing
MAX_COMPACTION_SUMMARY_CHARS / MAX_SPLIT_TURN_CONTEXT_CHARS exports
unchanged), scales linearly above it. The resolved budget and the
split-turn/preserved section cap (budget/2) are derived once from
contextWindowTokens and threaded into finalizeSummaryText + section
builders. Tests: 270 passed (compaction-safeguard + quality).

Dogfood openclaw#723.
amittell added a commit to amittell/openclaw that referenced this pull request Sep 2, 2026
…uites

Adds the regression tests for the three compaction-safeguard tickets:

- openclaw#721: unit test asserting the missing_identifiers audit reason carries
  the full >4000-char identifier payload, and an end-to-end quality-guard
  scenario asserting every identifier survives in the corrective
  instruction sent to the model.
- openclaw#722: the two final-audit cases now assert degraded fallback behavior
  (compaction proceeds, structured fallback summary, no cancel reason,
  quality_guard_degraded_fallback log line).
- openclaw#723: unit tests for resolveCompactionSummaryBudgetChars (16k floor,
  no-maxTokens ceiling, scaled ceiling, session-size passthrough) and an
  end-to-end scenario asserting a ~1M-char serialized session finalizes
  with all required tail sections plus a 20k filler line intact and no
  truncation marker.

Also updates the test API surface: exports
wrapUntrustedQualityFeedbackBlock + resolveCompactionSummaryBudgetChars,
renames MAX_COMPACTION_SUMMARY_CHARS to the MIN_COMPACTION_SUMMARY_CHARS
floor, and threads per-section maxChars through the preserved/split-turn
section builders.
amittell added a commit to amittell/openclaw that referenced this pull request Sep 3, 2026
…afeguard set

Records the 2026-09-02 22:22/22:35 deploys (stop, build, spare-port smoke,
launchd), that the smoke run performed the api-root-changed rotation on mac-mini,
and Alex's ruling that openclaw#721-openclaw#723 / #5 is the next carry, with
the group-session measurements that motivate it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
amittell added a commit to amittell/openclaw that referenced this pull request Sep 4, 2026
…safeguard set

openclaw#721: the quality audit named only the first three missing identifiers
and the corrective regeneration instruction went through the 4000-char
operator-text wrapper, so a long defect list was cut mid-item; the model
never saw which identifiers to restore and the retry failed the same
audit. The audit now emits the full missing list (bounded by the 12-item
extraction cap) and the corrective pass wraps it with its own 8000-char
budget; operator-supplied text keeps the 4000-char wrapper.

openclaw#723: the finalized summary budget was a fixed 16,000 chars, so a ~1M-char
session's perfect summary lost its required tail sections to truncation
and failed the audit on every retry. The budget is now
clamp(serializedChars, 16k, 16k + (maxTokens - overhead) x 2 x 2): the
legacy floor for small sessions, scaled by what the summarizer can
actually emit for large ones. The provider path has no summarizer model
and finalizes at the floor; the LLM path resolves the budget once it
knows the summarizable size and derives the split-turn/preserved caps
from it.

Ported by hand onto the restructured safeguard (the fork's tests target
compaction-safeguard.test.ts, grandfathered over max-lines); regression
coverage lives in a sibling file. Neutralize check: the openclaw#721 corrective
test and both openclaw#723 tests fail with the production edits reverted; the
anchor control stays green by design.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
amittell added a commit to amittell/openclaw that referenced this pull request Sep 4, 2026
amittell added a commit to amittell/openclaw that referenced this pull request Sep 4, 2026
amittell added a commit to amittell/openclaw that referenced this pull request Sep 17, 2026
Ported from cad37985e06 (upstream PR branch fix/compaction-degrade-instead-of-cancel).
The fork has degraded instead of cancelling since e545867, but it finalized the
fallback with NO retention plan, so the pending user request and the exact identifiers
the audited path budgets for were dropped and the session kept only the empty template.

Retention here cannot be mandatory: one way a session reaches the degrade is required
facts that do not fit the budget, and throwing would strand the session this branch
exists to rescue. finalizeSummaryText takes an opt-in best-effort mode that records a
`quality-retention` loss and refits without the plan.

Resolved against the fork rather than applied as-is:
- kept the fork's openclaw#723 session-scaled ceiling (the 3-arg fitCompactionSummary), made it
  reassignable for the new refit, and gave the refit the same ceiling. Upstream's version
  has no ceiling argument at all.
- the fork's inline degrade block is replaced by the commit's degradeToFallbackSummary
  helper, keeping the fork's reasonCodes/reasonCount in the diagnostic.
- compactionResult gains an optional detail so the boundary records
  `details.qualityDegraded` rather than leaving the log line as the only evidence.
- docs/concepts/compaction.md: took the incoming paragraph. The 9.4 text still described
  upstream's cancel, which this fork has not done since e545867.
- NOT taken: deleting wrapUntrustedQualityFeedbackBlock's 8000-char budget. The upstream
  commit can delete it because its audit is then the only bound; the fork's own tests pin
  that wrapper, and with the audit bounded it can no longer be what cuts the list.

Two tests pinned the pre-fix body and now assert the ask survives. That is the whole
visible effect of the fix, so they are updated rather than relaxed:
  agent-session-compaction.test.ts     "Pending user asks: None." -> the retained ask
  compact.hooks.test.ts                same, on the embedded-runner boundary

Measured in this tree (Air, node 22.23.1):
  compaction-safeguard.test.ts + agent-session-compaction + compact.hooks  365 tests, all pass
  control, production file reverted with the new test kept: 1 failed,
    AssertionError on details.qualityDegraded - it fails on the assertion, not on a throw
  pnpm tsgo:core  exit 0
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.

1 participant