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
impl ConstrainedProfile
Sourcepub fn session_config() -> SessionConfig
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.
Sourcepub fn run_config() -> RunConfig
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.
Sourcepub fn pipeline_builder() -> ToolPipelineBuilder
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.
Sourcepub fn request_options() -> RequestOptions
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.
Sourcepub fn apply<C: ApiClient>(loop_: &mut BareLoop<C>) -> Result<(), LoopError>
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();