| 88 | /// Trait that all agents must implement |
| 89 | #[async_trait] |
| 90 | pub trait AgentTrait: Send + Sync { |
| 91 | /// Get agent ID |
| 92 | fn id(&self) -> &AgentId; |
| 93 | |
| 94 | /// Get agent configuration |
| 95 | fn config(&self) -> &AgentConfig; |
| 96 | |
| 97 | /// Process a message and return a response |
| 98 | async fn process_message( |
| 99 | &self, |
| 100 | message: AgentMessage, |
| 101 | context: &mut WorkflowContext, |
| 102 | ) -> GraphBitResult<AgentMessage>; |
| 103 | |
| 104 | /// Execute a message and return structured data (for optimized workflow execution) |
| 105 | async fn execute(&self, message: AgentMessage) -> GraphBitResult<serde_json::Value>; |
| 106 | |
| 107 | /// Validate agent output against expected schema |
| 108 | async fn validate_output(&self, output: &str, schema: &serde_json::Value) -> ValidationResult; |
| 109 | |
| 110 | /// Check if agent has a specific capability |
| 111 | fn has_capability(&self, capability: &AgentCapability) -> bool { |
| 112 | self.config().capabilities.contains(capability) |
| 113 | } |
| 114 | |
| 115 | /// Get supported capabilities |
| 116 | fn capabilities(&self) -> &[AgentCapability] { |
| 117 | &self.config().capabilities |
| 118 | } |
| 119 | |
| 120 | /// Get access to the LLM provider for direct tool calling |
| 121 | fn llm_provider(&self) -> &LlmProvider; |
| 122 | } |
| 123 | |
| 124 | /// Standard LLM-based agent implementation |
| 125 | pub struct Agent { |
nothing calls this directly
no outgoing calls
no test coverage detected