This guide helps you resolve common issues when working with the NEAR Swarm Intelligence framework.
Problem: Error about Python version compatibility.
Solution:
- Check your Python version:
python --version
- Install Python 3.12+:
# macOS
brew install [email protected]
# Ubuntu
sudo apt update
sudo apt install python3.12
Problem: Missing dependencies or version conflicts.
Solution:
- Update pip:
python -m pip install --upgrade pip
- Install in development mode:
pip install -e .
Problem: "Plugin not found" or loading errors.
Solution:
- Check plugin structure:
my-agent/
├── __init__.py
├── agent.yaml # Must exist
├── plugin.py # Must exist
└── README.md
- Verify plugin is installed:
near-swarm plugins list
- Try reinstalling:
near-swarm plugins remove my-agent
near-swarm plugins install ./my-agent
Problem: Invalid plugin configuration.
Solution:
- Validate configuration:
near-swarm config validate
- Check YAML syntax:
# agent.yaml
name: my-agent
description: "Agent description"
version: "0.1.0"
author: "Your Name"
capabilities:
- capability_one
- capability_two
llm:
provider: ${LLM_PROVIDER}
model: ${LLM_MODEL}
temperature: 0.7
near:
network: ${NEAR_NETWORK:-testnet}
account_id: ${NEAR_ACCOUNT_ID}
private_key: ${NEAR_PRIVATE_KEY}
- Debug configuration loading:
near-swarm config show --debug
Problem: Plugin initialization or cleanup failures.
Solution:
- Implement proper lifecycle methods:
class MyPlugin(AgentPlugin):
async def initialize(self) -> None:
try:
# Initialize resources
self.llm = self.create_llm_provider(self.config.llm)
self.near = await self.create_near_connection(self.config.near)
except Exception as e:
self.logger.error(f"Initialization failed: {e}")
raise PluginError(str(e))
async def cleanup(self) -> None:
try:
# Clean up resources
await self.near.close()
except Exception as e:
self.logger.error(f"Cleanup failed: {e}")
- Enable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)
Problem: "Environment variable not set" errors.
Solution:
- Check
.env
file exists:
ls -la .env
- Verify required variables:
# Required: NEAR account details
NEAR_NETWORK=testnet
NEAR_ACCOUNT_ID=your-account.testnet
NEAR_PRIVATE_KEY=your-private-key
# Required: AI provider details
LLM_PROVIDER=hyperbolic
LLM_API_KEY=your-llm-api-key
# Optional: AI model settings
LLM_MODEL=deepseek-ai/DeepSeek-V3
- Load variables:
source .env
Problem: Configuration validation errors.
Solution:
- Use configuration models:
from pydantic import BaseModel, Field
class MyConfig(BaseModel):
name: str
version: str = Field(pattern=r"^\d+\.\d+\.\d+$")
temperature: float = Field(ge=0, le=1)
- Validate during loading:
from near_swarm.config import ConfigurationManager
config_manager = ConfigurationManager()
try:
config = config_manager.load_config("my-agent", MyConfig)
except ConfigError as e:
print(f"Configuration error: {e}")
Problem: LLM API errors or unexpected responses.
Solution:
- Verify API key:
from near_swarm.llm import LLMProvider
provider = LLMProvider(config.llm)
try:
await provider.validate_connection()
except LLMError as e:
print(f"LLM error: {e}")
- Handle API errors:
async def safe_llm_call(self, prompt: str) -> Dict[str, Any]:
try:
return await self.llm.query(prompt)
except LLMError as e:
self.logger.error(f"LLM call failed: {e}")
return {"error": str(e)}
Problem: NEAR blockchain interaction errors.
Solution:
- Test connection:
from near_swarm.near import NEARConnection
near = NEARConnection(config.near)
try:
await near.validate_connection()
except NEARError as e:
print(f"NEAR error: {e}")
- Handle transaction errors:
async def safe_transfer(self, recipient: str, amount: str) -> Dict[str, Any]:
try:
return await self.near.send_tokens(recipient, amount)
except NEARError as e:
self.logger.error(f"Transfer failed: {e}")
return {"error": str(e)}
- Issue:
Transaction failed: nonce too low
- Cause: Multiple transactions sent in rapid succession
- Solution: The framework automatically handles retries with exponential backoff
- Verification: Check transaction status in explorer URL provided in logs
- Issue: Agent analyzes but doesn't execute transactions
- Cause: Confidence threshold not met (requires >75%)
- Solution: This is normal behavior. The agent is being conservative
- Verification: Check confidence level in logs
- Issue: Unclear if transaction was successful
- Solution: Check the logs for:
✅ Transaction Successfully Executed! • Transaction Hash: <hash> • Explorer URL: <url>
- Verification: Visit the explorer URL to confirm status
- Solution: Check the logs for:
Error | Cause | Solution |
---|---|---|
nonce too low |
Transaction ordering issue | Automatic retry handles this |
insufficient funds |
Account balance too low | Add funds to account |
gas price too low |
Network congestion | Automatic retry with backoff |
Solution:
- Check directory structure:
ls -R my-agent/
- Create plugin with CLI:
near-swarm create agent my-agent
Solution:
- Validate YAML syntax
- Check variable substitution
- Run validation:
near-swarm config validate my-agent
Solution:
- Check resource initialization
- Verify dependencies
- Enable debug mode:
near-swarm start my-agent --debug
-
Check documentation:
-
Search issues:
-
Join community:
-
Debug tools:
# Enable debug logging
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)