Skip to content

fix(session): record per-tool errors via PostToolUseFailure SDK hook (fixes #672)#674

Open
mickume wants to merge 1 commit into
mainfrom
fix/issue-672-tool-errors-tracking
Open

fix(session): record per-tool errors via PostToolUseFailure SDK hook (fixes #672)#674
mickume wants to merge 1 commit into
mainfrom
fix/issue-672-tool-errors-tracking

Conversation

@mickume

@mickume mickume commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

The tool_errors table was always empty because record_tool_error() only fired on session-level is_error, not on individual tool failures. The Claude Agent SDK's PostToolUseFailure hook fires for each tool invocation failure, providing tool_name and error — exactly what's needed.

Closes #672

Changes

File Change
packages/agentfox/agentfox/session/backends/claude.py PostToolUseFailure hook + _build_tool_error_hook()
packages/agentfox/agentfox/session/session.py _on_tool_error closure, passed as tool_error_callback
Test mock backends (2 files) Added **kwargs for forward compatibility

Verification

  • All existing tests pass: ✅ (5857)
  • Linter / formatter: ✅
  • No regressions: ✅

Auto-generated by af-fix.

…ixes #672)

The tool_errors table was always empty because record_tool_error() only
fired on session-level is_error, not on individual tool failures. The
Claude Agent SDK handles tool results internally — per-tool errors never
surfaced through the streaming interface.

Registered a PostToolUseFailure hook that fires for each tool invocation
failure, calling record_tool_error() and record_tool_error_trace() with
the tool name and error message from the SDK hook input.
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.

bug: tool_errors table is always empty despite tool failures occurring

1 participant