Context Agent • Rust AI Agent SDK
ContextAgent: Context agent for managing conversation context
ContextAgent
Defined in the specialized module.
Rust AI Agent SDK
Context agent for managing conversation context
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph LR
input["Input Data"] --> agent["Agent: ContextAgent"]
agent --> output["Output Result"]
style agent fill:#8B0000,color:#fff
style input fill:#8B0000,color:#fff
style output fill:#8B0000,color:#fffFields
| Name | Type | Description |
|---|---|---|
config | ContextAgentConfig | Configuration |
context | Vec<ContextEntry> | Context window |
max_entries | usize | Maximum entries |
Methods
new
fn new(config: ContextAgentConfig) -> SelfCreate a new context agent
Parameters:
| Name | Type |
|---|---|
config | ContextAgentConfig |
add
fn add(&mut self, role: impl Into<String>, content: impl Into<String>) -> ()Add an entry to context
Parameters:
| Name | Type |
|---|---|
role | impl Into<String> |
content | impl Into<String> |
get_context
fn get_context(&self) -> Vec<&ContextEntry>Get context as messages
clear
fn clear(&mut self) -> ()Clear context
len
fn len(&self) -> usizeGet context length
is_empty
fn is_empty(&self) -> boolCheck if context is empty
Source
View on GitHubpraisonai/src/parity/specialized.rs at line 46