fix(observe): do not fingerprint successful file-tool responses

errorFingerprint() ran ERROR_RE over Read, Edit and Write success
objects. Source files that contain words such as error or failed then
produced raw: fingerprints and false tool_error_loop signals: 151
entries across 9 sessions.

PostToolUse never receives failed calls, because Claude Code sends them
to PostToolUseFailure. Return null for objects with a file or filePath
key and no is_error: true. String responses keep their fingerprints.

Proposed by ADAM /reflect (2026-09-25-002). Tests 36b and 36c added:
147 passed, 0 failed.

Claude-Session: https://claude.ai/code/session_014prTNuJnKuwcAd28vUZAnN
This commit is contained in:
2026-09-25 03:07:34 +01:00
parent b2fff8f271
commit e3fe691b45
2 changed files with 27 additions and 0 deletions
+6
View File
@@ -249,6 +249,12 @@ function snapshotContext(state) {
function errorFingerprint(toolResponse) {
if (!toolResponse) return null;
// Read/Edit/Write success objects carry `file`/`filePath` and no `is_error`.
// PostToolUse never receives failed calls (CC routes them to
// PostToolUseFailure), so ERROR_RE here would only match source-file text.
if (typeof toolResponse === "object" && !Array.isArray(toolResponse) &&
toolResponse.is_error !== true &&
("file" in toolResponse || "filePath" in toolResponse)) return null;
let text = "";
if (typeof toolResponse === "string") text = toolResponse;
else if (toolResponse.content !== undefined) {