Core Concepts
Actions
Building blocks of SpinAI agents
What are Actions?
Actions are discrete tasks that your AI agent can perform. They are:
- Type-safe and predictable
- State-aware through context
- Dependency-aware
- Reusable across agents
Creating Actions
Use the createAction
helper to define actions:
Action Configuration
Context and State
Actions receive and modify state through context:
Example using context:
Dependencies
Actions can depend on other actions:
SpinAI automatically:
- Resolves dependency order
- Ensures prerequisites run first
- Prevents circular dependencies
- Handles parallel execution when possible
Best Practices
-
Single Responsibility Each action should do one thing well:
-
Clear Descriptions Help the LLM understand when to use your action:
-
State Management Use clear state keys and types:
-
Error Handling Use the retry system for unreliable operations: