pub struct ContextEvent {
pub step: u32,
pub kind: String,
pub detail: Option<String>,
pub est_tokens: Option<u64>,
pub reported_tokens: Option<u64>,
}Expand description
One decision the context assembler made: the section it built for a turn, or a stale read it re-read (or was refused).
One row per turn plus one per re-read — never one per elided observation,
which would put a row explosion in the trace to say nothing new. Together
they answer “why did the model not see the thing it read at step 3”, and
est_tokens beside reported_tokens is what records the estimator’s drift
from the provider’s own count (see crate::context::estimate_tokens).
use io_harness::{ContextEvent, Store};
let events = store.context_events(run_id)?;
// Why the model did not see something it read earlier: five observations were
// stubbed to fit the budget, and one stale read could not be refreshed at all
// because the policy now refuses that path.
let refused: Vec<&str> = events
.iter()
.filter(|e| e.kind == "reread_refused")
.filter_map(|e| e.detail.as_deref())
.collect();
assert_eq!(refused, ["secrets/id_rsa: denied by policy"]);
// And the pair that makes the budget trustworthy: what the assembler
// estimated, beside what the provider actually charged for the same turn.
// Drift here is the estimator being wrong, not the budget being generous.
let assembled = events.iter().find(|e| e.kind == "assembled").expect("one per turn");
assert_eq!((assembled.est_tokens, assembled.reported_tokens), (Some(4_100), Some(4_690)));Fields§
§step: u32The step it belongs to.
kind: String"assembled", "reread", or "reread_refused".
detail: Option<String>For "assembled", the turn’s summary (carried=3 stubbed=5 reread=1);
for a re-read, the path and why it was or was not re-read.
est_tokens: Option<u64>The assembler’s own estimate for the section it built.
reported_tokens: Option<u64>What the provider said the request actually cost, when it says anything.
Implementations§
Source§impl ContextEvent
impl ContextEvent
Sourcepub fn assembled(step: u32, detail: impl Into<String>, est_tokens: u64) -> Self
pub fn assembled(step: u32, detail: impl Into<String>, est_tokens: u64) -> Self
The section built for one turn.
Sourcepub fn reread(step: u32, detail: impl Into<String>) -> Self
pub fn reread(step: u32, detail: impl Into<String>) -> Self
A stale read was re-read at assembly time.
Sourcepub fn reread_refused(step: u32, detail: impl Into<String>) -> Self
pub fn reread_refused(step: u32, detail: impl Into<String>) -> Self
A stale read could not be re-read — the policy refused it, or it is gone.
Sourcepub fn memory_write(step: u32, detail: impl Into<String>) -> Self
pub fn memory_write(step: u32, detail: impl Into<String>) -> Self
The agent recorded a durable note for later runs over this workspace.
Sourcepub fn memory_evict(step: u32, detail: impl Into<String>) -> Self
pub fn memory_evict(step: u32, detail: impl Into<String>) -> Self
A note was dropped to hold the workspace’s memory caps.
Sourcepub fn memory_recall(step: u32, detail: impl Into<String>) -> Self
pub fn memory_recall(step: u32, detail: impl Into<String>) -> Self
Notes from earlier runs were carried into this turn’s context.
Sourcepub fn served(step: u32, provider: impl Into<String>) -> Self
pub fn served(step: u32, provider: impl Into<String>) -> Self
Which provider actually answered this step.
Recorded only when the answer is not obvious from configuration — a
Fallback that fell over. runs.provider is one
label for a whole run and stops being true the moment a run can use two.
Sourcepub fn replan(step: u32, detail: impl Into<String>) -> Self
pub fn replan(step: u32, detail: impl Into<String>) -> Self
The agent made no progress and was told once to change approach. The run continues.
Split from Self::stalled in 0.12.0. Both were recorded under the one
"stalled" kind, distinguishable only by prose in detail — so anything
scoring a run could not tell “was nudged and carried on” from “gave up”
without string-matching an English sentence the crate never promised.
Trait Implementations§
Source§impl Clone for ContextEvent
impl Clone for ContextEvent
Source§fn clone(&self) -> ContextEvent
fn clone(&self) -> ContextEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContextEvent
impl Debug for ContextEvent
impl Eq for ContextEvent
Source§impl PartialEq for ContextEvent
impl PartialEq for ContextEvent
impl StructuralPartialEq for ContextEvent
Auto Trait Implementations§
impl Freeze for ContextEvent
impl RefUnwindSafe for ContextEvent
impl Send for ContextEvent
impl Sync for ContextEvent
impl Unpin for ContextEvent
impl UnsafeUnpin for ContextEvent
impl UnwindSafe for ContextEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.