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§
Sourcetype Msg: AgentMessage
type Msg: AgentMessage
The message type (implements AgentMessage).
Required Methods§
Sourcefn decide(
&self,
messages: &[Self::Msg],
) -> impl Future<Output = Result<StepDecision<Self::Action>, Self::Error>> + Send
fn decide( &self, messages: &[Self::Msg], ) -> impl Future<Output = Result<StepDecision<Self::Action>, Self::Error>> + Send
Call LLM to decide next actions.
Sourcefn execute(
&self,
action: &Self::Action,
) -> impl Future<Output = Result<ActionResult, Self::Error>> + Send
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.
Sourcefn action_signature(action: &Self::Action) -> String
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.