Overview
This basic example demonstrates the simplest possible MoFA agent - an echo agent that receives input and produces output. It’s the perfect starting point for understanding the MoFA framework’s core concepts.What You’ll Learn
- Creating a basic agent using
MoFAAgenttrait - Implementing agent lifecycle methods (initialize, execute, shutdown)
- Using
AgentInputandAgentOutputtypes - Working with agent state management
Prerequisites
- Rust 1.75 or higher
- Basic understanding of async/await in Rust
Source Code
Running the Example
Expected Output
Key Concepts
MoFAAgent Trait
TheMoFAAgent trait is the core abstraction in MoFA. Every agent must implement:
id()- Unique identifier for the agentname()- Human-readable namecapabilities()- Tags and features the agent supportsinitialize()- Setup logic before executionexecute()- Main processing logicshutdown()- Cleanup logicstate()- Current agent state
Agent Lifecycle
AgentInput and AgentOutput
MoFA uses structured input/output types:- AgentInput::text() - Text input
- AgentInput::json() - Structured JSON data
- AgentOutput::text() - Text response
- AgentOutput::json() - Structured response
Next Steps
Chat Stream Example
Learn streaming chat interactions
ReAct Agent
Build reasoning + acting agents
Core Concepts
Deep dive into agent concepts
API Reference
Explore the full SDK