Skip to content

refactor: clean AI slop (-1886 lines) and fix 5 P0 capability gaps#70

Merged
Tuanzi1015 merged 1 commit into
MLT-OSS:mainfrom
lml2468:feat/slop-cleanup-and-p0-gaps
Apr 11, 2026
Merged

refactor: clean AI slop (-1886 lines) and fix 5 P0 capability gaps#70
Tuanzi1015 merged 1 commit into
MLT-OSS:mainfrom
lml2468:feat/slop-cleanup-and-p0-gaps

Conversation

@lml2468
Copy link
Copy Markdown
Contributor

@lml2468 lml2468 commented Apr 11, 2026

Summary

  • AI slop cleanup: Remove 1,886 lines of dead code, duplicate logic, and unused abstractions across 34 files
  • Fix MCP deadlock bug: RefreshTools called DiscoverTools while holding mutex — would deadlock on SSE tool change notifications
  • Fix 5 P0 capability gaps identified from reference implementation comparison

Slop Cleanup

  • Delete 8 dead code files (models_dev, checkpoints, rate_limit_tracker, subdirectory_hints, prompt_caching, display, redact + test)
  • Remove 20+ dead functions (loadResumedHistory, fireToolGenStarted, SetupFromEnv, ProbeContextLength, hasStreamingCallbacks, termWidth, hexToRGB, custom min, etc.)
  • Replace stdlib reimplementations with strings.Contains, builtin min
  • Consolidate splitMessage duplication in dmwork.go
  • Delete empty content filter hook and manual containsIgnoreCase
  • Unexport internal-only helpers (defaultStatePath, parseRetryAfter, strategyFromConfig)
  • Fix writeToLogFile to use config.HermesHome() instead of hardcoded ~/.hermes/logs

P0 Capability Gaps Fixed

Gap Change
resolveTools() hardcoded Wire to toolsets.ResolveMultipleToolsets() with enabled/disabled support
Context file injection Add scanContextContent() with 10 threat patterns + invisible Unicode detection
Secret redaction Implement 23 regex patterns, wire into agent loop after tool dispatch
Anthropic prompt caching Apply cache_control to last 3 messages (~75% input cost reduction)
vision_analyze stub Actually call multimodal LLM with image data (base64/URL support)

Test plan

  • go build ./... passes
  • go vet ./... clean
  • make test — all 14 packages pass
  • New tests: context_refs_test.go (25 tests), redact_test.go (13 tests)

Slop cleanup (-1,847 lines):
- Delete 8 dead code files (models_dev, checkpoints, rate_limit_tracker,
  subdirectory_hints, prompt_caching, display, redact, rate_limit_tracker_test)
- Remove dead functions: loadResumedHistory, fireToolGenStarted, SetupFromEnv,
  ProbeContextLength, hasStreamingCallbacks, termWidth, hexToRGB, min, etc.
- Replace custom stdlib reimplementations with strings.Contains, builtin min
- Consolidate splitMessage in dmwork.go to use platforms.SplitMessage
- Delete empty content filter hook and containsIgnoreCase
- Remove dead currentBlockType variable and _ = strings.Contains workaround
- Unexport internal helpers (defaultStatePath, parseRetryAfter, strategyFromConfig)
- Fix writeToLogFile to use config.HermesHome() instead of hardcoded path
- Fix MCP RefreshTools deadlock (called DiscoverTools while holding mutex)
- Simplify resolveTools() signature (removed unused parameters)

P0 capability gaps fixed:
- Wire resolveTools() to toolsets package with enabled/disabled support
- Add context file injection scanning (10 threat patterns + invisible Unicode)
- Implement secret redaction (23 regex patterns) wired into agent loop
- Add Anthropic prompt caching for last 3 messages (~75% input cost reduction)
- Make vision_analyze call multimodal LLM with image data (base64/URL)
- Add ImageURLs multimodal support to llm.Message and OpenAI client
@Tuanzi1015 Tuanzi1015 merged commit d197ad0 into MLT-OSS:main Apr 11, 2026
7 of 8 checks passed
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.

2 participants