Skip to main content
This page covers the parameters most integrations don’t need on day one but matter once you’re tuning a workload or instrumenting a benchmark.

ReasonBlocks constructor

All parameters except api_key are keyword-only.
The ReasonBlocks(...) constructor does not auto-read REASONBLOCKS_API_KEY — read it yourself and pass to api_key. The base_url default is read from REASONBLOCKS_BASE_URL at import time by reasonblocks._settings; setting it before importing reasonblocks will redirect the underlying HTTP clients without per-call configuration. REASONBLOCKS_API_TIMEOUT is read the same way.

FSM threshold tuning

The difficulty FSM classifies each step into INIT, FAST, NORMAL, SLOW, or SKIP based on a difficulty score in [0, 1]. Pass fsm_thresholds to adjust any subset of the defaults:
Hysteresis. Once in FAST, the FSM stays there until a single step scores above 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.
Unmapped states leave the agent’s configured model untouched. See Route models by FSM state for routing-specific details.

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.
To act on the budget, read it yourself and decide what to do:

Live streaming

Live streaming emits run_start / step / run_finish events to rb-api as the run progresses. On by default.
When live_streaming_enabled=False:
  • The StreamingEmitter is never constructed.
  • _maybe_emit_run_start, _maybe_emit_step, and _maybe_emit_run_finish short-circuit to no-ops.
  • No dashboard run row is created.
  • flush_session() calls go nowhere — there’s no emitter to flush. Don’t expect flush_session to 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-customer rb_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.
The six buckets: 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.
Named fields (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.