feat(memory): learn from tool errors to prevent repetitive failures#193
Open
tonbistudio wants to merge 1 commit intoConway-Research:mainfrom
Open
feat(memory): learn from tool errors to prevent repetitive failures#193tonbistudio wants to merge 1 commit intoConway-Research:mainfrom
tonbistudio wants to merge 1 commit intoConway-Research:mainfrom
Conversation
The ingestion pipeline previously skipped all tool errors with
`if (tc.error) continue;`, so the agent never learned from failures.
This caused repetitive error loops (e.g., PATH_TRAVERSAL spam).
Now errors are stored as semantic facts under the "environment" category
with keys like `tool_error:{tool}:{error_type}`. Repeated errors
increment a count and increase confidence (0.5 + 0.1*count, cap 1.0),
making them more prominent in memory retrieval over time.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
if (tc.error) continue;), so agents never learned from failures ? causing repetitive error loops (e.g., PATH_TRAVERSAL spam for hundreds of turns)environmentcategory with keys liketool_error:{tool}:{error_type}Details
src/memory/ingestion.tsnormalizeErrorType()helper that maps error strings to consistent labels (PATH_TRAVERSAL, TIMEOUT, PERMISSION_DENIED, RATE_LIMIT, etc.)if (tc.error) continue;with error-learning block that uses existingSemanticMemoryManager.store()UPSERT semanticsenvironmentSemanticCategory ? no type changes neededsrc/__tests__/memory.test.tsTest plan
npx vitest run src/__tests__/memory.test.ts? all 83 tests pass (10 new)semantic_memorytable?? Generated with Claude Code