pub struct SessionPipeline { /* private fields */ }Expand description
Per-session pipeline handle. Cloneable; holds an Arc to the inner
LayeredPipeline plus Paper 3 enricher state (recent-tools window,
effectiveness counters, fail-fast circuit).
Implementations§
Source§impl SessionPipeline
impl SessionPipeline
Sourcepub fn new(config: AdaptiveConfig) -> Self
pub fn new(config: AdaptiveConfig) -> Self
Create a new pipeline for the current MCP server process. The
session id is derived from the process id so multiple concurrent
devboy mcp instances do not collide in shared telemetry.
When config.telemetry.enabled is true, a JsonlSink is
opened at <config.telemetry.path | ~/.devboy/telemetry>/<session>.jsonl
and attached to the pipeline. Failures to open the sink (missing
permissions, etc.) are logged at WARN level and degrade to a
no-op telemetry — they never fail the server start-up.
Sourcepub async fn with_speculation(
self,
dispatcher: Arc<dyn PrefetchDispatcher>,
) -> Self
pub async fn with_speculation( self, dispatcher: Arc<dyn PrefetchDispatcher>, ) -> Self
Attach a speculative-execution dispatcher. The host calls this
once at startup with a PrefetchDispatcher that bridges to
its own tools/call path. After this, Self::speculate_after
schedules out-of-band prefetches when the planner finds high-
probability follow-ups.
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Best-effort drop hook: on session close, abort every still-
pending speculative task. The async-aware version of Drop
(Rust’s sync Drop only sends an abort signal; this method
also drains the JoinSet so the runtime sees the cancellation
before we return).
Sourcepub fn enrichment_snapshot(&self) -> EnrichmentEffectiveness
pub fn enrichment_snapshot(&self) -> EnrichmentEffectiveness
Snapshot of the Paper 3 enrichment counters so far in this
session. Cheap (clone of EnrichmentEffectiveness); intended
for tools/list debug output, end-of-session summary, or live
status reporting.
Sourcepub fn recent_tools_snapshot(&self) -> Vec<String>
pub fn recent_tools_snapshot(&self) -> Vec<String>
Snapshot of recent tool names (oldest first). Used by the host
when it builds a TurnContext for EnrichmentPlanner::build_plan.
Sourcepub fn should_skip(&self, tool_name: &str) -> bool
pub fn should_skip(&self, tool_name: &str) -> bool
Returns true when the planner’s fail-fast circuit is armed for
tool_name — the host should refuse to dispatch the call and
emit a short hint instead. Armed iff:
[tools.<tool_name>].fail_fast_after_n = Some(n), and- the last
nconsecutive responses for that tool were “empty” (≤FAIL_FAST_EMPTY_THRESHOLD_BYTES).
EnrichmentEffectiveness is not updated here — the host is
expected to call Self::record_fail_fast_skip once it has
actually skipped the dispatch, so the saved-call counters stay
honest if the host opts to override the recommendation.
Sourcepub fn record_fail_fast_skip(&self, predicted_cost_tokens: u32)
pub fn record_fail_fast_skip(&self, predicted_cost_tokens: u32)
Notify the aggregator that the host actually short-circuited a
call this turn (the host saw should_skip return true and
honoured it). predicted_cost_tokens should come from the
tool’s cost_model.typical_kb so the saved-token count stays
proportional to the call we avoided.
Sourcepub async fn speculate_after(
&self,
tool_name: &str,
prev_response_json: &Value,
) -> String
pub async fn speculate_after( &self, tool_name: &str, prev_response_json: &Value, ) -> String
Run the Paper 3 planner against the response that just landed
for tool_name, dispatch every safe (Pure / ReadOnly)
follow-up out-of-band, and wait up to
enrichment.prefetch_timeout_ms for them to complete.
Settled prefetches land in the dedup cache so the LLM’s next
tools/call for the same tool_name+args collapses to an L0
hit. Tasks still pending past the timeout keep running and
land later on the same session — never blocking the main
response path.
Returns a short hint string the host can append to the LLM’s response so the model knows what context arrived early. Empty when the planner had nothing to schedule (or speculation is disabled).
Speculation is disabled when:
config.enrichment.enabled = false(default), or- no
PrefetchDispatcherhas been attached viaSelf::with_speculation.
In both cases this method is a cheap no-op and returns "".
Source§impl SessionPipeline
impl SessionPipeline
Sourcepub fn on_compaction_boundary(&self)
pub fn on_compaction_boundary(&self)
Notify the pipeline that the host compacted its context. Drops dedup entries from prior partitions on the next eviction sweep.
Sourcepub fn invalidate_file(&self, file_path: &str)
pub fn invalidate_file(&self, file_path: &str)
Invalidate all cache entries pointing at file_path. Called by
the server before a mutating tool (Edit/Write/…) is
dispatched so that a subsequent Read of the same file does
not return a stale > [ref: …] hint.
Sourcepub fn process(
&self,
request_id: &str,
params: &ToolCallParams,
result: ToolCallResult,
ts_ms: i64,
) -> ToolCallResult
pub fn process( &self, request_id: &str, params: &ToolCallParams, result: ToolCallResult, ts_ms: i64, ) -> ToolCallResult
Process a single tool-call response through L0 dedup. When the
L0 layer emits a reference hint (> [ref: tc_42, byte-identical]
or its terse / verbose variant), the input ToolCallResult is
rewritten to carry the hint instead of the original body. Other
layer outcomes pass the original result through unchanged —
L1/L2 encoders for typed-domain responses live in Pipeline.
Trait Implementations§
Source§impl Clone for SessionPipeline
impl Clone for SessionPipeline
Source§fn clone(&self) -> SessionPipeline
fn clone(&self) -> SessionPipeline
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more