pub struct PawanAgent { /* private fields */ }Expand description
The main Pawan agent The main Pawan agent
This struct represents the core Pawan agent that handles:
- Conversation history management
- Tool calling with the LLM via pluggable backends
- Streaming responses
- Multiple LLM backends (NVIDIA API, Ollama, OpenAI)
- Context management and token counting
- Integration with Eruka for 3-tier memory injection
Implementations§
Source§impl PawanAgent
impl PawanAgent
Sourcepub async fn preflight_check(&self) -> Result<()>
pub async fn preflight_check(&self) -> Result<()>
Pre-flight health check: verify the LLM backend is reachable before starting work. Sends a minimal “ping” message. Returns Ok(()) if the model responds.
Source§impl PawanAgent
impl PawanAgent
Sourcepub fn new(config: PawanConfig, workspace_root: PathBuf) -> Self
pub fn new(config: PawanConfig, workspace_root: PathBuf) -> Self
Create a new PawanAgent with auto-selected backend
Sourcepub fn with_tools(self, tools: ToolRegistry) -> Self
pub fn with_tools(self, tools: ToolRegistry) -> Self
Create with a specific tool registry
Sourcepub fn tools_mut(&mut self) -> &mut ToolRegistry
pub fn tools_mut(&mut self) -> &mut ToolRegistry
Get mutable access to the tool registry (for registering MCP tools)
Sourcepub fn with_backend(self, backend: Box<dyn LlmBackend>) -> Self
pub fn with_backend(self, backend: Box<dyn LlmBackend>) -> Self
Create with a custom backend
Sourcepub fn save_session(&self) -> Result<String>
pub fn save_session(&self) -> Result<String>
Save current conversation as a session, returns session ID
Sourcepub fn resume_session(&mut self, session_id: &str) -> Result<()>
pub fn resume_session(&mut self, session_id: &str) -> Result<()>
Resume a saved session by ID
Sourcepub fn config(&self) -> &PawanConfig
pub fn config(&self) -> &PawanConfig
Get the configuration
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear the conversation history
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message to history
Sourcepub fn switch_model(&mut self, model: &str)
pub fn switch_model(&mut self, model: &str)
Switch the LLM model at runtime. Recreates the backend with the new model.
Sourcepub fn model_name(&self) -> &str
pub fn model_name(&self) -> &str
Get the current model name
Sourcepub fn get_tool_definitions(&self) -> Vec<ToolDefinition>
pub fn get_tool_definitions(&self) -> Vec<ToolDefinition>
Get tool definitions for the LLM
Sourcepub async fn execute(&mut self, user_prompt: &str) -> Result<AgentResponse>
pub async fn execute(&mut self, user_prompt: &str) -> Result<AgentResponse>
Execute a single prompt with tool calling support
Sourcepub async fn execute_with_callbacks(
&mut self,
user_prompt: &str,
on_token: Option<TokenCallback>,
on_tool: Option<ToolCallback>,
on_tool_start: Option<ToolStartCallback>,
) -> Result<AgentResponse>
pub async fn execute_with_callbacks( &mut self, user_prompt: &str, on_token: Option<TokenCallback>, on_tool: Option<ToolCallback>, on_tool_start: Option<ToolStartCallback>, ) -> Result<AgentResponse>
Execute with optional callbacks for streaming
Sourcepub async fn heal(&mut self) -> Result<AgentResponse>
pub async fn heal(&mut self) -> Result<AgentResponse>
Execute a healing task with real diagnostics
Sourcepub async fn heal_with_retries(
&mut self,
max_attempts: usize,
) -> Result<AgentResponse>
pub async fn heal_with_retries( &mut self, max_attempts: usize, ) -> Result<AgentResponse>
Execute healing with retries — calls heal(), checks for remaining errors, retries if needed
Sourcepub async fn task(&mut self, task_description: &str) -> Result<AgentResponse>
pub async fn task(&mut self, task_description: &str) -> Result<AgentResponse>
Execute a task with a specific prompt
Sourcepub async fn generate_commit_message(&mut self) -> Result<String>
pub async fn generate_commit_message(&mut self) -> Result<String>
Generate a commit message for current changes
Auto Trait Implementations§
impl !Freeze for PawanAgent
impl !RefUnwindSafe for PawanAgent
impl Send for PawanAgent
impl Sync for PawanAgent
impl Unpin for PawanAgent
impl UnsafeUnpin for PawanAgent
impl !UnwindSafe for PawanAgent
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
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