Bug
The "System prompt is getting large. Run /doctor then /recompile" warning persists in the desktop app even after:
- Running
/doctor (multiple times)
- Running
/recompile (multiple times)
- Restarting the desktop app entirely
Evidence
From source code investigation of the CLI binary (/opt/homebrew/bin/letta):
- Threshold:
STARTUP_SYSTEM_PROMPT_WARNING_THRESHOLD_TOKENS = 30000 (line ~217325)
- Token estimation: Uses
Buffer.byteLength(text, "utf8") / 4 where SYSTEM_PROMPT_BYTES_PER_TOKEN = 4
- For memfs agents: Calls
estimateSystemPromptTokensFromMemoryDir() which only counts system/ files
- Actual token count:
letta memory tokens reports 14,195 tokens (was 21,100 before optimization — both well under 30K)
- Warning state: Stored in
systemPromptDoctorStateByAgent = new Map() — set on startup via buildStartupSystemPromptWarning(agentState) and refreshed on recompile via refresh_doctor_state command
Environment
- Letta Code CLI: v0.25.8 (installed via homebrew)
- Desktop app: latest (auto-updates separately from CLI)
- macOS Sequoia 15.x, Apple Silicon
- Agent with memfs enabled
Hypothesis
Two possible causes:
-
Estimation mismatch: The estimation function (byteLength/4) may be measuring the full compiled system prompt (including harness instructions, tool definitions, etc.) rather than just the system/ memory files. The compiled prompt is significantly larger than the memory-only count.
-
Stale state on recompile: The refresh_doctor_state command may not be properly resetting the warning state in the desktop app's in-memory Map. The warning persists across restarts, which suggests the state might be persisted somewhere (localStorage, app state) rather than being purely in-memory.
Steps to Reproduce
- Have an agent with memfs enabled and ~14-21K tokens of system/ memory
- Observe the warning on app startup
- Run
/doctor then /recompile
- Warning persists
Expected Behavior
Warning should not appear when system prompt tokens are below the 30K threshold.
Workaround
None found. The warning is cosmetic (agent operates normally) but causes unnecessary concern and user confusion.
Reported by agent investigation. Source code references from CLI binary at /opt/homebrew/bin/letta.
Bug
The "System prompt is getting large. Run /doctor then /recompile" warning persists in the desktop app even after:
/doctor(multiple times)/recompile(multiple times)Evidence
From source code investigation of the CLI binary (
/opt/homebrew/bin/letta):STARTUP_SYSTEM_PROMPT_WARNING_THRESHOLD_TOKENS = 30000(line ~217325)Buffer.byteLength(text, "utf8") / 4whereSYSTEM_PROMPT_BYTES_PER_TOKEN = 4estimateSystemPromptTokensFromMemoryDir()which only countssystem/filesletta memory tokensreports 14,195 tokens (was 21,100 before optimization — both well under 30K)systemPromptDoctorStateByAgent = new Map()— set on startup viabuildStartupSystemPromptWarning(agentState)and refreshed on recompile viarefresh_doctor_statecommandEnvironment
Hypothesis
Two possible causes:
Estimation mismatch: The estimation function (
byteLength/4) may be measuring the full compiled system prompt (including harness instructions, tool definitions, etc.) rather than just thesystem/memory files. The compiled prompt is significantly larger than the memory-only count.Stale state on recompile: The
refresh_doctor_statecommand may not be properly resetting the warning state in the desktop app's in-memory Map. The warning persists across restarts, which suggests the state might be persisted somewhere (localStorage, app state) rather than being purely in-memory.Steps to Reproduce
/doctorthen/recompileExpected Behavior
Warning should not appear when system prompt tokens are below the 30K threshold.
Workaround
None found. The warning is cosmetic (agent operates normally) but causes unnecessary concern and user confusion.
Reported by agent investigation. Source code references from CLI binary at
/opt/homebrew/bin/letta.