Skip to content

fix(hooks): keep error text on failure events - #1499

Merged
zlareb1 merged 3 commits into
ClickHouse:mainfrom
prascli:fix/1481-posttooluse-failure-error
Nov 26, 2026
Merged

zlareb1 merged 3 commits into
ClickHouse:mainfrom
prascli:fix/1481-posttooluse-failure-error

Conversation

@prascli

@prascli prascli commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Failed tool calls in Claude Code sessions now record the error text in the observation. An action:error event shows why the call failed instead of an empty error field.

Why

Refs #1481

A PostToolUseFailure event carries its error in the top-level error field and has no tool_response. buildObservation read the error only from tool_response, so error was an empty string. The observation recorded that a call failed but not why. The fix reads payload.error first and keeps the existing tool_response fallbacks for clients that report errors there, so both event shapes are covered.

Scope and risk

Only the Claude Code hook's error selection and its mirrored Codex copy change. Tool input, output, redaction, dedupe and the shape of the observation are untouched. A client that sends both fields now sees the top-level text it reported for the failure. Both plugin manifests move from 1.2.53 to 1.2.54; no other open pull request uses that version.

Compatibility, rollout and rollback

  • Wire: no operation or field added, changed or removed, and no changed default. The error field of an action:error observation is now populated for one event shape.
  • Operator steps: none. No backfill, re-index or settings change; install the updated plugin.
  • Rollback: reverting restores the empty error field for these events. No rows, migrations or generated files are left behind.

Tests

A regression test in integrations/claude-code-plugin/tests/loom-capture.test.mjs builds an observation from a PostToolUseFailure payload with only a top-level error. Before the fix it failed with actual: ''; after the fix it passes.

Verification

Commands and results on this checkout, based on upstream/main at 96b4870c6:

$ node --test integrations/claude-code-plugin/tests/loom-capture.test.mjs
before the fix: 8 pass, 1 fail (the new case, actual: '')
after the fix: 9 pass, 0 fail

$ node --test integrations/claude-code-plugin/tests/*.test.mjs
719 tests, 712 pass, 0 fail

$ python3 scripts/codegen/agent_plugin_sync.py --check
codex plugin copies are current

$ python3 -m pytest tests/unit/test_codex_plugin.py -q
could not collect: the local environment lacks server dependencies (opentelemetry.instrumentation). Version parity was read directly from both manifests: both report 1.2.54.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): opencode-go:hy4-flash-free. I checked the failing case before the change, the passing suite after, the mirrored Codex copy and the version numbers.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

Note

Low Risk
Narrow client-side fix in capture hooks plus version bump and a unit test; no server or wire changes.

Overview
Failed tool calls now persist the real failure message in Loom observations. buildObservation in the Claude Code and Codex capture hooks checks payload.error first when building the observation’s error field, then keeps the existing fallbacks on tool_response so both event shapes still work.

PostToolUseFailure events often ship only a top-level error and no tool_response, which left error empty before. action:error observations should now show why the call failed.

Both plugin manifests are bumped to 1.2.54, and a regression test covers a PostToolUseFailure payload with only top-level error.

Reviewed by Cursor Bugbot for commit 63cab67. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 25, 2026 11:28pm UTC
loom-telemetry Ready Ready Preview Nov 25, 2026 11:28pm UTC

Request Review

@cla-assistant

cla-assistant Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nine hook tests pass and the Codex mirror matches. The pinned Biome check fails on both hook copies.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit job rejects two candidate limits in enrich.py. The same assertion fails on the CI base and on clean main, and passes with the repair. Failed unit job · Repair #1503

Line 139 of the source hook exceeded the repository's 120-column limit. Reformat it and regenerate the mirrored Codex hook copy.

Signed-off-by: Indra Prasetya <[email protected]>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hook records the top-level failure text through the existing redaction and length limit. All nine focused tests, the plugin mirror check, and the pinned Biome format check pass on this head.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both failed unit shards reproduce on the CI base without the hook change. The coding profile assertion passes on main with #1507. The limit gate rejects two enrichment bounds and two fixed request caps. #1503 tracks the limit repair.

Coding profile job · Merged profile fix · Limit job · Limit repair

@zlareb1
zlareb1 merged commit e3f1b4e into ClickHouse:main Nov 26, 2026
79 of 81 checks passed
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.

2 participants