pub struct WorkingSet { /* private fields */ }Expand description
Manages the set of files currently in the agent’s context
Implementations§
Source§impl WorkingSet
impl WorkingSet
Sourcepub fn with_config(config: WorkingSetConfig) -> Self
pub fn with_config(config: WorkingSetConfig) -> Self
Create a new working set with the given configuration.
Sourcepub fn current_turn(&self) -> u32
pub fn current_turn(&self) -> u32
Returns the current turn number.
Sourcepub fn add(&mut self, path: PathBuf, tokens: usize) -> Option<String>
pub fn add(&mut self, path: PathBuf, tokens: usize) -> Option<String>
Add a file to the working set, evicting LRU entries if needed.
Sourcepub fn add_labeled(
&mut self,
path: PathBuf,
tokens: usize,
label: &str,
) -> Option<String>
pub fn add_labeled( &mut self, path: PathBuf, tokens: usize, label: &str, ) -> Option<String>
Add a file with a label, evicting LRU entries if needed.
Sourcepub fn add_pinned(&mut self, path: PathBuf, tokens: usize, label: Option<&str>)
pub fn add_pinned(&mut self, path: PathBuf, tokens: usize, label: Option<&str>)
Add a pinned file that is immune to eviction.
Sourcepub fn clear(&mut self, keep_pinned: bool)
pub fn clear(&mut self, keep_pinned: bool)
Clear the working set, optionally keeping pinned entries.
Sourcepub fn entries(&self) -> impl Iterator<Item = &WorkingSetEntry>
pub fn entries(&self) -> impl Iterator<Item = &WorkingSetEntry>
Iterate over all entries in the working set.
Sourcepub fn get(&self, path: &Path) -> Option<&WorkingSetEntry>
pub fn get(&self, path: &Path) -> Option<&WorkingSetEntry>
Get an entry by path.
Sourcepub fn total_tokens(&self) -> usize
pub fn total_tokens(&self) -> usize
Returns the total estimated token count across all entries.
Sourcepub fn last_eviction(&self) -> Option<&str>
pub fn last_eviction(&self) -> Option<&str>
Returns the last eviction message, if any.
Sourcepub fn file_paths(&self) -> Vec<&PathBuf>
pub fn file_paths(&self) -> Vec<&PathBuf>
Returns all file paths in the working set.
Sourcepub fn record_write(&mut self, path: &Path, hash: [u8; 32])
pub fn record_write(&mut self, path: &Path, hash: [u8; 32])
Record the SHA-256 of content a tool has just written to path.
If the entry is already present, its intended_hash is overwritten
(the most recent write wins) and last_access_turn is refreshed.
If the entry does not exist yet, a new one is inserted with zero
estimated tokens — the caller is expected to update token estimates
separately via add/add_labeled when loading file content.
Trait Implementations§
Source§impl Clone for WorkingSet
impl Clone for WorkingSet
Source§fn clone(&self) -> WorkingSet
fn clone(&self) -> WorkingSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more