Skip to content

feat(kennel): strip personality emote lines before storing drawers#485

Open
SrividyaGanapathi wants to merge 2 commits into
mpfaffenberger:mainfrom
SrividyaGanapathi:feature/kennel-recorder-noise-filter
Open

feat(kennel): strip personality emote lines before storing drawers#485
SrividyaGanapathi wants to merge 2 commits into
mpfaffenberger:mainfrom
SrividyaGanapathi:feature/kennel-recorder-noise-filter

Conversation

@SrividyaGanapathi

Copy link
Copy Markdown

Summary

  • Adds _strip_noise() to recorder.py that removes Code Puppy personality emote lines (e.g. *wags tail excitedly*, *zooms around happily*) before a response is stored as a kennel drawer
  • Adds PUPPY_KENNEL_STRIP_NOISE env var to config.py (default on) so users can opt out without code changes
  • Adds tests/plugins/test_puppy_kennel_recorder.py with 13 correctness tests and 3 quantitative evals

Problem

Agent responses were stored verbatim, including personality emotes. These got packed back into the system prompt each session, consuming token budget with zero memory signal.

How it works

The sanitizer processes responses line-by-line before add_drawer is called:

  • Strips lines matching ^\s*\*(?!\*)[^*\n]+\*\s*$ (the RPG emote pattern)
  • Skips lines inside code fences — content between ``` is never touched
  • Leaves **bold**, * bullets, and inline *italic* mid-sentence untouched
  • Collapses blank lines left behind by stripped emotes

Evals (measured on a representative mixed response)

Metric Result
Char reduction per drawer 23.5%
Tokens saved per drawer ~42 tokens
Packer: drawers in 1500-token budget 8 → 11 (+37%)
Latency at 500 chars 0.014 ms
Latency at 5,000 chars 0.118 ms
Latency at 32,000 chars (max) 0.737 ms

Test plan

  • _strip_noise() strips emote lines
  • Bold, bullets, inline italic, code fences all preserved
  • All-emote response → blank → record_run_end no-ops (no drawer written)
  • PUPPY_KENNEL_STRIP_NOISE=0 disables filtering end-to-end
  • Token savings eval asserts ≥15% reduction
  • Packer eval asserts signal drawers surface in recall block
  • Latency eval asserts <5ms at all sizes (actual: <1ms)
uv run pytest tests/plugins/test_puppy_kennel_recorder.py -v
# 18 passed

🤖 Generated with Claude Code

SrividyaGanapathi and others added 2 commits June 16, 2026 18:36
Code Puppy's playful emotes (*wags tail excitedly*, *zooms around*) were
stored verbatim in the kennel and packed back into the system prompt each
session, wasting ~23% of the token budget on noise with zero memory value.

Add `_strip_noise()` to recorder.py that removes lines matching the RPG
emote pattern (*...*) while preserving code fences, bold text, bullet
points, and inline italics. Controlled by PUPPY_KENNEL_STRIP_NOISE env
var (default on).

Evals on a representative mixed response:
- 23.5% char reduction per drawer (~42 tokens saved)
- Packer fits 8 → 11 drawers in the 1500-token budget (+37%)
- Latency: <1ms even at max drawer size (32k chars)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- F541: remove f-prefix from strings without placeholders (lines 282, 333)
- F841: remove unused variable `pure_emote` (line 311)
- E741: rename ambiguous loop variable `l` to `line` (line 363)
- ruff format: apply auto-formatting

Co-Authored-By: Claude Sonnet 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