Repository navigation
fix(sentry-monitor): classify tool-call errors and fix release tag - #144
Merged
Merged
Conversation
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
All reported issues were addressed across 35 files
Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.
Re-trigger cubic
…stop misreporting expected outcomes The sentry-monitor plugin's `release` tag was this plugin's own pinned manifest version, not the running app version, so every host on every release reported the same tag and a per-deploy regression could never be attributed. Adds `hostVersion` to the plugin API, sourced from the real app version, distinct from each plugin's own `version`. after_tool_call captures now carry a structured `errorKind` (denied/invalid-input/timeout/internal/exit-error/upstream) derived from signals the host already computes -- result status, exec exit code, execution-started flag, middleware markers -- never from message text. A policy/permission/visibility denial is no longer captured to Sentry at all: the system worked as intended. A model argument-validation rejection downgrades to a non-paging warning instead of an exception, since it's real signal for a schema mismatch but not a host defect. Fingerprints now scrub volatile tokens (paths, UUIDs, timestamps, byte/pixel counts) before grouping, so the same underlying failure recurring with different incidental detail lands in one Sentry issue instead of one per occurrence. Validation errors previously lost all field detail once collapsed to their first line. `validateToolArguments` now throws a typed `ToolArgumentValidationError` carrying a single-line `summary` of every field issue, surfaced via `details.error` so structured lookups find it first. Separately: `edit`/`write`/`read` schemas rejected Claude-Code-style `file_path`/`old_string`/`new_string` even though each tool's own render code already reads those names. Adds alias normalization via a new shared, non-mutating `renameStringKeyAlias` helper (mutating the model's raw tool-call arguments in place would have corrupted the persisted transcript). Slack's error formatter appended granted/accepted OAuth scope lists to any platform error whenever the scope response headers were present -- but Slack sends those headers on every response, success or failure, so an unrelated error read as a scope mismatch that wasn't there. Now gated on `needed`, the field Slack only sets on an actual missing-scope failure. The session-tree visibility denial message always named tools.sessions.visibility=tree as the cause, even when a sandbox clamp silently overrode an operator's explicit non-tree config. Session tools now share one `resolveSessionVisibilityContext` helper so the message can name the real cause. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…and aliasing Six real issues found by review, each verified against the actual code before fixing: - An inline gateway exec-approval denial kept details.status: failed with no dedicated status, so it classified as upstream instead of denied and paged as an exception for an expected refusal. Adds a structured details.denied signal to that one result builder rather than sniffing the message text or overloading a shared status literal. - sessions_list's separate visibility-metadata warning still named tools.sessions.visibility=tree as the cause even when a sandbox clamp was the actual reason; it now shares the same clamp-aware wording as the per-row denial message. - A tool result reporting status: timed_out (underscore) fell through to upstream instead of timeout. - The edit tool's live TUI diff preview reads the raw, in-flight streamed args before prepareArguments runs, so it never recognized the newly-accepted snake_case aliases and silently showed no preview. Reuses the existing alias normalizer on a render-local copy. - A model sending both edits[] and top-level old_string/new_string had the top-level pair silently appended as an extra, unintended edit. The top-level alias now only applies when edits[] is absent. - Fingerprinting a tool-call error by scrubbing all bare numbers made distinct exec exit codes collapse into one Sentry bucket whenever no errorCode was set. The exit code is now threaded through the hook event as its own field and preferred in the fingerprint. Also fixes the two real CI failures from the initial PR: an oxlint prefer-structured-clone violation in a new test, and a TS2339 from a test-local type missing the new errorKind/errorCode fields. Bumps the plugin-sdk public-surface budget (10390->10395 exports, 5212->5214 callable exports) to the exact counts after this PR's additive SDK surface -- a deliberate, reviewed increase, not config drift. Co-Authored-By: Claude Sonnet 5 <[email protected]>
convyusboy
force-pushed
the
ridho/openclaw-fleet-tool-error-classification
branch
from
August 21, 2026 14:47
248a45e to
d190381
Compare
Add a type-narrowing expectDeniedExecDetails helper for ExecToolDetails' discriminated status union, and cast the deliberately-alias-shaped renderCall args in edit.test.ts, fixing check-test-types failures introduced by the prior PR-feedback commit.
The earlier as-never cast only covered the first positional args param to renderCall; context.args carries the same alias-shaped literal and needs the same treatment, per the TS2345 CI failure on the previous commit.
There was a problem hiding this comment.
Solid cleanup of long-standing Sentry noise. Approving.
What I checked
hostVersionsplit from pluginversion. Plumbed throughapi-builderfromsrc/version.ts, additive on the plugin API surface (bumps the public-export budget by the exact 5/2 deltas — reviewed, not drift). Right call: 3624+ events reporting one release tag was silently breaking per-deploy regression tracking.errorKindclassification is structured, not text-sniffed.classifyToolCallErrorKindreads onlystatus,details.denied,executionStarted,middlewareError, andexitCode— nevererror-string patterns. Precedence (denied → invalid-input → timeout → internal → exit-error → upstream) matches the comment;DENIAL_STATUSESis deliberately narrow (forbidden/denied/blocked) and matchesreadToolResultStatus's lowercase normalization.- The gateway exec-denial
details.denied: truebridge. Nice fix —status: "failed"alone couldn't distinguish an approval denial from a real process failure, and the alternative (a new status literal) would ripple throughisToolResultError. Structured field, contained blast radius. - Fingerprint normalization.
normalizeFingerprintTextruns beforeFINGERPRINT_NUMBER_REso UUIDs/timestamps/paths/dimensions/filenames don't lose their tokens to the bare-number sweep. The exit-code threading (errorCode ?? exitCode ?? normalizeFingerprintText(error)) correctly keeps distinct exec exits in distinct buckets — the tests cover exit 1 vs 127 explicitly, which is the exact failure mode the earlier fix would have introduced. - Non-mutating alias helper.
renameStringKeyAliasreturns a new object;applyEditArgumentAliasesclones the array + entries; the caller-mutation test onedit.test.tsguards it. The double invocation (prepareArguments+getRenderablePreviewInput) is correct because the live streamed preview never runs throughprepareArguments— this was a real gap. ToolArgumentValidationError.summary. Single-pass over TypeBox's one-shot iterator;details.errorinagent-loop.tsgets the single-line form; the multi-linemessageis preserved onError. Structured consumers see the field-level detail they need.- Slack scope decoration gated on
needed. Correct — Slack setsneededonly onmissing_scope, and movingscopes/acceptedScopesinside theif (needed)block prevents them from ever appearing without it. The exact-equality assertion (not substring) on the non-scope error is the right proof. - Sandbox-clamp visibility context.
resolveSessionVisibilityContextconsolidates two calls into one;clampedFromSandboxthreads through history/status/send/list; the list-tool warning wording distinguishes clamp vs config. The mock-diverge risk called out in the second commit was real and is now covered. - CI. All green (checks-node-*, CodeQL, guards, docs, lint, test-types, contracts). 733 tests as advertised across every touched surface, including the new e2e wiring test that asserts
errorKind: "denied"/"invalid-input"end-to-end. - No blocking review or open threads. Cubic bot signed off; 8 self-review comments from you are annotations, not asks.
Minor observations, non-blocking
FINGERPRINT_FILENAME_REwill also match1.2.3-style version substrings as<file>(then the number pass would touch what's left). Groups deterministically either way — not a correctness bug, just noting it in case an issue title later reads oddly.- The
!executionStartedclassification precedes the timeout check. A pre-execution timeout (schema/argument-prep timing out) would classify asinvalid-inputrather thantimeout. Not a realistic path inprepareToolCall, so this is fine — flag if that flow ever grows async work.
Ship it.
convyusboy
added a commit
that referenced
this pull request
Aug 25, 2026
convyusboy
added a commit
that referenced
this pull request
Nov 20, 2026
…ationError's runtime identity (#339) * fix(agent-core): stop depending on @openclaw/ai for ToolArgumentValidationError'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]> * fix(agent-core): address cubic review feedback on PR #339 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]> * fix(agent-core): make ToolArgumentValidationErrorShape a local type, 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]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Four Sentry groups on the OpenClaw fleet were long-standing paging noise:
tool-call validation failures, and a session-tree visibility denial, all
merged into grab-bag issues that hid real signal. Digging into the actual
event data (not just issue titles) showed the underlying causes were
different from what they looked like at a glance, and none of the four
original groups had produced an event in the prior 3 days once the real
root cause was traced.
Why This Change Was Made
sentry-monitor'sreleasetag was wrong. It reported thisplugin's own pinned manifest version (
2026.5.18, never bumped), notthe running app version, so 3624+ events across 90 days all carried one
releasetag and per-deploy regression tracking was silently broken.Adds
hostVersionto the plugin API, sourced from the real app version.Fingerprinting on raw error text created one Sentry issue per
occurrence whenever the text contained a path, size, timestamp, or
pixel count (one issue was literally titled from an
ls -lline).normalizeFingerprintTextnow scrubs volatile tokens beforefingerprinting; the raw text stays in the visible issue title.
model-argument errors paged as exceptions identical to real defects.
after_tool_callcaptures now carry a structurederrorKind(
denied/invalid-input/timeout/internal/exit-error/upstream), derived only from signals the host already computes(result status, exec exit code, execution-started flag, middleware
markers) -- never from message text.
deniedoutcomes are no longercaptured at all;
invalid-inputdowngrades to a non-paging warninginstead of an exception.
error collapsed to its generic first line
(
Validation failed for tool "<name>":) for any single-line consumer.validateToolArgumentsnow throws a typedToolArgumentValidationErrorcarrying a single-line
summaryof every field issue, surfaced viadetails.error.edit/write/readrejected names their own render code alreadyreads. The schemas hard-rejected Claude-Code-style
file_path/old_string/new_string, even though each tool's TUI rendereralready reads those exact names. Adds alias normalization via a new
shared, non-mutating
renameStringKeyAliashelper -- mutating themodel's raw tool-call arguments in place (an earlier draft of this fix)
would have corrupted the persisted conversation transcript.
scope list. It appended
granted:/accepted:OAuth scope lists toany Slack platform error whenever the scope response headers were
present -- but Slack sends those headers on every response, success or
failure, so an unrelated error (e.g.
file_update_failed) read as ascope mismatch that didn't exist. Now gated on
needed, the fieldSlack only sets on an actual
missing_scopefailure.It always named
tools.sessions.visibility=tree, even when a sandboxclamp silently overrode an operator's explicit non-tree config. Session
tools (
history/status/send/list) now share oneresolveSessionVisibilityContexthelper so the message can name thereal cause when it's the clamp, not the config.
User Impact
after_tool_callnow name the actual tool, errorkind, and code instead of merging unrelated failures into one noisy
issue, and no longer page on expected policy denials.
edit/write/readnow succeed instead of getting a generic"Validation failed" rejection.
scope-configuration problem when it isn't one.
sandbox clamp instead of a config key the operator may have already
set correctly.
classification, message-fidelity, and alias-acceptance only.
Evidence
sentry-monitor(captures/format/register/dispatch), Slack
send.ts,session-visibility.tsand its 4 call sites,edit/write/readtools,
validateToolArguments,agent-loop, theafter_tool_callhook wiring e2e test, and the plugin-sdk contract/loader suites.
original noisy groups: none had produced an event in the trailing 3
days once traced to a shared root cause in the capture-grouping layer,
and each has been resolved in Sentry with a written reason citing the
specific fix here.
higheffort caught and this PR fixes: anargument-mutation bug in the original alias-handling draft that would
have corrupted persisted tool-call transcripts, a missed call site
(
sessions-list-tool.ts) for the sandbox-clamp context, and a testmock that would have silently diverged from the new combined
visibility-context helper -- all confirmed via passing tests, not just
code inspection.
🤖 Generated with Claude Code
Summary by cubic
Classifies tool-call failures in
sentry-monitorand sets Sentry’sreleaseto the running app version to cut paging noise and stabilize grouping. Previously every tool-call error paged as an exception andreleasewas the plugin version; now policy denials don’t capture, invalid inputs warn, exit codes/codes drive grouping, andreleasereflectshostVersion.Sentry release tag: was this plugin’s version; now
OpenClawPluginApi.hostVersionfromapi-builderfor per-deploy regression tracking.Tool-call classification:
after_tool_calladdserrorKind/errorCode/exitCode.deniedis not captured;invalid-inputis a warning; all others (incl.exit-error) remain exceptions.Fingerprints: prefer
errorCode/exitCode; otherwise scrub volatile text (paths/UUIDs/timestamps/sizes/dimensions). Other hooks (agent_end,message_sent,subagent_ended,cron_changed) also normalize.Validation detail:
validateToolArgumentsthrowsToolArgumentValidationErrorwith a single-linesummary;agent-coresurfaces it viadetails.error.File tool aliases:
edit/write/readacceptfile_path/old_string/new_stringvia non-mutating normalization; theeditlive diff preview recognizes these aliases.Slack errors: only append granted/accepted scopes when Slack sets
needed(missing_scope), avoiding misleading scope lists on unrelated errors.Session visibility: shared
resolveSessionVisibilityContextnames a sandbox clamp in per-row denials and list warnings when it forcedtree, instead of blamingtools.sessions.visibility.Review and rollout
hostVersionif you constructOpenClawPluginApimanually.invalid-inputis warning-level.Written for commit cc68378. Summary will update on new commits.