pub enum ContextPolicy {
Car,
SelfManaged,
}Expand description
Who owns the agent’s conversation context across a multi-turn run.
The daemon already bounds the assistant and coder loops to the model’s context window; a declarative agent had no such bound and no way to ask for one. This is that switch, per agent, named for who does the work rather than for a mechanism the spec author cannot see.
Deserialization is deliberately TOLERANT (see the hand-written impl below):
an unrecognized value warns and falls back to ContextPolicy::Car rather
than failing the parse. A strict impl would be a foot-gun here — the
authoring guide teaches hand-editing declagents.json, and DeclRegistry
treats an unparseable file as an empty registry that the next upsert
writes back, so one mistyped policy would delete every agent on the box.
Variants§
Car
CAR manages it: before each model call the running history is compacted
to fit the model’s context window, exactly as the assistant and coder
loops do (oldest middle turns dropped on a turn boundary, the system
prompt and the original task pinned, a [history compacted: notice left
behind). The default, so an agent that never thinks about context still
gets a bounded one.
SelfManaged
The agent author manages it. CAR never compacts this agent’s history — the spec owns whatever summarizing, truncation or externalization it wants. Choose it deliberately: nothing else bounds the transcript.
Implementations§
Source§impl ContextPolicy
impl ContextPolicy
Sourcepub fn is_car_managed(self) -> bool
pub fn is_car_managed(self) -> bool
Whether CAR compacts this agent’s history.
Exhaustive on purpose (repo rule): a matches! here would make every
future variant silently self-managed — i.e. would turn “we added a
policy” into “we switched compaction off for it”, which is the failure
mode with no symptom until a run overflows.
Trait Implementations§
Source§impl Clone for ContextPolicy
impl Clone for ContextPolicy
Source§fn clone(&self) -> ContextPolicy
fn clone(&self) -> ContextPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ContextPolicy
Source§impl Debug for ContextPolicy
impl Debug for ContextPolicy
Source§impl Default for ContextPolicy
impl Default for ContextPolicy
Source§fn default() -> ContextPolicy
fn default() -> ContextPolicy
Source§impl<'de> Deserialize<'de> for ContextPolicy
impl<'de> Deserialize<'de> for ContextPolicy
Source§fn deserialize<D>(
deserializer: D,
) -> Result<ContextPolicy, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ContextPolicy, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Accepts "car" and "self"; ANYTHING else warns and yields Car.
The strict derive returned unknown variant, and one bad character in a
hand-edited declagents.json then travelled the whole swallow chain —
DeclRegistry::read_all maps a parse error to an empty registry, and
the next upsert persists that emptiness — so a typo in an optional
field could unregister every agent the user had. A field whose only two
values both mean “keep running” must never be able to do that. The
fallback is the managed default, which is also the safe one: the worst
outcome of guessing wrong is a bounded history for an author who wanted
to bound it themselves, and the warning says so.
The spec id is not reachable from here (serde hands this impl only the
field’s own value), so the warning names the value; the surrounding
spec is one declagents.json grep away.
impl Eq for ContextPolicy
Source§impl PartialEq for ContextPolicy
impl PartialEq for ContextPolicy
Source§impl Serialize for ContextPolicy
impl Serialize for ContextPolicy
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ContextPolicy
Auto Trait Implementations§
impl Freeze for ContextPolicy
impl RefUnwindSafe for ContextPolicy
impl Send for ContextPolicy
impl Sync for ContextPolicy
impl Unpin for ContextPolicy
impl UnsafeUnpin for ContextPolicy
impl UnwindSafe for ContextPolicy
Blanket Implementations§
impl<T> Boilerplate for T
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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 more