Skip to content

fix: prevent false-positive auth errors in stripAuthErrors()#178

Open
catgodtwno4 wants to merge 1 commit intoMartian-Engineering:mainfrom
catgodtwno4:fix/summarize-strip-auth-false-positive
Open

fix: prevent false-positive auth errors in stripAuthErrors()#178
catgodtwno4 wants to merge 1 commit intoMartian-Engineering:mainfrom
catgodtwno4:fix/summarize-strip-auth-false-positive

Conversation

@catgodtwno4
Copy link

Summary

Fixes #171 — false-positive auth error when summary content contains auth-related keywords.

Root Cause

In src/summarize.ts, pickAuthInspectionValue() (line 390) returns the full response object when no auth-related keys are found in the subset:

return Object.keys(subset).length > 0 ? subset : value;  // BUG

This causes collectAuthFailureText() to walk the entire response including content[].text (the actual summary text). If the summary discusses auth errors (e.g., a conversation about debugging 401s), the regex AUTH_ERROR_TEXT_PATTERN matches against conversation content rather than actual API error responses.

Fix

Return empty object {} instead of the original value when no auth-related keys are found:

return Object.keys(subset).length > 0 ? subset : {};  // FIXED

This prevents downstream extractProviderAuthFailure() from inspecting irrelevant fields.

Verified On

Machine Primary Model LCM Model Summaries False Positives After Fix
Scott#4 Claude Opus M2.7 HS 200+ 0
Scott#2 Claude Opus M2.7 HS 40+ 0

Test

Compress a conversation containing strings like 401, invalid api key, authentication_error. Before fix: false [lcm] compaction failed: provider auth error log. After fix: clean log, summary written successfully.

When summarizing conversations that discuss authentication errors
(e.g. '401', 'invalid api key'), pickAuthInspectionValue() would
fall back to the original value when no auth-related keys were found
in the subset, causing the downstream extractProviderAuthFailure()
to incorrectly detect auth failures from conversation content rather
than actual API responses.

This resulted in misleading '[lcm] compaction failed: provider auth error'
log messages even though summaries were successfully written to the DB.

Fix: return empty object instead of original value when no auth-related
keys are found, preventing false-positive auth error detection.

Fixes Martian-Engineering#171
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.

False-positive auth error when summary content contains auth-related keywords

1 participant