Skip to content

loom-capture hook stores no error text for PostToolUseFailure events #1481

Todo

Description

@aniketbhoir-git

Version: plugin loom@loom 1.2.23, Loom 1.2.0, Claude Code on Windows 11.

What happens

When a tool call fails, the observation has the tag action:error, but its error field is empty. The record shows that a call failed, not why.

Cause

In hooks/loom-capture.mjs, buildObservation (lines 134 to 148) reads the error text only from payload.tool_response (.error, .stderr, .message). Claude Code sends the error of a PostToolUseFailure event in the top-level field payload.error; the payload has no tool_response. So errText is an empty string.

Steps to reproduce

  1. Run a session with the plugin on.
  2. Let the agent run a failing command, for example ls /nonexistent.
  3. Read the row in loom.agent_events (operation='observe.record', tag action:error) and its obs:* memory. The input is there; the error text is not.

Expected

The observation holds the error text (Exit code 2 / ls: cannot access ...).

Proposed fix

Read payload.error first:

const errText = isError ? (payload.error || toolResponse.error || toolResponse.stderr || toolResponse.message || toolResponse) : "";

Evidence

A second hook on the same events, which reads payload.error, recorded the full text for 33 of 33 failures in the same sessions.

Related gaps (for separate issues, if you want them)

  • The payload fields duration_ms, tool_use_id and agent_id are not stored, so durations are not known and subagent calls cannot be told apart from main calls.
  • The hook does not retry, so events are lost while the server restarts.

Activity

  1. added
    bug
    help wanted
    up-for-grabs
    on Nov 25, 2026
  2. zlareb1 commented on Nov 25, 2026

    @zlareb1
    Member

    @aniketbhoir-git would you like to fix this?

  3. prascli commented on Nov 25, 2026

    @prascli
    Contributor

    Fixed in PR #1499: #1499

    The capture hook now reads the top-level error field on PostToolUseFailure and keeps the existing tool_response fallbacks, so both event shapes record the failure text. A regression test uses the payload shape from this report: it failed with an empty error before the change and passes after. The Codex plugin copy is regenerated and both plugin manifests are bumped.

    Verified locally: node --test integrations/claude-code-plugin/tests/*.test.mjs (719 tests, 0 failures), and the repository's Codex copy sync check reported the copies current.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wantedup-for-grabs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions