Skip to content

fix(llm): include system prompt tokens in memory compressor budget#3

Draft
0xhis wants to merge 2 commits intomainfrom
fix/memory-compressor-token-budget
Draft

fix(llm): include system prompt tokens in memory compressor budget#3
0xhis wants to merge 2 commits intomainfrom
fix/memory-compressor-token-budget

Conversation

@0xhis
Copy link
Copy Markdown
Owner

@0xhis 0xhis commented Mar 21, 2026

Summary

The memory compressor was not accounting for system prompt and agent identity tokens when calculating the conversation budget. This caused premature history truncation on long scans with large system prompts.

Changes

  • Add reserved_tokens parameter to compress_history() that subtracts already-accounted tokens from the budget before applying limits
  • Calculate reserved_tokens from system prompt and agent identity messages in _prepare_messages()

Files Changed

  • strix/llm/llm.py (+7/-2)
  • strix/llm/memory_compressor.py (+8/-1)

Split from usestrix#328.

@0xhis 0xhis force-pushed the fix/memory-compressor-token-budget branch from 2502a59 to 22d978e Compare March 21, 2026 08:28
0xhis added 2 commits March 21, 2026 01:49
The memory compressor was not accounting for system prompt and agent
identity tokens when calculating the conversation budget. This caused
premature history truncation on long scans with large system prompts.

Adds a reserved_tokens parameter to compress_history() that subtracts
already-accounted tokens from the budget before applying limits.
@0xhis 0xhis force-pushed the fix/memory-compressor-token-budget branch from 22d978e to 63035db Compare March 21, 2026 08:52
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