Skip to content

Capture: smart existing entry selection for LLM prompt #89

Closed

Description

@itdove

Summary

extract_knowledge sends existing entries to the LLM so it can avoid duplicates. Currently sends all keys (truncated to last 50). For large knowledge bases, this wastes prompt tokens on irrelevant entries.

Current behavior

existing_text = "\n".join(f"- {e.key}" for e in existing[-50:])

Proposed improvement

Use vector search to find existing entries most similar to the transcript, then only include those in the prompt:

  1. Embed the transcript (or a summary of it)
  2. query_vector(embedding, limit=20) to get closest existing entries
  3. Send only those 20 entries (keys + short value snippets) to the LLM

This gives the LLM better context for dedup while keeping the prompt small.

Per-model token budgets (future)

Different models have different context windows. Could add per-model config:

  • phi4-mini: ~4K usable for existing entries
  • llama3: ~8K
  • claude: ~100K

The capture prompt would auto-adjust the number of existing entries based on model capacity.

Acceptance Criteria

  • Existing entries sent to capture LLM are filtered by relevance to transcript
  • Prompt stays within model capacity
  • Capture still detects duplicates effectively
  • Falls back to keys-only if embedding unavailable

Discovered during #37 demo testing.

Activity

  1. self-assigned this
    on Sep 8, 2026
  2. itdove commented on Sep 8, 2026

    @itdove
    OwnerAuthor

    Implemented on branch 89:

    • Existing capture context is filtered to up to 20 vector-relevant entries.
    • Relevant entries include normalized value snippets capped at 240 characters.
    • Exact duplicate/update checks still use the complete existing-entry set.
    • Embedding, provider, or vector-search failures fall back to keys-only context.
    • Added regression tests for relevance selection, fallback behavior, exact deduplication, and prompt truncation.

    Verification: focused capture/LLM tests pass (34); full suite has 652 passing tests and 3 unrelated failures caused by the sandbox read-only /home/itdove/.cache/lore PR-workdir path.

  3. itdove commented on Sep 8, 2026

    @itdove
    OwnerAuthor

    ✅ Session Complete

    Project: lore
    Goal: #89: Capture: smart existing entry selection for LLM prompt
    Time Spent:
    0h 14m total

    • itdove: 0h 13m
    • unknown: 0h 0m
      Branch: 89

    No significant activity detected in this session.

    Session Notes:

    Session Notes: itdove-lore-89

    JIRA: #89

    2026-09-08 11:50

    • Implemented issue Capture: smart existing entry selection for LLM prompt #89: capture now embeds the transcript and sends up to 20 vector-relevant existing entries with bounded value snippets; exact duplicate/update classification still uses the full store; embedding/config/vector failures fall back to keys-only context. Added focused capture and Ollama prompt tests. Verification: focused tests 34 passed; full suite 652 passed, 3 unrelated failures in PR creation paths because /home/itdove/.cache/lore is read-only in this environment.

    Generated by DevAIFlow

  4. itdove commented on Sep 8, 2026

    @itdove
    OwnerAuthor

    Pull request created: #96

  5. itdove commented on Sep 8, 2026

    @itdove
    OwnerAuthor

    ✅ Session Complete

    Project: lore
    Goal: #89: Capture: smart existing entry selection for LLM prompt
    Time Spent:
    0h 15m total

    • itdove: 0h 14m
    • unknown: 0h 0m
      Branch: 89

    No significant activity detected in this session.

    Session Notes:

    Session Notes: itdove-lore-89

    JIRA: #89

    2026-09-08 11:50

    • Implemented issue Capture: smart existing entry selection for LLM prompt #89: capture now embeds the transcript and sends up to 20 vector-relevant existing entries with bounded value snippets; exact duplicate/update classification still uses the full store; embedding/config/vector failures fall back to keys-only context. Added focused capture and Ollama prompt tests. Verification: focused tests 34 passed; full suite 652 passed, 3 unrelated failures in PR creation paths because /home/itdove/.cache/lore is read-only in this environment.

    Generated by DevAIFlow

  6. added a commit that references this issue on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions