pub trait SgrAgent {
type Action: Send + Sync;
type Msg: AgentMessage + Send + Sync;
type Error: Display + Send;
// 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;
// Provided method
fn action_category(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 + Send + Sync
type Msg: AgentMessage + Send + Sync
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 (exact match).
Provided Methods§
Sourcefn action_category(action: &Self::Action) -> String
fn action_category(action: &Self::Action) -> String
Coarse category for semantic loop detection.
Default: normalize the signature (strips bash flags, quotes, fallbacks). Override for project-specific normalization.
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.