Skip to main content

SgrAgent

Trait SgrAgent 

Source
pub trait SgrAgent {
    type Action;
    type Msg: AgentMessage;
    type Error: Display;

    // Required methods
    fn decide(
        &self,
        messages: &[Self::Msg],
    ) -> impl Future<Output = Result<StepDecision<Self::Action>, Self::Error>> + Send;
    fn execute(
        &self,
        action: &Self::Action,
    ) -> impl Future<Output = Result<ActionResult, Self::Error>> + Send;
    fn action_signature(action: &Self::Action) -> String;
}
Expand description

Base SGR Agent trait — implement per project.

Covers the non-streaming case (va-agent, simple CLIs). For streaming, implement SgrAgentStream on top.

§Stateful executors

If execute needs mutable state (e.g. MCP connections), use interior mutability (Mutex, RwLock). The trait takes &self to allow concurrent action execution in the future.

Required Associated Types§

Source

type Action

The action union type (BAML-generated, project-specific).

Source

type Msg: AgentMessage

The message type (implements AgentMessage).

Source

type Error: Display

Error type.

Required Methods§

Source

fn decide( &self, messages: &[Self::Msg], ) -> impl Future<Output = Result<StepDecision<Self::Action>, Self::Error>> + Send

Call LLM to decide next actions.

Source

fn execute( &self, action: &Self::Action, ) -> impl Future<Output = Result<ActionResult, Self::Error>> + Send

Execute a single action. Returns tool output + done flag. Does NOT push to session — the loop handles that.

Source

fn action_signature(action: &Self::Action) -> String

String signature for loop detection.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§