Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Context bloat 400k tokens in 3 min after restart #2568

Unanswered
varunbaranwal asked this question in Q&A
Discussion options

Issue Summary

Container restart does not clear accumulated session context. Running agent session continues to load massive context despite restart, resulting in 90%+ increase in API token costs.


Technical Details

Session Information:

  • Session ID: sess-1778272236516-2bodft
  • Agent Group: Prachin (Private Secretary Agent)
  • Messaging Group: telegram-mg-17782 (Telegram)
  • Session Started: May 8, 2026
  • Container Status: Restarted May 19, 2026, 8:53 AM IST

Issue Timeline:

Date/Time Event Token Usage
May 8 Session created, initial usage baseline ~5-10K/msg
May 17 Context bloat warning identified ~100K/msg
May 19, 8:45 AM Spike detected: 575K tokens in 3 min ~192K/msg
May 19, 8:53 AM Container restarted (docker restart) -
May 19, 8:58 AM Post-restart spike: 397K tokens in 3 min ~132K/msg
May 20, 9:00 AM Status: No improvement, continues at 132K/msg 132K/msg

Root Cause Analysis

Expected Behavior:

  • Fresh session restart should clear context
  • New messages should load minimal context (~5-10K tokens)
  • Cost should drop 90%

Actual Behavior:

  • Container restart completed successfully
  • Session ID remains same: sess-1778272236516-2bodft
  • Context size: Still ~130K tokens per message
  • No cost reduction observed

Hypothesis:

  1. Session context persisted in database/cache despite container restart
  2. Agent loading accumulated context from storage layer, not fresh memory
  3. Possible: inbound.db or outbound.db not cleared
  4. Possible: Session container restarted but agent retained state

Business Impact

Cost Analysis:

Scenario Tokens/Message Weekly Cost Annual Cost
Baseline (target) 5-10K ~0ドル.15 ~8ドル
Current bloat 130K ~4ドル/week ~200ドル
Cost increase 12-26x 26x higher 25x higher

Operational Impact:

  • Cost optimization strategy blocked
  • Cannot implement weekly context resets
  • System unsustainable at current usage rates
  • User unable to meet cost targets

Steps Taken So Far

  1. âœ" Identified context bloat (May 17)
  2. âœ" Implemented file-based workflow to reduce conversation context
  3. âœ" Attempted container restart (May 19, 8:53 AM)
  4. âœ" Verified restart did not resolve issue
  5. âœ" Documented metrics and timeline
  6. → Escalating for infrastructure investigation

Data for Debugging

Session Creation Query:

Session: sess-1778272236516-2bodft
Agent Group: ag-1778272236511-97z4s3 (Prachin)
Container: f15e22cf6a58 (hostname)
Last Active: May 20, 2026, 9:01 AM UTC
Status: active/running

Affected Configuration:

  • NanoClaw v2 on Raspberry Pi 5 (4GB RAM)
  • Claude Model: Haiku 4.5
  • Integration: Telegram bot
  • Session Mode: shared

Requested Resolution

  1. Root Cause Investigation: Why does session context persist after container restart?
  2. Database Check: Verify inbound.db/outbound.db cleared on restart
  3. Cache Inspection: Check if context cached at higher level
  4. Fix: Implement proper context cleanup on container restart
  5. Verification: Test that restart actually clears session context

Workaround Status

Current Mitigation (File-Based Workflow):

  • Using persistent files instead of conversation memory
  • Files: meeting-agenda.md, tasks.md, reminders.md, policy-ideas.md
  • Reduces context per message, but doesn't address root cause
  • Effective only if other users don't inflate context
  • Still costs 12-26x baseline

Sustainability: Workaround not sustainable long-term at current cost levels.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /