Skip to content

feat(engine): Think/Recall/Sessions intelligence layer#5

Merged
EtanHey merged 1 commit into
mainfrom
feat/think-recall-engine
Feb 19, 2026
Merged

feat(engine): Think/Recall/Sessions intelligence layer#5
EtanHey merged 1 commit into
mainfrom
feat/think-recall-engine

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented Feb 19, 2026

Summary

  • New engine.py module with three capabilities: think, recall, sessions
  • think(context): Given current task, retrieve categorized past knowledge (decisions, patterns, bugs, context)
  • recall(file_path|topic): Proactive retrieval — file timeline, session history, related knowledge
  • sessions(project, days): Browse recent sessions by date/project
  • 3 new MCP tools wired into the server (11 total)
  • 29 tests (24 unit + 5 integration), all pass in <2s

Architecture

engine.py (pure logic, testable)
    ↕
mcp/__init__.py (async wrappers, MCP protocol)
    ↕
vector_store.py (DB queries)

Test plan

  • 24 unit tests: categorization, formatting, edge cases (0.17s)
  • 5 integration tests: session queries, file recall with real DB (1.37s)
  • All 19 existing tests still pass (no regressions)
  • MCP tool list verified: 11 tools registered
  • Import verification passes

🤖 Generated with Claude Code


Note

Medium Risk
Adds new retrieval endpoints that query the vector DB and run embeddings via MCP, expanding the public tool surface and introducing new query/formatting paths that could impact performance or error handling.

Overview
Introduces a new engine.py “Think/Recall/Sessions” layer that builds structured, markdown-formatted outputs for (1) context-aware memory retrieval (think) with intent-based grouping and an importance floor, (2) proactive file/topic recall (recall) combining file timelines, session context, and related hybrid search, and (3) recent session browsing (sessions) backed by direct session_context SQL queries.

Wires these capabilities into the MCP server as three new read-only tools (brainlayer_think, brainlayer_recall, brainlayer_sessions) with async wrappers that offload embedding + engine work to an executor. Adds a new test_engine.py suite covering categorization/formatting plus DB-backed integration checks for sessions and file-based recall.

Written by Cursor Bugbot for commit c1773df. This will update automatically on new commits. Configure here.

Add engine.py with three new capabilities:
- think(context): Retrieve relevant past decisions, patterns, and
  bugs given current task context. Categorizes by intent.
- recall(file_path|topic): Proactive retrieval — file interaction
  timeline, session history, and related knowledge.
- sessions(project, days): Browse recent sessions by date/project.

Wire into MCP server as 3 new tools (11 total):
- brainlayer_think: Pre-task context injection
- brainlayer_recall: File/topic-based proactive retrieval
- brainlayer_sessions: Session browsing

29 tests (24 unit + 5 integration), all pass in <2s.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@EtanHey EtanHey merged commit a297f7e into main Feb 19, 2026
0 of 3 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 19, 2026

Warning

Rate limit exceeded

@EtanHey has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between eaed3cc and c1773df.

📒 Files selected for processing (3)
  • src/brainlayer/engine.py
  • src/brainlayer/mcp/__init__.py
  • tests/test_engine.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/think-recall-engine

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread src/brainlayer/engine.py
DECISION_INTENTS = {"deciding", "designing"}
DEBUG_INTENTS = {"debugging"}
IMPLEMENT_INTENTS = {"implementing", "configuring"}
REVIEW_INTENTS = {"reviewing", "discussing"}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

REVIEW_INTENTS constant defined but never used

Low Severity

REVIEW_INTENTS ({"reviewing", "discussing"}) is defined at module level alongside DECISION_INTENTS, DEBUG_INTENTS, and IMPLEMENT_INTENTS, but categorize_by_intent never references it. Items with "reviewing" or "discussing" intents silently fall through to the else branch and land in the context bucket instead of getting their own category. The constant adds confusion by implying a category that doesn't exist.

Additional Locations (1)

Fix in Cursor Fix in Web

Comment thread src/brainlayer/engine.py
"project": meta.get("project", ""),
"created_at": meta.get("created_at", ""),
}
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Identical chunk-building code duplicated in recall

Low Severity

The recall function contains two character-for-character identical blocks that build related_chunks dicts from search results — one in the file_path branch and one in the topic branch. If a field mapping or default ever needs to change (e.g. adding tags like think does), it must be updated in both places, risking inconsistent fixes.

Additional Locations (1)

Fix in Cursor Fix in Web

@EtanHey EtanHey deleted the feat/think-recall-engine branch February 19, 2026 20:22
EtanHey added a commit that referenced this pull request Feb 19, 2026
Add engine.py with three new capabilities:
- think(context): Retrieve relevant past decisions, patterns, and
  bugs given current task context. Categorizes by intent.
- recall(file_path|topic): Proactive retrieval — file interaction
  timeline, session history, and related knowledge.
- sessions(project, days): Browse recent sessions by date/project.

Wire into MCP server as 3 new tools (11 total):
- brainlayer_think: Pre-task context injection
- brainlayer_recall: File/topic-based proactive retrieval
- brainlayer_sessions: Session browsing

29 tests (24 unit + 5 integration), all pass in <2s.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.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