Repository navigation
fix(sentry-monitor): fingerprint hook captures and surface real Python exception text - #133
Conversation
…n exception text Every after_tool_call/model_call_ended/etc. capture was thrown via `new Error(message)` at one fixed call site, so Sentry's stack-based grouping merged unrelated tool/hook failures into a single noisy issue regardless of message content. Add an explicit fingerprint per capture builder so distinct failures split into their own issues. Also fix normalizeToolErrorText to use the last line of a Python traceback (the actual exception) instead of the generic "Traceback (most recent call last):" header line.
|
I'll analyze this and get back to you. |
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.
Fix all with cubic | Re-trigger cubic
…aceback extraction
- Include httpStatus in the model_call_ended fingerprint so same-classification
failures with different HTTP causes (e.g. Bedrock 503 vs a gateway 502) still
split into separate issues.
- Skip the exec tool's appended exit-status trailer ("Command exited with code
N", "Command timed out...", "Command aborted...") when picking a Python
traceback's real last line, so that trailer text isn't mistaken for the
actual exception.
- Drop a PR-specific issue reference from a permanent code comment.
There was a problem hiding this comment.
Approved. Clean, well-scoped telemetry fix.
Root cause is correctly nailed: every capture is thrown via new Error(message) from one fixed call site per hook, so Sentry's stack-based grouping merged unrelated failures into one bucket — confirmed live on OPENCLAW-FLEET-H4. The explicit fingerprint per capture builder (single reused fingerprintOf helper, threaded through dispatch.ts SentryScopeContext) is the right fix, and httpStatus in the model_call_ended fingerprint correctly splits Bedrock 503 vs gateway 502.
The normalizeToolErrorText last-line-of-traceback fix is well-handled — the ^\(?Command\b/i trailer regex correctly skips exec's appended exit/timeout/abort status lines without clobbering a real CommandError:, and non-traceback multi-line output still keeps the first line.
Verified independently: checked out the branch and ran both scoped suites — extensions/sentry-monitor (64) + embedded-agent-subscribe.tools (28) = 92 passing, including the new regression tests for distinct fingerprints and traceback extraction. Telemetry-only, no runtime/product behavior change, no migration, no secrets. Post-deploy split verification tracked in ENG-18309.
tests: sentry-monitor 64 + agents 28 passed · scope observability-only · no migration · signed
Version-bump-only release cutting the seven commits merged to boon since v2026.6.11-boon.19: #129 (deliver an attachment when prose is fused onto the MEDIA: path), #131 (stop mislabeling sanctioned silent NO_REPLY finals as delivery failures, ENG-18092), #133 (fingerprint sentry-monitor hook captures and surface the real Python exception line), #130 (docs cross-link), and the #36 / #77 / #113 dependency bumps. Bumps the gateway plus @openclaw/slack, @openclaw/msteams, and @openclaw/diagnostics-prometheus to 2026.6.11-boon.20 in lockstep across all 8 manifests, and adds the CHANGELOG entry. No code changes. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

What Problem This Solves
Sentry issue
OPENCLAW-FLEET-H4had 403 occurrences over ~1 month, 0 users impacted, generically titled "Error: Traceback (most recent call last):" — but pulling the underlying events showed it was actually a grab-bag of completely unrelated tool failures: Python tracebacks,web fetch failed (403/404),memory_search timed out,An API error occurred: thread_not_found,cron job not found,Action send requires a target, etc., all merged into one noisy issue.Why This Change Was Made
Every
sentry-monitorcapture (after_tool_call,model_call_ended,agent_end,message_sent,subagent_ended,cron_changed) is dispatched viaclient.captureException(new Error(capture.message), scope)from a single fixed call site inextensions/sentry-monitor/src/dispatch.ts. Because the JS stack trace is identical for every capture of a given hook, Sentry's stack-based grouping merges all of them into one issue regardless of message content — hiding real signal behind noise.A secondary bug compounded this for Python
execfailures:normalizeToolErrorText(src/agents/embedded-agent-subscribe.tools.ts) took only the first line of raw tool output as the error string. For a Python traceback, the first line is always the genericTraceback (most recent call last):header — the actualExceptionType: messageis the last line — so every distinct Python exec failure reported identical, useless text even in isolation.User Impact
Sentry issues for the
after_tool_call(and sibling) hooks now split by their real cause (tool name, provider/model, outcome, message) instead of all landing in one bucket, and Python exec failures surface the actual exception instead of a generic traceback header. This is telemetry/observability-only — no runtime/product behavior changes for end users.Evidence
search_eventsonOPENCLAW-FLEET-H4: 20 sampled events showed wildly different underlying messages (traceback, web fetch 403/404, memory_search timeout, thread_not_found, cron job not found, etc.) all grouped under the same issue.fingerprintto every capture builder inextensions/sentry-monitor/src/captures.ts, threaded throughdispatch.ts'sSentryScopeContext.normalizeToolErrorTextto use the last non-empty line when text is a Python traceback.extensions/sentry-monitor, 26 insrc/agents/embedded-agent-subscribe.tools.test.ts), including new regression tests proving distinct tools/errors fingerprint differently and traceback extraction picks the right line. Ran viavitest runagainst the scoped configs (test/vitest/vitest.extensions.config.ts,test/vitest/vitest.agents.config.ts) since the repo's shared local heavy-check lock was held by tsgo in another worktree.oxfmt.Follow-up tracked in ENG-18309 (Linear): live post-deploy verification that new occurrences actually split, and what to do with the old already-merged
OPENCLAW-FLEET-H4bucket.Summary by cubic
Splits Sentry issues for hook captures by adding explicit fingerprints and surfaces real Python exceptions. Previously, all captures for a hook grouped under one JS stack; now each capture sets a fingerprint from distinguishing fields, and Python exec errors use the real exception line.
dispatch.ts, and compute it viafingerprintOf(e.g., formodel_call_ended: provider, model, errorClass, httpStatus, failureKind, errorCategory; for tools: tool + error text).normalizeToolErrorTextto use the last non-empty line of Python tracebacks and ignore exec status trailers (e.g., “Command exited with code N”, timeouts); keep the first line for other multi-line outputs.Written for commit bd7d35f. Summary will update on new commits.