Repository navigation
fix(agent-core): stop depending on @openclaw/ai for ToolArgumentValidationError's runtime identity - #339
Conversation
…ationError's runtime identity (ENG-23048) ToolArgumentValidationError (added in #144 for sentry-monitor classification) lives in packages/llm-core/src/validation.ts, which upstream's base-reset (v2026.7.35, #307/#335/#336) recently extracted into the externally-resolved @openclaw/ai package -- never bundled into the openclaw CLI tarball or the standalone @openclaw/agent-core package, per tsdown.config.ts. Boon never publishes its own @openclaw/ai, so any consumer installing openclaw plus a normal @openclaw/ai from the public registry gets upstream's unpatched package, which has never carried this class. The compiled openclaw package's proxy chunk statically imports it as a value from "@openclaw/ai/validation", crashing at module-evaluation time for any consumer touching openclaw/plugin-sdk/agent-harness. agent-loop.ts's only production use of the class is `.summary` via instanceof, so switch to a structural check and a type-only import; the agent-core validation.ts facade re-exports the type only. Type-only exports erase at build time, so the bundler no longer needs a runtime binding for this symbol from the externally-resolved @openclaw/ai. Verified: packages/llm-core and packages/agent-core unit tests pass; `pnpm build` dist no longer imports the class as a value from @openclaw/ai/validation; oxlint and tsgo:core clean; plugin-sdk SDK-surface export budget unaffected; and end-to-end by copying the fixed dist into a consumer repo (anychat-boon-web) with the real, unpatched public @openclaw/ai still installed -- a test that previously crashed on import now passes. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 2 files
Linked issue analysis
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Avoid a runtime import of the missing validation error class | The agent-core import and facade re-export are type-only, removing the class’s runtime binding. |
| ✅ | Keep validation error summaries in tool-call details | The structural check reads summary from matching errors, and the PR reports the consumer repro passes. |
Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.
View guided diff | Turn on auto-fix | Re-trigger cubic
Trim both ToolArgumentValidationError comments to the short rationale (why the check is structural, not why the package got externalized) per review feedback on keeping changed-source comments focused. Also drop the `instanceof Error` requirement from isToolArgumentValidationError: the check only needs `name`/`summary`, and `instanceof Error` would reject a cross-realm or plain-object error that otherwise carries both fields. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
Correction to exact-head review #5978409684 (APPROVED, commit ba91c49eb67ea741cbaa2bff73a45e1ea9718195). This edit corrects the review text only; the earlier event remains APPROVED in GitHub history and is not erased or dismissed. A separate exact-head REQUEST_CHANGES review (#5978831875) records the current blocker; GitHub's aggregate decision is CHANGES_REQUESTED.
The runtime fix and structural guard are sound, but the public TypeScript declaration remains unusable against the published dependency: the exact-head dist/plugin-sdk/agent-core.d.ts exposes ToolArgumentValidationError through @openclaw/ai/validation, while published @openclaw/[email protected] does not export that type. A strict TypeScript 6.0.3 consumer gets TS2305. Please define a local structural type or remove the invalid public type export, then add a built-consumer check against the registry package.
The earlier statement that all 141 check runs completed green was inaccurate. The current exact-head inventory contains skipped, cancelled, and neutral check runs; the CI workflow, ci-gate, and build-artifacts completed successfully. Both PR commits remain GitHub-verified GPG signatures. This is a body correction only and does not change this review's APPROVED state.
There was a problem hiding this comment.
Corrective exact-head review: Changes requested.
This is not a withdrawal or dismissal of the prior APPROVED review #5978409684 (state APPROVED, exact head ba91c49eb67ea741cbaa2bff73a45e1ea9718195; #339 (review)). It adds a separate blocker on that same head and does not erase or dismiss the earlier approval.
The runtime fix itself looks sound: the missing value binding is erased from the JavaScript output, and the structural guard still recognizes the validator's name and summary. The exact-head CI run completed successfully, including ci-gate and build-artifacts. The prior review's blanket statement that all 141 check runs were green is inaccurate: the exact-head inventory includes skipped, cancelled, and neutral checks, although ci-gate is successful.
Blocking issue (P2): the public SDK type declarations still depend on a type that the published @openclaw/ai package does not export. The exact-head build artifact's dist/plugin-sdk/agent-core.d.ts exposes ToolArgumentValidationError through a declaration importing it from @openclaw/ai/validation; the published @openclaw/[email protected] dist/validation.d.mts exports only the validator functions. A strict TypeScript 6.0.3 consumer importing this type from the public SDK fails with TS2305. The monorepo type-check misses this because its workspace @openclaw/ai re-exports the local llm-core class. Please remove this external type dependency (for example, define the public structural error type locally or omit the type-only public export) and add a built-consumer type-check against the published dependency. The runtime fix can then be approved without leaving the public TypeScript surface unusable.
…not a re-export (ENG-23048) Published @openclaw/[email protected]'s dist/validation.d.mts exports only validateToolArguments and validateToolCall -- no ToolArgumentValidationError type, matching its missing value export. `export type { ... } from "@openclaw/ai/validation"` resolved fine against the workspace-linked @openclaw/ai (boon's own packages/ai), masking that a real external consumer type-checking against the published registry package would hit TS2305. Define the minimal shape locally instead (just the `name`/`summary` fields agent-loop.ts's structural guard reads), so the public .d.ts no longer depends on the externally-resolved package's declarations at all. Verified against the actual published @openclaw/[email protected] dist/validation.d.mts. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
Verdict: APPROVE (ready-to-release)
Review summary:
- Public TypeScript declarations: Commit a79374e resolves the blocking TS2305 declaration issue identified on head ba91c49. Instead of re-exporting the type from @openclaw/ai/validation (which is absent from published @openclaw/[email protected]), packages/agent-core/src/validation.ts now defines ToolArgumentValidationErrorShape as a local structural interface (readonly name: "ToolArgumentValidationError", readonly summary: string).
- Runtime and SDK surface: packages/agent-core/src/agent-loop.ts imports ToolArgumentValidationErrorShape as a type-only import for its structural guard. The generated declaration bundle in dist/plugin-sdk/agent-core.d.ts no longer imports ToolArgumentValidationError from @openclaw/ai/validation, completely eliminating external dependency on unpublished symbols.
- Verification: Verified against dist-runtime-build from CI run 44653169513. A strict TypeScript consumer probe against the published @openclaw/[email protected] package passes without TS2305. All 3 commits (4bcc74b, ba91c49, a79374e) are GPG-signed and verified. Core CI workflow passed including ci-gate, build-artifacts, unit tests, lint, and typechecks.
Cuts the fork release carrying #339 (ENG-23048) and #340 (ENG-23040), both merged to boon after the v2026.7.35-boon.2 tag. #340's fix is untested against the real canary race that boon.2 failed on, so this bump is what makes that fix installable for the re-canary attempt. Version-only bump, same pattern as prior boon.N trains: upstream base stays 2026.7.35; fork increment moves boon.2 -> boon.3. Bumps root package.json/npm-shrinkwrap.json, all 142 bundled plugin manifests (pnpm plugins:sync), and regenerates every extension's npm-shrinkwrap.json (node scripts/generate-npm-shrinkwrap.mjs --all). Adds the 2026.7.35-boon.3 CHANGELOG.md section. Co-authored-by: Claude Sonnet 5 <[email protected]>
Closes ENG-23048
What Problem This Solves
Fixes an issue where any downstream consumer that installs this repo's
openclawrelease (starting fromv2026.7.35-boon.1, the current upstream base) and touchesopenclaw/plugin-sdk/agent-harnessor anything that transitively importspackages/agent-core's compiled module would crash at module-load time with:Confirmed in anychat-boon-web's
tests/transport/boon-web/reply-turn.test.tsright after bumping itsopenclawdevDependency pin fromv2026.6.35-boon.6tov2026.7.35-boon.1(ENG-22290's PR #233) — this isn't test-only, it would crash the same way in production for that app.Why This Change Was Made
packages/llm-core/src/validation.tswas patched in boon's fork (#144, Aug 2026) to throw a typedToolArgumentValidationErrorinstead of a plainError, sopackages/agent-core/src/agent-loop.tscan surface a one-line.summaryin a failed tool call'sdetails.error. Upstream's recent base-reset (v2026.7.35, #307/#335/#336) extracted that file's package into a newly-published, separately-versioned@openclaw/aiand marked it "never bundle" (tsdown.config.ts), so every build now treats it as an external runtime dependency resolved from each consumer's ownnode_modules. Boon doesn't publish its own@openclaw/aianywhere, so a consumer's plainpnpm installgets upstream's package — which has never carried this boon-specific class, confirmed againstgit show v2026.7.35:packages/llm-core/src/validation.tsand the actual published@openclaw/[email protected]npm tarball.Fix:
agent-loop.ts's only consumer of the class (error instanceof ToolArgumentValidationError, used solely to read.summary) now does a structural check (error.name === "ToolArgumentValidationError" && typeof error.summary === "string") instead ofinstanceof, and imports the class as a type only.packages/agent-core/src/validation.ts's facade re-exports it withexport typeinstead of a value export. A type-only export/import erases entirely at build time, so the bundler no longer emits a runtime binding for this symbol against the externally-resolved@openclaw/ai— while.summarykeeps working exactly as before for the one call site that needs it. No change topackages/llm-coreitself, so this stays easy to re-sync with upstream.User Impact
No user-visible behavior change — tool-call validation errors still carry the same
.summarydetail indetails.error. This just stops the wholeopenclawpackage from crashing for any consumer (plugin, embedding app) that installs it from this repo's releases alongside a normal@openclaw/aifrom the public npm registry.Surface note:
packages/agent-core/src/validation.ts'sToolArgumentValidationErrorgoes from a value export to a type-only one.@openclaw/agent-coreis"private": trueand never published, so there's no npm consumer of it directly. The only genuinely public path,openclaw/plugin-sdk/agent-core, was already fully unloadable before this PR (any import from it crashed with the same SyntaxError, not just this symbol) — so no working externalinstanceofusage exists to break. This PR turns a fully-broken module into a working one, minus a value export nobody could have exercised.Evidence
node scripts/run-vitest.mjs packages/llm-core/src/validation.test.ts packages/agent-core/src— 15 files / 109 tests pass.node scripts/run-vitest.mjs test/scripts/plugin-sdk-surface-report.test.ts— 9 tests pass; SDK export-surface budget unaffected by the type-only export change.pnpm build, thengrep -rn "ToolArgumentValidationError" dist/— the class is now only a local structural-check helper in the bundled proxy chunk; no remainingimport { ToolArgumentValidationError, ... } from "@openclaw/ai/validation"value import.node scripts/run-oxlint.mjs packages/agent-core/src/agent-loop.ts packages/agent-core/src/validation.tsandpnpm tsgo:core— both clean.dist/into a real consumer checkout (anychat-boon-web,node_modules/openclaw/dist) with the actual unpatched public@openclaw/[email protected]from npm still installed (not swapped out).tests/transport/boon-web/reply-turn.test.ts, which crashed on import before this fix, passes after.🤖 Generated with Claude Code