Skip to main content

ConstrainedProfile

Struct ConstrainedProfile 

Source
pub struct ConstrainedProfile;
Expand description

The small-model-tuned runtime profile.

Bundles context-budget machinery (a context manager that compacts the conversation at the session’s configured threshold), a smaller window and fewer turns via session_config / run_config, verify-on-write (VerifyMiddleware with NoopVerifier), tool-call memoization (MemoizingMiddleware with NoopPathExtractor), output truncation (OutputLimitMiddleware), goal re-injection (GoalReminder), and strict tool-call decoding (ToolConstraint::Strict) into one coherent profile.

This is the harder-problem profile: it assumes the model drifts off-goal, repeats tool calls, ships broken edits, and emits malformed tool arguments, and installs machinery that catches each. Frontier models tolerate the same defaults fine; use FrontierProfile to opt out.

The no-op verifier and path extractor are wired by default so the profile is functional out of the box — but no actual verification or path-based cache invalidation happens until you swap in real impls. The verify middleware still registers and the cache still works by TTL; replacing NoopVerifier with cargo check / tsc and NoopPathExtractor with a path-aware extractor is the intended upgrade path.

Implementations§

Source§

impl ConstrainedProfile

Source

pub fn session_config() -> SessionConfig

A SessionConfig tuned for a small model.

Sets a smaller context window than the default — small models degrade faster as context fills, so the window is tightened. Compaction threshold is unchanged (tightness comes from the window, not from compacting earlier).

Value: context_window = 32_768.

Source

pub fn run_config() -> RunConfig

A RunConfig tuned for a small model.

Fewer max turns than the default, since small models are more prone to non-converging tool loops. All other run-scoped knobs stay at their defaults.

Value: max_turns = 100.

Source

pub fn pipeline_builder() -> ToolPipelineBuilder

A ToolPipeline builder pre-loaded with the small-model middleware stack.

Middleware registration order (first-registered outermost): output-limit → verify → memoize. Memoize (innermost) caches the raw tool result before verify appends its diagnostics — the cache never holds a verify block, and every successful write-class call is verified anew — while the output cap (outermost, post-processing last) truncates the combined output, so verify-appended diagnostics cannot escape the cap.

No .with_core() is set — pass the result to BareLoop::set_pipeline, which attaches the tool registry. Middleware a host chains onto this builder registers inside the preset’s memoize layer — for anything that must see the original call (a redaction scrub, say) that is the wrong slot: chain it on the pipeline after the preset’s layers instead.

Source

pub fn request_options() -> RequestOptions

RequestOptions requesting strict tool-call decoding.

Apply via BareLoop::set_request_options so the constraint reaches the provider on every turn.

Source

pub fn apply<C: ApiClient>(loop_: &mut BareLoop<C>) -> Result<(), LoopError>

Apply the profile’s compaction machinery, pipeline, and goal-reminder contributor to a BareLoop.

Installs a ContextManager around a TruncatingCompactor with its window and threshold synced from the loop’s session config, replacing whatever the constructor seeded, so the profile’s context budgeting is enforced by machinery rather than left to the caller. Also sets the small-model middleware stack (via Self::pipeline_builder) and registers a GoalReminder firing every 5 turns. Does not set the loop’s config or request options — those are set separately at construction (BareLoop::new) and via BareLoop::set_request_options.

§Errors

Returns LoopError if BareLoop::set_pipeline fails.

§Example
use loopctl::engine::BareLoop;
use loopctl::presets::ConstrainedProfile;
use loopctl::tool::ToolRegistry;
use std::sync::Arc;

// `client` is any ApiClient impl.
let mut agent = BareLoop::new(Arc::new(client), ToolRegistry::new(), ConstrainedProfile::session_config());
ConstrainedProfile::apply(&mut agent).unwrap();

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more