Skip to main content
make_openai_tools wraps a CodebaseMemory instance and an optional ImportGraph in @function_tool-decorated callables for the openai-agents SDK. Pass the returned list directly to Agent(tools=[...]).
from reasonblocks.integrations import make_openai_tools

Installation

pip install reasonblocks openai-agents

make_openai_tools

make_openai_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 up to three @function_tool-decorated callables (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 regardless of the enable flags.
graph
ImportGraph | None
default:"None"
Optional ImportGraph. When provided and enable_impact=True, an impact_analysis tool is added.
recall_top_k
int
default:"5"
Maximum number of findings per recall_findings call.
recall_threshold
float
default:"0.25"
Minimum similarity score for recall results.
enable_recall
bool
default:"true"
Include recall_findings. Has no effect when memory is None.
enable_store
bool
default:"true"
Include store_finding. Has no effect when memory is None.
enable_impact
bool
default:"true"
Include impact_analysis when a graph is provided.

Returns

tools
list
A list of @function_tool-decorated callables. Spread into the Agent tool list: tools=[*rb_tools, *your_tools].

Tools

recall_findings(query)

Searches CodebaseMemory and returns the formatted recall string.
ParameterTypeDescription
querystrNatural-language description of what you are looking for

store_finding(content, file_path, finding_type)

Persists a finding. 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 (truncated to 64 chars)

impact_analysis(file_path)

Calls ImportGraph.format_impact() and returns the rendered string.
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 asyncio
import pathlib
from agents import Agent, Runner
from reasonblocks import CodebaseMemory, ImportGraph, ReasonBlocks
from reasonblocks.integrations import make_openai_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_openai_tools(memory, graph)

agent = Agent(
    name="code-reviewer",
    instructions="You are a senior engineer reviewing Python codebases.",
    tools=[*rb_tools, *your_tools],
)

hooks = rb.openai_hooks(
    run_id="run-1",
    agent_name="code-reviewer",
    task="Review auth module for security issues",
)

async def main():
    async with hooks:
        result = await Runner.run(
            agent,
            input="Review auth/session.py for security issues",
            hooks=hooks,
        )
    print(result.final_output)

asyncio.run(main())

Telemetry: openai_hooks

make_openai_tools handles tool wiring only. Run telemetry — run_start, per-step events, and run_finish — is provided separately by rb.openai_hooks(), which returns a RunHooks adapter you pass to Runner.run(hooks=...).
openai_hooks is telemetry-only. Unlike the LangChain middleware, it does not inject E-trace steering text into the agent’s prompt. The OpenAI Agents SDK has no before_model analog to splice content into the system prompt mid-run; running openai_hooks gives you dashboard rows and per-step events but not in-loop steering.
For the full openai_hooks reference and lifecycle details, see the OpenAI Agents integration guide.