Skip to content

Reasoning API

The client.reasoning namespace exposes reasoning scaffolding and meta-learning controls that amplify model performance without changing the provider.

SDK proxy

crp.sdk.proxies._ReasoningProxy

Reasoning / meta-learning proxy (SPEC-019, §12, §13).

Exposes reasoning scaffolds, source grounding retrieval, CQS detection, and cross-window validation.

scaffold(task, **kwargs)

Build a reasoning scaffold for task.

Parameters:

Name Type Description Default
task str

Task description.

required
**kwargs Any

Additional options forwarded to the meta-learning engine.

{}

Returns:

Type Description
str

Scaffold string (empty if scaffolding is disabled).

sources(fact_id=None, **kwargs)

Retrieve source passages linked to a fact.

Parameters:

Name Type Description Default
fact_id str | None

Fact identifier. If None, all passages are returned.

None
**kwargs Any

Additional filtering options.

{}

Returns:

Type Description
list[dict[str, Any]]

List of source passage dicts.

cqs(signal)

Detect Context Quality Signals (CQS) in signal.

Parameters:

Name Type Description Default
signal str

Text to scan for context hunger signals.

required

Returns:

Type Description
dict[str, Any]

Dict describing detected signals and recommended action.

cross_window_validate(windows, **kwargs)

Run cross-window consistency validation.

Parameters:

Name Type Description Default
windows list[str]

List of window output strings.

required
**kwargs Any

Additional options forwarded to the validator.

{}

Returns:

Type Description
dict[str, Any]

Dict with issues and severity counts.

Meta-Learning Engine

crp.advanced.meta_learning.MetaLearningEngine

ORC + ICML + RTL meta-learning capabilities.

Parameters:

Name Type Description Default
dispatch_fn Callable[[str, str], tuple[str, Any]] | None

Callable accepting (prompt, context) and returning (output, metadata). Used to execute reasoning steps and probe the model. May be None for offline planning.

None
model_capability int

Integer capability level of the active model.

1
config MetaLearningConfig | None

MetaLearningConfig overrides; defaults are used if None.

None

trace_count property

Return the number of traces currently stored in the RTL.

should_use_orc(task_complexity=3, resource_pressure='NONE', probe_quality=0.0)

Gate check for ORC activation.

Gate 1: resource_pressure >= HIGH → False Gate 2: model_capability >= task_complexity → False Gate 3: probe_quality >= 0.7 → False (ORC unnecessary)

Parameters:

Name Type Description Default
task_complexity int

Estimated complexity of the task on a 1–5 scale.

3
resource_pressure str

Resource pressure label ("NONE", "LOW", "MODERATE", "HIGH", "CRITICAL").

'NONE'
probe_quality float

Quality score from a zero-shot probe; high values indicate ORC is unnecessary.

0.0

Returns:

Type Description
bool

True when ORC should be used to break the task into steps.

orchestrated_reasoning(task_intent, task_complexity=3, resource_pressure='NONE')

Decompose and execute an orchestrated reasoning chain.

Parameters:

Name Type Description Default
task_intent str

Natural-language description of the task to solve.

required
task_complexity int

Estimated complexity of the task.

3
resource_pressure str

Resource pressure label; reduces the number of allowed steps under higher pressure.

'NONE'

Returns:

Type Description
ORCResult

An ORCResult containing step outputs and the synthesised final

ORCResult

answer.

build_reasoning_scaffold(task_intent)

Build a reasoning scaffold adapted to model capability.

Capability ≤ 1 (0.5B-1B): Full step-by-step template Capability ≤ 2 (2B-7B): Light approach Capability > 2: No scaffolding

Parameters:

Name Type Description Default
task_intent str

Task description to scaffold.

required

Returns:

Type Description
str

Scaffold string to prepend to the prompt, or an empty string when

str

scaffolding is disabled.

build_metacognitive_envelope(task_intent, base_envelope='', few_shot_traces=None)

Build an envelope with reasoning scaffold + few-shot examples.

Parameters:

Name Type Description Default
task_intent str

Task description.

required
base_envelope str

Existing envelope text to preserve, if any.

''
few_shot_traces list[ReasoningTrace] | None

Optional explicit traces to include as examples. When omitted, the RTL is queried for matching traces.

None

Returns:

Type Description
str

Combined envelope string containing the base envelope, scaffold,

str

and any few-shot examples.

store_trace(trace)

Store a reasoning trace if quality meets the configured threshold.

Parameters:

Name Type Description Default
trace ReasoningTrace

ReasoningTrace to store.

required

Returns:

Type Description
bool

True when the trace was stored, False when RTL is disabled or the

bool

trace quality is too low.

to_dict()

Serialize the engine and its trace library.

Returns:

Type Description
dict[str, Any]

Dictionary with the trace library and active configuration.