Skip to content

Comments

feat(memory): learn from tool errors to prevent repetitive failures#193

Open
tonbistudio wants to merge 1 commit intoConway-Research:mainfrom
tonbistudio:feat/memory-error-learning
Open

feat(memory): learn from tool errors to prevent repetitive failures#193
tonbistudio wants to merge 1 commit intoConway-Research:mainfrom
tonbistudio:feat/memory-error-learning

Conversation

@tonbistudio
Copy link

Summary

  • The ingestion pipeline previously skipped all tool errors (if (tc.error) continue;), so agents never learned from failures ? causing repetitive error loops (e.g., PATH_TRAVERSAL spam for hundreds of turns)
  • 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, capped at 1.0), making them more prominent in memory retrieval

Details

src/memory/ingestion.ts

  • Added normalizeErrorType() helper that maps error strings to consistent labels (PATH_TRAVERSAL, TIMEOUT, PERMISSION_DENIED, RATE_LIMIT, etc.)
  • Replaced if (tc.error) continue; with error-learning block that uses existing SemanticMemoryManager.store() UPSERT semantics
  • Uses existing environment SemanticCategory ? no type changes needed

src/__tests__/memory.test.ts

  • 10 new tests covering: error normalization patterns, semantic fact storage, count incrementing on repeat errors, confidence capping, and error message truncation

Test plan

  • npx vitest run src/__tests__/memory.test.ts ? all 83 tests pass (10 new)
  • Full test suite ? no regressions (pre-existing failures in command-injection/skills-hardening unrelated)
  • Deploy to a running automaton and verify errors appear in semantic_memory table

?? Generated with Claude Code

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>
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.

1 participant