Skip to content

feat: make auto-recall query length limit configurable (autoRecallMaxQueryLength)#374

Open
jlin53882 wants to merge 1 commit intoCortexReach:masterfrom
jlin53882:feat/configurable-auto-recall-query-length
Open

feat: make auto-recall query length limit configurable (autoRecallMaxQueryLength)#374
jlin53882 wants to merge 1 commit intoCortexReach:masterfrom
jlin53882:feat/configurable-auto-recall-query-length

Conversation

@jlin53882
Copy link
Copy Markdown
Contributor

Summary

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

Problem

When auto-recall is enabled, the full event.prompt (which may include long file attachment descriptions, conversation metadata, or multi-turn context) is passed directly as the embedding query. This can dilute the semantic signal and produce lower-quality retrieval results.

Solution

Add FR-04 truncation logic before embedding, configurable via config.autoRecallMaxQueryLength:

const MAX_RECALL_QUERY_LENGTH = config.autoRecallMaxQueryLength ?? 2_000;
let recallQuery = event.prompt;
if (recallQuery.length > MAX_RECALL_QUERY_LENGTH) {
  const originalLength = recallQuery.length;
  recallQuery = recallQuery.slice(0, MAX_RECALL_QUERY_LENGTH);
  api.logger.info(
    `memory-lancedb-pro: auto-recall query truncated from ${originalLength} to ${MAX_RECALL_QUERY_LENGTH} chars`
  );
}

Design notes

  • Mirrors existing pattern: autoRecallMaxItems, autoRecallMaxChars, autoRecallPerItemMaxChars all follow the same config.X ?? default pattern
  • Default of 2000: Allows richer queries than the 1000-char limit some users had patched locally
  • Log visibility: When truncation occurs, an info-level log is emitted so operators can observe behavior
  • Consistent with FR-04 intent: "Auto-recall only needs the user's intent, not full attachment text"

Related

…lMaxQueryLength (default 2000)

- Add FR-04 truncation before embedding to keep query focused
- Make MAX_RECALL_QUERY_LENGTH configurable via config.autoRecallMaxQueryLength
- Default to 2000 chars (previously hardcoded 1000 in some builds)
- Add info log when truncation occurs for visibility
- Mirrors existing config pattern (autoRecallMaxItems, autoRecallMaxChars, etc.)
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0ab0ba0ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


// FR-04: Truncate long prompts (e.g. file attachments) before embedding.
// Auto-recall only needs the user's intent, not full attachment text.
const MAX_RECALL_QUERY_LENGTH = config.autoRecallMaxQueryLength ?? 2_000;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Wire new query-length setting into parsed config

config.autoRecallMaxQueryLength is read here, but parsePluginConfig never copies cfg.autoRecallMaxQueryLength into the returned PluginConfig, so this value is always undefined at runtime and the code always falls back to 2_000. In practice, users cannot actually configure the limit despite the commit message and inline docs saying they can.

Useful? React with 👍 / 👎.

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