# ReasonBlocks ## Docs - [CodebaseMemory class reference](https://docs.reasonblocks.com/api-reference/codebase-memory.md): API reference for CodebaseMemory — store, recall, invalidate, and manage per-codebase agent findings with semantic search and cache coverage helpers. - [ImportGraph class reference](https://docs.reasonblocks.com/api-reference/import-graph.md): API reference for ImportGraph — build Python import graphs and query the blast radius of changed files to drive targeted cache invalidation. - [Anthropic and Claude SDK tool factories](https://docs.reasonblocks.com/api-reference/integrations/claude-tools.md): make_claude_tools() for the Anthropic Messages API and make_claude_agent_sdk_tools() for the Claude Agent SDK, both wiring CodebaseMemory and ImportGraph. - [LangChain tool factories for ReasonBlocks](https://docs.reasonblocks.com/api-reference/integrations/langchain-tools.md): make_langchain_tools() returns LangChain tools for CodebaseMemory recall, storing findings, and impact analysis — pass the list directly to create_agent. - [OpenAI Agents SDK tool factories](https://docs.reasonblocks.com/api-reference/integrations/openai-tools.md): make_openai_tools() creates function_tool callables for the openai-agents SDK, wiring CodebaseMemory recall, finding storage, and impact analysis. - [ReasonBlocks class reference](https://docs.reasonblocks.com/api-reference/reasonblocks.md): Complete API reference for the ReasonBlocks class — constructor options, middleware(), openai_hooks(), and the score_step() heuristic scorer. - [TokenSavingMiddleware reference](https://docs.reasonblocks.com/api-reference/token-saving-middleware.md): API reference for TokenSavingMiddleware — compress old tool outputs, trigger early exit when agents loop, and track token savings with stats. - [ETrace: retrieved steering pattern](https://docs.reasonblocks.com/api-reference/types/e-trace.md): Reference for the ETrace dataclass — fields returned when ReasonBlocks retrieves a pattern from the pattern store to inject into the agent system prompt. - [FSMState: agent difficulty state enum](https://docs.reasonblocks.com/api-reference/types/fsm-state.md): Reference for the FSMState enum — the six states ReasonBlocks uses to classify agent difficulty per step and trigger model routing and E-trace injection. - [StepRecord: per-step trace data](https://docs.reasonblocks.com/api-reference/types/step-record.md): Reference for the StepRecord dataclass — per-step fields captured by ReasonBlocks, and for TraceState, which tracks difficulty history and token totals. - [E-trace steering injection explained](https://docs.reasonblocks.com/concepts/e-traces.md): How ReasonBlocks injects instance-level, pattern-level, and universal guidance into your agent via E1, E2, and E3 traces appended to the system message. - [Agent difficulty states (FSM)](https://docs.reasonblocks.com/concepts/fsm-states.md): How ReasonBlocks classifies agent difficulty across FAST, NORMAL, SLOW, and SKIP states, and what each state means for model routing and E-trace injection. - [How ReasonBlocks works](https://docs.reasonblocks.com/concepts/how-it-works.md): An overview of the middleware pipeline: how ReasonBlocks scores each agent step, runs health monitors, injects steering guidance, and routes the model call. - [Health monitors for agent trajectories](https://docs.reasonblocks.com/concepts/monitors.md): The six built-in monitors that detect action loops, budget exhaustion, edit thrashing, test repetition, collapsed exploration, and rising hedging in agent runs. - [Advanced configuration options](https://docs.reasonblocks.com/configuration/advanced.md): Configure FSM thresholds, model routing, live streaming, customer scoping, stage timing instrumentation, and custom run metadata for production deployments. - [Monitor weight profiles and customization](https://docs.reasonblocks.com/configuration/monitor-profiles.md): Configure monitor weight profiles and per-monitor weights for coding, PR review, and QA use cases — with the default weights and fire threshold explained. - [ReasonBlocksConfig: full configuration reference](https://docs.reasonblocks.com/configuration/reasonblocks-config.md): Complete reference for the ReasonBlocksConfig dataclass — every tier toggle, token-saving lever, and routing field for assembling the full middleware stack. - [Persist agent findings with CodebaseMemory](https://docs.reasonblocks.com/guides/codebase-memory.md): Store, recall, and invalidate per-codebase agent findings using ReasonBlocks CodebaseMemory — a semantic findings store scoped to each codebase. - [Use ReasonBlocks with LangChain](https://docs.reasonblocks.com/guides/langchain.md): Step-by-step guide for adding ReasonBlocks middleware to LangChain and LangGraph agents, including run tagging, failure tracking, and CodebaseMemory tools. - [Route models by agent difficulty](https://docs.reasonblocks.com/guides/model-routing.md): Switch models automatically based on FSM difficulty state — cheaper models on easy steps, more powerful models when the agent is struggling. - [Use ReasonBlocks with OpenAI Agents](https://docs.reasonblocks.com/guides/openai-agents.md): Integrate ReasonBlocks telemetry and codebase memory tools into OpenAI Agents SDK applications using hooks and the make_openai_tools factory. - [Reduce token usage with TokenSavingMiddleware](https://docs.reasonblocks.com/guides/token-saving.md): Compress stale tool outputs, nudge stuck agents to exit early, and cut LLM costs with TokenSavingMiddleware — configurable, stackable, and framework-agnostic. - [Install and configure the ReasonBlocks SDK](https://docs.reasonblocks.com/installation.md): Install ReasonBlocks via pip, set your API key, and configure optional parameters like base URL for self-hosted deployments and E-trace retrieval. - [What is ReasonBlocks?](https://docs.reasonblocks.com/introduction.md): ReasonBlocks is a Python SDK that adds step scoring, E-trace injection, and health monitoring to LangChain and OpenAI Agents apps without changing your agent code. - [Get started with ReasonBlocks in five minutes](https://docs.reasonblocks.com/quickstart.md): Install the SDK, initialize ReasonBlocks, and add middleware to your LangChain agent. Your first instrumented run takes about five minutes to set up. - [Troubleshoot common ReasonBlocks issues](https://docs.reasonblocks.com/troubleshooting/common-issues.md): Diagnose and fix common setup problems including import errors, missing API key, absent steering injections, and runs that stay in-progress in the dashboard. - [Frequently asked questions](https://docs.reasonblocks.com/troubleshooting/faq.md): Answers to common questions about ReasonBlocks setup, API keys, E-traces, FSM behavior, middleware ordering, and run tagging for the dashboard.