Skip to content

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

Merged
jalehman merged 3 commits intoMartian-Engineering:mainfrom
catgodtwno4:fix/summarize-strip-auth-false-positive
Apr 2, 2026
Merged

fix: prevent false-positive auth errors in stripAuthErrors()#178
jalehman merged 3 commits intoMartian-Engineering:mainfrom
catgodtwno4:fix/summarize-strip-auth-false-positive

Conversation

@catgodtwno4
Copy link
Copy Markdown
Contributor

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.

@sisutuulenisa
Copy link
Copy Markdown

Confirmed this matches our repro on OpenClaw 2026.4.1 with lossless-claw 0.5.2. We saw false [lcm] compaction failed: provider auth error warnings where the Detail: payload was clearly assistant-generated summary text containing auth-related terms like 403 / Unauthorized, while normal openai-codex/gpt-5.4 requests succeeded elsewhere in runtime. Related confirmation issue: #237.

scott and others added 2 commits April 2, 2026 06:53
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
@jalehman jalehman force-pushed the fix/summarize-strip-auth-false-positive branch from d165ffa to ffea40f Compare April 2, 2026 13:54
@jalehman jalehman merged commit 0613b7f into Martian-Engineering:main Apr 2, 2026
1 check passed
@jalehman
Copy link
Copy Markdown
Contributor

jalehman commented Apr 2, 2026

Thank you!

@github-actions github-actions Bot mentioned this pull request Apr 1, 2026
@sisutuulenisa
Copy link
Copy Markdown

Following up after comparing the merged diff to the local hotfix we are running here: this is the same fix we applied in our OpenClaw runtime.

Concretely, we patched the fallback from:

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

to:

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

That immediately stopped the false [lcm] compaction failed: provider auth error cases on our side when the generated summary text itself contained strings like 401, 403, or Unauthorized.

So from our side, this merged PR matches the real root cause in #237 exactly. The later confirmation on #237 from another deployment also makes sense to us: 0.5.3 still reproduced because this fix was not in the published package yet, but the merged PR logic is the right correction.

Thanks again — once this is in a released package, I’d expect #237 to be effectively resolved.

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

3 participants