Skip to content

fix(local): inherit conversation context_window_limit from model_settings#3235

Open
abhay-codes07 wants to merge 1 commit into
letta-ai:mainfrom
abhay-codes07:fix/local-conversation-context-window
Open

fix(local): inherit conversation context_window_limit from model_settings#3235
abhay-codes07 wants to merge 1 commit into
letta-ai:mainfrom
abhay-codes07:fix/local-conversation-context-window

Conversation

@abhay-codes07

@abhay-codes07 abhay-codes07 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New local-backend conversations dropped the agent's configured context_window_limit: the desktop draft flow (and other callers) send the limit nested inside model_settings, but createLocalConversationRecord only read the top-level context_window_limit field. The stored record ended up without a limit, so every new conversation fell back to the hardcoded 128000 default even when the agent was configured with a much larger window.
  • Lift model_settings.context_window_limit to the conversation record's top-level field at creation when no explicit top-level value is provided. An explicit top-level value still wins, and conversations with no configured limit keep the field unset.

Fixes #3132.

Test plan

  • bun test src/backend/local-backend.test.ts — adds a repro test (fails without the fix) plus guards for top-level precedence and the no-limit case
  • bun run check
  • Full unit suite — no new failures vs a clean main baseline on the same machine

AI disclosure

Following the policy proposed in #3139: this PR was developed with AI assistance (Claude Code) — the investigation, patch, and tests were AI-assisted. I directed the work, reviewed the change, and ran the validation above locally; the repro test was mutation-checked (it fails with the fix reverted).

cc @cpacker — this sits right next to the record-normalization work in #3136, happy to adjust if you'd rather fold it in there.

Copilot AI review requested due to automatic review settings July 6, 2026 13:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…ings

New conversations created against the local backend only honored a
top-level context_window_limit field, but the desktop draft flow sends
the limit nested inside model_settings. The stored record ended up
without a limit and every consumer fell back to the 128000 default,
even when the agent was explicitly configured with a larger window.

Lift the nested value to the record's top-level field at creation via
conversationContextWindowLimitFromBody (placed in local-model-
normalization.ts next to supportedConversationModelSettingsFromBody). An
explicit top-level value still wins, and conversations without any
configured limit keep the field unset.

Fixes letta-ai#3132
@abhay-codes07
abhay-codes07 force-pushed the fix/local-conversation-context-window branch from aa75987 to 5932946 Compare July 15, 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.

Local backend: new conversations don't inherit agent's context_window_limit — always fall back to hardcoded 128000

2 participants