Skip to content

feat(memfs): enforce configurable system prompt token limit - #3614

Open
sarahwooders wants to merge 3 commits into
mainfrom
letta/configurable-memfs-system-token-limit-ef2755b1
Open

feat(memfs): enforce configurable system prompt token limit#3614
sarahwooders wants to merge 3 commits into
mainfrom
letta/configurable-memfs-system-token-limit-ef2755b1

Conversation

@sarahwooders

@sarahwooders sarahwooders commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Enforce an exclusive 20,000-token default limit for the staged MemFS system context, with current-layout preference and legacy memory/system/ fallback using the existing bytes-per-token heuristic.
  • Store per-repository overrides in tracked system/.letta-policy.yml; ordinary commits are blocked while the approval-gated CLI performs narrowly scoped policy commits without sweeping unrelated working-tree changes into them.
  • Add letta memory token-limit get|set: reads use the declarative read-only CLI table, while writes use native built-in alwaysAsk permission rules that survive unrestricted mode.
  • Keep the hook marker explicitly as an anti-accident guard rather than a security boundary, and document how agents should inspect usage and the configured limit during routine memory work.

Test plan

  • Run focused MemFS hook, token-limit CLI, permission-matcher, read-only-shell, and system-prompt estimator tests
  • Verify native alwaysAsk covers direct, absolute-path, and quoted CLI invocations without substring false positives
  • Verify current and legacy MemFS layouts use the same token-counting semantics
  • Verify token-limit commits preserve unrelated working-tree changes
  • Run bun run check (12/12 checks passing)

👾 Generated with Letta Code

Keep durable in-context memory below a safe default while allowing each memory repo to choose an explicit limit.

See [trace](https://app.letta.com/chat/agent-57231da8-42f3-4523-b190-66c3eda21057?conversation=conv-5011ca7e-88d2-4dd0-8933-c96938d2180b). Resume conversation with `letta --conv conv-5011ca7e-88d2-4dd0-8933-c96938d2180b`

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Store per-repository limits in a protected tracked policy so agents cannot silently reset enforcement, while exposing approved CLI access for intentional changes.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
Use native permission rules and declarative CLI paths so protected token-limit updates follow existing infrastructure without bespoke command classifiers or nonce handshakes.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.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