mofa agent command provides comprehensive agent lifecycle management including starting, stopping, restarting, and monitoring agents.
Subcommands
start
Start an agent
stop
Stop a running agent
restart
Restart an agent
status
Show agent status
list
List all agents
logs
View agent logs
create
Create agent interactively
mofa agent start
Start an agent and register it in the runtime.Usage
Arguments
<AGENT_ID>
Required. Unique identifier for the agent.
Options
-c, --config <PATH>
Path to agent configuration file.
- Type: Path
- Default: Auto-discovered (looks for
agent.yml,agent.yaml, etc.)
--type <FACTORY_TYPE>
Agent factory type to use for creation.
- Type: String
- Default: First available factory
mofa agent status to see available factory types.
--daemon
Run agent as a background daemon.
- Type: Boolean flag
- Default:
false
Examples
Start with default configuration
Start with specific config
Start as daemon
Error Codes
| Code | Description |
|---|---|
0 | Agent started successfully |
1 | Agent already running |
2 | Configuration not found or invalid |
3 | No factory available |
4 | Factory type not found |
mofa agent stop
Stop a running agent gracefully.Usage
Arguments
<AGENT_ID>
Required. ID of the agent to stop.
Options
--force-persisted-stop
Update persisted state even when runtime registry is unavailable.
- Type: Boolean flag
- Default:
false
Examples
Normal stop
Force persisted stop
Graceful Shutdown
The stop command:- Attempts graceful shutdown via agent instance
- Updates persisted state to “Stopped”
- Unregisters agent from runtime registry
- Rolls back on failure
Error Codes
| Code | Description |
|---|---|
0 | Agent stopped successfully |
1 | Agent not found |
2 | Agent not running |
3 | Failed to unregister |
mofa agent restart
Restart an agent (stop and start).Usage
Arguments
<AGENT_ID>
Required. ID of the agent to restart.
Options
-c, --config <PATH>
Path to agent configuration file.
- Type: Path
- Default: Auto-discovered or previously used config
Examples
mofa agent status
Show detailed status information for agents.Usage
Arguments
[AGENT_ID]
Optional. Specific agent ID. If omitted, shows all agents.
Examples
Show specific agent status
Show all agents
mofa agent list
List all registered agents with their status.Usage
Options
--running
Show only running agents.
- Type: Boolean flag
- Default:
false
--all
Show all agents including stopped ones.
- Type: Boolean flag
- Default:
true
Examples
List all agents
List only running agents
JSON output
mofa agent logs
View and tail agent logs.Usage
Arguments
<AGENT_ID>
Required. ID of the agent to view logs for.
Options
-t, --tail
Tail the logs (follow in real-time).
- Type: Boolean flag
- Default:
false
--level <LEVEL>
Filter by log level.
- Type: String
- Values:
INFO,DEBUG,ERROR,WARN - Default: Show all levels
--grep <PATTERN>
Search for text pattern in logs.
- Type: String
- Default: None
--limit <N>
Limit number of lines to display.
- Type: Integer
- Default: All lines
--json
Output logs as JSON.
- Type: Boolean flag
- Default:
false
Examples
View recent logs
Tail logs in real-time
Filter by error level
Search logs
Limit output
JSON format
mofa agent create
Interactive wizard to create a new agent configuration.Usage
Options
--non-interactive
Run in non-interactive mode with defaults.
- Type: Boolean flag
- Default:
false
-c, --config <PATH>
Output configuration file path.
- Type: Path
- Default:
./agent.yml
Examples
Interactive creation
Common Workflows
Start and monitor agent
Restart with new configuration
Troubleshooting
Agent States
Agents can be in the following states:| State | Description |
|---|---|
Running | Agent is active and processing requests |
Ready | Agent is initialized and ready |
Stopped | Agent has been stopped |
Initializing | Agent is starting up |
Executing | Agent is processing a task |
Paused | Agent is temporarily paused |
Error | Agent encountered an error |
See Also
- Configuration - Manage configuration
- Sessions - View agent sessions
- Plugins - Install plugins
- Logs - View detailed logs