Skip to content

feat: make MAX_RECALL_QUERY_LENGTH configurable for auto-recall #373

@jlin53882

Description

@jlin53882

Problem

When auto-recall is enabled, long prompts (e.g. file attachment descriptions, multi-turn conversation summaries) are passed directly as embedding queries without any length limit. This causes two issues:

  1. Embedding quality degrades for very long queries — the semantic signal gets diluted when the query contains thousands of characters of surrounding context
  2. No user visibility into when and by how much queries are truncated

In practice, query lengths of 1002-1777 chars are common, and a 1000-char hardcoded limit is too restrictive for meaningful queries.

Proposed Solution

Make the auto-recall query length limit configurable via config.autoRecallMaxQueryLength, defaulting to 2000 chars:

const MAX_RECALL_QUERY_LENGTH = config.autoRecallMaxQueryLength ?? 2_000;

This mirrors the existing pattern used for other auto-recall config parameters:

  • config.autoRecallMaxItems (default: 3)
  • config.autoRecallMaxChars (default: 600)
  • config.autoRecallPerItemMaxChars (default: 180)

Why this improves quality

  • Embedding models typically perform best with focused, concise query text
  • A configurable limit lets users tune based on their embedding provider's context window
  • Users get log visibility (memory-lancedb-pro: auto-recall query truncated from X to Y chars) when truncation happens

Additional notes

  • FR-04 in the codebase already documents the intent: "Auto-recall only needs the user's intent, not full attachment text"
  • A configurable limit enables this intent without forcing an overly restrictive hardcoded value

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions