pub trait Agent:
Send
+ Sync
+ 'static {
// Required method
fn run(
&self,
pid: String,
nid: String,
inputs: Inputs,
log: LogSender,
) -> impl Future<Output = AgentOutput> + Send;
// Provided method
fn shutdown(&self) -> impl Future<Output = ()> + Send { ... }
}Expand description
Trait for implementing an Actflow agent.
Implement this trait to create your own agent that can be executed by the Actflow workflow engine.
§Example
ⓘ
use actflow_agent_sdk::{Agent, AgentOutput, Inputs, LogSender};
struct MyAgent;
impl Agent for MyAgent {
async fn run(
&self,
pid: String,
nid: String,
inputs: Inputs,
log: LogSender,
) -> AgentOutput {
log.send("Processing...").await;
AgentOutput::success(serde_json::json!({"result": "done"}))
}
}Required Methods§
Provided Methods§
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.