ReasonBlocks constructor
All parameters exceptapi_key are keyword-only.
FSM threshold tuning
The difficulty FSM classifies each step intoINIT, FAST, NORMAL, SLOW, or SKIP based on a difficulty score in [0, 1]. Pass fsm_thresholds to adjust any subset of the defaults:
fast_threshold + hysteresis_margin (default 0.30). Once in SLOW, it stays until a step scores below slow_threshold - hysteresis_margin (default 0.50). This prevents one borderline step from bouncing the agent back to NORMAL immediately.
Model routing
model_routing maps any of "FAST", "NORMAL", "SLOW", "SKIP" to a model identifier. Routing applies inside wrap_model_call after FSM scoring, before pattern injections render.
Token budget (tracked, not enforced)
token_budget is tracked-only. The middleware records token usage from every model call onto the trace state, and TraceStateManager.get_budget_used() returns the fraction consumed. The FSM does not transition to SKIP when the budget is exhausted, and no inputs are rejected.
Live streaming
Live streaming emitsrun_start / step / run_finish events to rb-api as the run progresses. On by default.
live_streaming_enabled=False:
- The
StreamingEmitteris never constructed. _maybe_emit_run_start,_maybe_emit_step, and_maybe_emit_run_finishshort-circuit to no-ops.- No dashboard run row is created.
flush_session()calls go nowhere — there’s no emitter to flush. Don’t expectflush_sessionto produce a run row after a network outage; if streaming was disabled, no events have been queued.- Local behavior — FSM scoring, monitor steering, injection, model routing — is unaffected.
E1 scoping
E1 retrieval is scoped to your organization automatically — rb-api derives the scope from the API key’s principal (a per-customerrb_live_* key carries its org). There is no client-side customer_id parameter on the ReasonBlocks constructor or ReasonBlocksConfig; runs under the same key share an E1 pattern pool, and other organizations stay isolated.
Stage-timing instrumentation
ReasonBlocksMiddleware can record per-stage latencies in milliseconds across six buckets. Useful for breaking down where SDK overhead lives during a benchmark.
Each list contains one float per step the stage actually ran. Stages that didn’t run (e.g. E1 under FAST) produce no entry.
Custom run metadata
metadata on rb.middleware() (or on rb.openai_hooks()) merges into the run record’s JSON metadata column. Anything not consumed by named fields rides along.
agent_name, task, framework, model, codebase_id, org_id, project_id, task_profile) are popped out before metadata is serialized, so they don’t double-count.
Self-hosted deployments
base_url is forwarded to every internal API client (E-trace retrieval, monitor evaluation, live telemetry). Trailing slashes are stripped.
