Skip to main content

InternalTool

Trait InternalTool 

Source
pub trait InternalTool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        state: &'life1 CognitiveState,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, PeError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A tool available only inside the cognitive graph.

Internal tools operate on CognitiveState for self-management: writing notes, recalling constraints, recording failures, etc. They are NOT exposed to the outer execution graph.

§Example

use pe_core::internal_tool::InternalTool;
use pe_core::cognitive::CognitiveState;
use pe_core::error::PeError;

struct MyTool;

#[async_trait::async_trait]
impl InternalTool for MyTool {
    fn name(&self) -> &str { "my_tool" }
    fn description(&self) -> &str { "A custom internal tool" }
    async fn execute(
        &self,
        _state: &CognitiveState,
        _args: serde_json::Value,
    ) -> Result<serde_json::Value, PeError> {
        Ok(serde_json::json!({"status": "ok"}))
    }
}

Required Methods§

Source

fn name(&self) -> &str

Unique tool name.

Source

fn description(&self) -> &str

Human-readable description for LLM tool-use prompts.

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, state: &'life1 CognitiveState, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, PeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the tool with the current cognitive state and arguments.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§