pub struct DecisionContext {
pub agent_id: u32,
pub query: String,
pub phase: String,
pub tick: u64,
pub recent_results: Vec<ActionResult>,
pub state: AgentState,
pub active_files: Vec<String>,
pub remaining_work: Vec<String>,
pub metadata: HashMap<String, String>,
}Expand description
Context for making a decision
Contains all the information a Decider needs to choose the next action.
Fields§
§agent_id: u32The agent’s ID
query: StringThe original query/goal
phase: StringCurrent phase of execution
tick: u64Current tick number
recent_results: Vec<ActionResult>Recent action results (for learning from past)
state: AgentStateCurrent agent state
active_files: Vec<String>Files currently being worked on
remaining_work: Vec<String>Remaining work items
metadata: HashMap<String, String>Custom metadata
Implementations§
Source§impl DecisionContext
impl DecisionContext
Sourcepub fn with_phase(self, phase: impl Into<String>) -> Self
pub fn with_phase(self, phase: impl Into<String>) -> Self
Set the current phase
Sourcepub fn add_result(&mut self, result: ActionResult)
pub fn add_result(&mut self, result: ActionResult)
Add a recent result
Sourcepub fn with_active_files(self, files: Vec<String>) -> Self
pub fn with_active_files(self, files: Vec<String>) -> Self
Set active files
Sourcepub fn with_remaining_work(self, work: Vec<String>) -> Self
pub fn with_remaining_work(self, work: Vec<String>) -> Self
Set remaining work
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add metadata
Sourcepub fn last_result(&self) -> Option<&ActionResult>
pub fn last_result(&self) -> Option<&ActionResult>
Get the last result
Sourcepub fn last_succeeded(&self) -> bool
pub fn last_succeeded(&self) -> bool
Check if the last action succeeded
Sourcepub fn last_failed(&self) -> bool
pub fn last_failed(&self) -> bool
Check if the last action failed
Sourcepub fn recent_failure_count(&self) -> usize
pub fn recent_failure_count(&self) -> usize
Count recent failures
Sourcepub fn recent_success_rate(&self) -> f64
pub fn recent_success_rate(&self) -> f64
Calculate recent success rate
Sourcepub fn has_remaining_work(&self) -> bool
pub fn has_remaining_work(&self) -> bool
Check if there’s remaining work
Sourcepub fn next_work_item(&self) -> Option<&String>
pub fn next_work_item(&self) -> Option<&String>
Get the next work item
Sourcepub fn query_contains(&self, keyword: &str) -> bool
pub fn query_contains(&self, keyword: &str) -> bool
Check if query contains a keyword (case-insensitive)
Sourcepub fn query_contains_any(&self, keywords: &[&str]) -> bool
pub fn query_contains_any(&self, keywords: &[&str]) -> bool
Check if query contains any of the keywords
Trait Implementations§
Source§impl Clone for DecisionContext
impl Clone for DecisionContext
Source§fn clone(&self) -> DecisionContext
fn clone(&self) -> DecisionContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DecisionContext
impl Debug for DecisionContext
Source§impl Default for DecisionContext
impl Default for DecisionContext
Source§fn default() -> DecisionContext
fn default() -> DecisionContext
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for DecisionContext
impl<'de> Deserialize<'de> for DecisionContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for DecisionContext
impl RefUnwindSafe for DecisionContext
impl Send for DecisionContext
impl Sync for DecisionContext
impl Unpin for DecisionContext
impl UnsafeUnpin for DecisionContext
impl UnwindSafe for DecisionContext
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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