AttributeError: module 'reasonblocks' has no attribute X
AttributeError: module 'reasonblocks' has no attribute X
SymptomWhat this means
reasonblocks/__init__.py resolves public names lazily through a PEP 562 __getattr__. The _LAZY mapping in __init__.py covers every documented name, including TokenSavingMiddleware, GeneralMonitorMiddleware, ReasonBlocks, ReasonBlocksAPI, MonitorClient, compress_tool_output, and assign_arm. Accessing any of them on the module object should succeed.If you hit this error for a documented name, that’s a bug in the lazy mapping (the name is in the docs but missing from _LAZY). File an issue with the exact name you tried to access and the SDK version.For internal names (anything not exported in __all__), import directly from the submodule:ImportError: cannot import name 'AgentMiddleware' from 'langchain'
ImportError: cannot import name 'AgentMiddleware' from 'langchain'
CauseReasonBlocks requires LangChain 1.0+.
AgentMiddleware, ModelRequest, and ModelResponse were introduced in 1.0.FixImportError: No module named 'networkx'
ImportError: No module named 'networkx'
CauseIf you don’t use
networkx is only needed for ImportGraph (reasonblocks.import_graph). It’s an optional dependency.FixImportGraph, remove the import — the rest of the SDK doesn’t touch networkx.No steering injections appearing in any run
No steering injections appearing in any run
SymptomEvery entry in 2. Wrong 3. 5. E1 monitor gate deniesE1 only retrieves when monitors signal trouble (a monitor fired in the current step or one of the previous two, or composite >
mw.step_log has empty injection_sources and intervention_texts. The agent runs, but receives no guidance.Walk through these in order1. Missing or invalid api_keyEmpty, malformed, or revoked keys cause silent API failure. Enable debug logging:base_urlVerify the endpoint:e_traces_enabled=FalseDisables E1/E2/E3 entirely. Default is True.4. FSM stays in FASTAll E-tracing skips when the FSM is FAST. Inspect:0.15). Healthy runs leave E1 quiet by design. E2 and E3 should still fire — check injection_sources for those tiers.6. Per-tier capsE1 caps at one retrieval per run. E2 caps at one. E3 fires only on step 0. Monitor steering caps at 5 per run with cooldowns: SLOW/SKIP=2, NORMAL=3, FAST=5.Agent never enters FAST mode
Agent never enters FAST mode
SymptomThe FSM stays in Inspect the raw distribution of difficulty scores to calibrate:
NORMAL even on steps that look easy.CauseThe default fast_threshold is 0.2 and fast_window is 6. The agent must score below 0.2 on six consecutive steps to enter FAST. The shipped heuristic scorer weights hedging language, length, error references, and entity density — agents with verbose intermediate reasoning may never drop below 0.2.FixRaise fast_threshold or shrink fast_window:Too many steering injections — agent looks over-guided
Too many steering injections — agent looks over-guided
CauseMonitor steering is capped at Fix for monitor steeringIndirectly, raise the FSM thresholds so the agent reaches SLOW less aggressively (SLOW has the shortest cooldown):
_monitor_max_per_run = 5 per run with FSM-state cooldowns (SLOW/SKIP=2, NORMAL=3, FAST=5). E1 and E2 each cap at one retrieval per run; E3 fires only on step 0. So the cap from ReasonBlocksMiddleware itself is bounded.If you’re seeing many more injections than that, the source is most likely GeneralMonitorMiddleware (when enabled separately) — its rule cooldown defaults to 8.Fix for GeneralMonitorTokenSavingMiddleware isn't compressing tool outputs
TokenSavingMiddleware isn't compressing tool outputs
Symptom
mw.stats.compressions stays at 0 after a run that produced long tool outputs.Causes (check in order)- Tool outputs are shorter than
compress_threshold_chars(default1800). - Fewer than
keep_recent_tool_messages + 1tool messages exist (defaults to 2 — with only 2 tool messages, both are exempt). enable_compression=Falsewas set explicitly.- Tool messages have no
id— without one, the LangGraphadd_messagesreducer can’t dedup, so the middleware skips compression rather than appending duplicates. This is rare and usually a custom-tool issue. - Middleware ordering:
TokenSavingMiddlewareshould be last in the list. When stacking withReasonBlocksMiddleware(orGeneralMonitorMiddleware), placing it earlier means it processes history before injections land.
build_middleware() or rb.middleware() to get the right order automatically. When constructing middleware manually:Dashboard shows runs as 'in progress' indefinitely
Dashboard shows runs as 'in progress' indefinitely
SymptomRuns appear in the dashboard with a spinner or “in progress” status and never transition to “complete”.CauseA run row only flips to “complete” when ReasonBlocks emits a If the context manager isn’t an option, call To override the default
run_finish event. That happens in two places:after_agenthook — fires when LangChain finishesagent.invoke()cleanly.__exit__on the context manager — fires when thewith mw:block exits (success or exception).
flush_session), the run row stays open.FixUse the context manager:flush_session yourself:"success" outcome when the agent returned normally but the run was logically a failure, call mw.mark_failure(reason=...) before after_agent fires (or before the with block exits).
