Spaces:
Running on Zero
Running on Zero
Commit History
25 days ago
-
Part 31E: cap memory payloads to prevent Groq token blowup
Bug: WebUI 413s on tool calls after 2-3 turns because Part 8 memory layer replayed full history including 15 KB base64 chart images from python_eval, blowing Groq's 8K TPM budget. Fixes in src/sunnyware/memory.py: - _sanitize_content() helper: redacts 500+ char base64 runs (mixed-case + digits required to avoid false positives on plain text) and truncates to per-tier caps - log_event(): sanitize payload.content before DB write MAX_LOG_CONTENT_CHARS = 2000 - build_context(): sanitize replayed messages MAX_HISTORY_CONTENT_CHARS = 800 - format_context(): sanitize cross-session context MAX_CONTEXT_CONTENT_CHARS = 200 - build_context default max_turns: 10 -> 6 Smoke: scripts/memory_cap_smoke.py — 9 checks, all passing - tests cover: truncation, base64 redaction, 10x15KB replay collapse Verified: WebUI chart request no longer hits HTTP 413.c3e8dd2