Repository navigation
Conversation
…llback The tool planner silently hid descriptors with malformed availability expressions (empty allOf/anyOf groups), because buildToolPlan had no mechanism to surface diagnostics to callers. This adds an optional onHiddenDiagnostic callback to BuildToolPlanOptions so callers can observe authoring errors like empty availability groups. It also adds defensive Array.isArray checks in evaluateExpression to prevent crashes when non-array values bypass the TS type system. - types: add onHiddenDiagnostic callback to BuildToolPlanOptions - planner: invoke onHiddenDiagnostic for each diagnostic that hides a tool - availability: add Array.isArray guards on allOf/anyOf before .flatMap/.map - tests: verify callback behavior (3 descriptors) and crash prevention (2 cases) Fixes openclaw#92361 Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed June 24, 2026, 6:47 AM ET / 10:47 UTC. Summary PR surface: Source +12, Tests +67. Total +79 across 5 files. Reproducibility: yes. Source inspection shows empty availability groups produce Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land one canonical fix that keeps the evaluator pure and surfaces malformed availability diagnostics once at the plugin descriptor registration or resolver boundary; keep the planner callback only if maintainers want that public API. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows empty availability groups produce Is this the best way to solve the issue? No. The callback is a plausible helper, but without a production caller or registration sink it is not the complete fix for the linked runtime diagnostic issue. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bfffc77bfc86. Label changesLabel justifications:
Evidence reviewedPR surface: Source +12, Tests +67. Total +79 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
All CI checks are green (135 passed). Ready for review. @vincentkoc would you mind reviewing this? Thanks! |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@fsdwen thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
Closing as not planned after #92411 landed the concrete evaluator hardening in This PR's callback would expand the public planner/SDK contract without a production caller or lifecycle owner. The generic planner already returns diagnostics in #92411 now rejects malformed, sparse, ambiguous, and cyclic plain-JavaScript expressions without throwing or failing open. If a current production registration owner is later shown to discard those returned diagnostics, the supported follow-up is one owner-boundary integration with a live caller repro—not a generic callback added in advance. Thanks @fsdwen for the careful crash-path analysis and proof. |
Summary
The tool planner (
buildToolPlan) silently hid descriptors with malformed availability expressions (emptyallOf/anyOfgroups), because it had no mechanism to surfaceunsupported-signaldiagnostics to callers. Tools were hidden with detailed diagnostics but no observable signal reached the developer.Root Cause
In
evaluateExpression(availability.ts), emptyallOf/anyOfarrays correctly produceunsupported-signaldiagnostics, butbuildToolPlanconsumes them silently — it pushes descriptors into thehidden[]array with no callback, logger, or event emitter to notify callers.Additionally,
evaluateExpressioncalls.flatMap()/.map()onallOf/anyOfvalues without checking they are actually arrays — allowing a crash path if non-array values bypass the TS type system.Fix
This adds an optional
onHiddenDiagnosticcallback toBuildToolPlanOptions. The planner invokes it for each diagnostic that hides a tool, giving callers a channel to observe authoring errors without coupling the planner to a specific logging mechanism.It also adds defensive
Array.isArrayguards inevaluateExpressionbefore.flatMap()/.map()calls to prevent crashes on malformed non-arrayallOf/anyOfvalues.src/tools/types.ts: addonHiddenDiagnosticcallback toBuildToolPlanOptionssrc/tools/planner.ts: invokeonHiddenDiagnosticfor each diagnostic that hides a toolsrc/tools/availability.ts: addArray.isArrayguards onallOf/anyOfbefore.flatMap/.mapsrc/tools/planner.test.ts: verify callback behavior across 3 descriptors (visible, malformed, env-missing)src/tools/availability.test.ts: verify crash prevention for non-arrayallOfandanyOfAlternative approaches considered
console.warninevaluateToolAvailability(PR #92368, closed)resolvePluginToolsintegration + recursive validation + SDK exports (PR #92411, open)Verification
Standalone crash-prevention proof:
Real behavior proof
Behavior addressed: Empty
allOf/anyOfarrays in tool availability descriptors produceunsupported-signaldiagnostics that were silently consumed bybuildToolPlan. The planner had no mechanism to surface authoring errors to callers, andevaluateExpressioncould crash on non-arrayallOf/anyOfvalues that bypassed the TS type system.Real environment tested: Linux, Node.js v22.19.0, OpenClaw upstream/main (
0842cb71eb), branchfix/92361-tool-availability-hidden-diagnostic.Exact steps or command run after this patch:
cd /home/0668000615/10239986/github/openclaw-worktrees/fix-92361-tool-availability-hidden-diagnostic node scripts/run-vitest.mjs run src/tools/planner.test.ts src/tools/availability.test.tsEvidence after fix:
The
onHiddenDiagnosticcallback test verifies:unsupported-signaldiagnostics trigger one callback per diagnosticenv-missingdiagnostics trigger one callback per diagnosticCrash-prevention proof:
No crash — returns a diagnostic instead of throwing
.flatMap is not a function.Observed result after fix:
buildToolPlannow callsonHiddenDiagnosticfor each diagnostic that hides a tool, giving callers a channel to observe authoring errors.evaluateExpressionreturnsunsupported-signaldiagnostics for non-arrayallOf/anyOfvalues instead of crashing with.flatMap is not a function. All 18 direct tests and 20 total tools-directory tests pass.What was not tested: Live gateway startup with a production caller wiring the
onHiddenDiagnosticcallback, becausebuildToolPlanhas no production callers on currentmain. The callback contract is verified through unit tests; production wiring is a separate integration task.What this does NOT change
evaluateToolAvailabilityandevaluateExpressionremain pure and side-effect freeToolPlan.hiddenarray still contains diagnostics (backward compatible)buildToolPlanintoresolvePluginTools— production integration is a separate concernCloses #92361.
🤖 Generated with Claude Code