Skip to main content
make_langchain_tools wires a CodebaseMemory instance and an optional ImportGraph to a list of LangChain @tool-decorated callables. Pass the returned list directly into create_agent(tools=...) alongside your own tools. The factory shares the memory and graph objects you provide, so a finding stored in one step is available to the next recall in the same run.
from reasonblocks.integrations import make_langchain_tools

Installation

The LangChain integration requires langchain-core:
pip install reasonblocks langchain-core

make_langchain_tools

make_langchain_tools(
    memory: CodebaseMemory | None = None,
    graph: ImportGraph | None = None,
    *,
    recall_top_k: int = 5,
    recall_threshold: float = 0.25,
    enable_recall: bool = True,
    enable_store: bool = True,
    enable_impact: bool = True,
) -> list
Returns a list of LangChain @tool callables. The list contains up to three tools (recall_findings, store_finding, impact_analysis) depending on which arguments and flags you provide.

Parameters

memory
CodebaseMemory | None
default:"None"
The CodebaseMemory instance the tools read from and write to. When None, both recall_findings and store_finding are omitted from the returned list regardless of enable_recall and enable_store.
graph
ImportGraph | None
default:"None"
Optional ImportGraph for the repository. When provided and enable_impact=True, an impact_analysis tool is added.
recall_top_k
int
default:"5"
Maximum number of findings returned by a single recall_findings call.
recall_threshold
float
default:"0.25"
Minimum similarity score (0–1) a finding must reach to be included in recall results.
enable_recall
bool
default:"true"
Include the recall_findings tool. Set to False to produce a write-only or impact-only tool set. Has no effect when memory is None.
enable_store
bool
default:"true"
Include the store_finding tool. Set to False for read-only scenarios. Has no effect when memory is None.
enable_impact
bool
default:"true"
Include the impact_analysis tool when a graph is provided.

Returns

tools
list
A list of LangChain @tool-decorated callables. Concatenate with your own tool list and pass to create_agent.

Tools

recall_findings(query)

Searches CodebaseMemory for findings relevant to query. The tool returns the same string that CodebaseMemory.format_recall() produces.
ParameterTypeDescription
querystrNatural-language description of what you are looking for

store_finding(content, file_path, finding_type)

Persists a finding to CodebaseMemory. Returns "stored (id=<fid>)" on success or "store failed" on transport error.
ParameterTypeDefaultDescription
contentstrThe finding text (truncated to 8000 chars)
file_pathstr""Repo-relative path (truncated to 512 chars)
finding_typestr"note"Short tag — bug, behavior, pattern, note (truncated to 64 chars)

impact_analysis(file_path)

Calls ImportGraph.format_impact() and returns the rendered string of dependents and dependencies.
ParameterTypeDescription
file_pathstrRepo-relative path, e.g. "pydantic/main.py"
impact_analysis is only present when you pass a non-None graph and enable_impact=True. Check len(rb_tools) rather than assuming a fixed index if you build the list conditionally.

Complete example

import pathlib
from langchain.agents import create_agent
from langchain_anthropic import ChatAnthropic

from reasonblocks import CodebaseMemory, ImportGraph, ReasonBlocks
from reasonblocks.integrations import make_langchain_tools

rb = ReasonBlocks(api_key="rb_live_...")
memory = CodebaseMemory(codebase_id="my-repo", api_key="rb_live_...")
graph = ImportGraph().build_from_files(
    {str(p): p.read_text() for p in pathlib.Path("myrepo").rglob("*.py")}
)

rb_tools = make_langchain_tools(
    memory,
    graph,
    recall_top_k=8,
    recall_threshold=0.3,
)

model = ChatAnthropic(model="claude-haiku-4-5-20251001", max_tokens=1024)

with rb.middleware(
    run_id="run-1",
    agent_name="reviewer",
    task="Review PR #42",
    model="claude-haiku-4-5-20251001",
    codebase_id="my-repo",
) as mw:
    agent = create_agent(
        model=model,
        tools=[*rb_tools, *your_tools],
        system_prompt="You are a senior Python reviewer.",
        middleware=[mw],
    )
    result = agent.invoke({"messages": [("user", "Review PR #42")]})
Build the tool list once per agent run, not once per process. The closure over memory and graph is fine to share across calls inside the same run, but each run typically wants its own CodebaseMemory instance scoped to the right codebase_id.