GAME Sandbox to SDK Reference Guide
Table of Contents
Open Table of Contents
Introduction
This guide maps the visual configurations in the GAME Sandbox GUI to their corresponding Python SDK implementations. Use this as a reference when transitioning from the Sandbox to programmatic implementation.
Agent Configuration
Agent Profile
In the Sandbox:
- Navigate to “Agent Profile” in left sidebar
- Fill in “Agent Goal” text field
- Fill in “Agent Description” field
- Configure “Agent Knowledge”
- Upload relevant datasets
#### In the SDK:
```python
from virtuals_sdk import game
Create agent with same configurations as Sandbox
agent = game.Agent(
api_key=“your_api_key”,
goal=“Help others become better crypto investors by offering information regarding DeFi markets”,
description="""
You are Athena, an intelligent AI who believes that the core value
proposition of blockchain is to facilitate decentralized finance,
payments, tokenization, and AI agent collaboration
""",
world_info=“The world of DeFi and blockchain technology…”,
main_heartbeat=15, # Maps to Heartbeat settings in GUI
reaction_heartbeat=5
)
Configure agent knowledge (matches Dataset section in GUI)
agent.set_knowledge([
{
“type”: “dataset”,
“name”: “DeFi Protocols”,
“content”: “Information about various DeFi protocols…”
},
{
“type”: “market_data”,
“content”: “Historical market data…”
}
])
</code>
### Knowledge Configuration
#### In the Sandbox:
1. Click "Agent Knowledge"
2. Upload datasets using drag & drop
3. Configure dataset parameters
#### In the SDK:
```python
# Load and configure datasets
agent.load_datasets([
{
"path": "market_data.csv",
"name": "Historical Market Data",
"description": "Price and volume data",
"refresh_interval": 3600 # 1 hour
},
{
"path": "defi_protocols.json",
"name": "Protocol Information",
"description": "Protocol details",
"refresh_interval": 86400 # 24 hours
}
])
# Configure dataset processing (equivalent to GUI settings)
agent.configure_dataset_processing({
"auto_refresh": True,
"max_cache_size": 1000,
"preprocessing": {
"clean_data": True,
"remove_outliers": True,
"fill_missing_values": "interpolate"
}
})
Game Setup
Heartbeat Configuration
In the Sandbox:
- Navigate to “GAME Setup” > “Heartbeat”
- Set “General” to 15 minutes
- Set “Reply Tweets” to 5 minutes
In the SDK:
# Method 1: During initialization
agent = game.Agent(
api_key="your_api_key",
main_heartbeat=15,
reaction_heartbeat=5
)
# Method 2: After initialization
agent.set_main_heartbeat(15)
agent.set_reaction_heartbeat(5)
Worker Configuration
In the Sandbox:
- Click “Workers”
- Configure Reply Worker:
- Set task description
- Configure reply count limits
- Set environment variables
- Configure Main Worker:
- Set name as “Twitter Main Location”
- Define functionalities
- Configure environment
In the SDK:
# Reply Worker Configuration (matches GUI settings)
reply_worker = game.Worker(
name="Reply Worker",
description="""
Process incoming tweet. Ignore if it is boring or unimportant.
Total replies made: {{replyCount}}. Ignore if conversation too long.
""",
environment={
"reply_threshold": 0.7,
"max_replies": "{{replyCount}}",
"min_relevance_score": 0.5
}
)
# Main Worker Configuration
main_worker = game.Worker(
name="Twitter Main Location",
description="""
This location allows for:
1. Engagement and interaction
2. Content generation
3. Analytics and monitoring
""",
environment={
"allowed_actions": ["reply", "like", "retweet"],
"rate_limits": {
"tweets_per_hour": 10,
"replies_per_hour": 20
}
}
)
# Add workers to agent (same as clicking Save in GUI)
agent.add_worker(reply_worker)
agent.add_worker(main_worker)
Function Configuration
Custom Functions
In the Sandbox:
- Click “Configure Functions for Simulation”
- Click ”+ Add Custom Function”
- Configure:
- Function name
- Description
- Arguments
- API settings
In the SDK:
# Create DeFi APY function (matches GUI configuration)
defi_apy_function = game.Function(
fn_name="get_defi_apy",
fn_description="Get information on DeFi yields",
args=[
game.FunctionArgument(
name="chain",
type="string",
description="Blockchain network"
),
game.FunctionArgument(
name="min_tvl",
type="number",
description="Minimum TVL threshold"
)
],
config=game.FunctionConfig(
method="get",
url="https://api.example.com/defi/apy",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer {{api_key}}"
},
payload={
"chain": "{{chain}}",
"min_tvl": "{{min_tvl}}"
}
)
)
# Add function to agent (same as saving in GUI)
agent.add_custom_function(defi_apy_function)
Default Functions
In the Sandbox:
- Check boxes for desired functions in function list
- Functions include: wait, post_tweet, reply_tweet, etc.
In the SDK:
# Enable same functions checked in GUI
agent.use_default_twitter_functions([
"wait",
"post_tweet",
"reply_tweet",
"like_tweet"
])
Tweet Enrichment and Response Configuration
In the Sandbox:
- Navigate to “X Setup” > “Tweet Enrichment”
- Enable enrichment
- Configure model parameters
- Set response lengths
In the SDK:
# Configure tweet enrichment (matches GUI settings)
agent.configure_twitter({
"enable_enrichment": True,
"model_settings": {
"model": "meta-llama/llama-2-7b-chat-int8",
"parameters": {
"temperature": 1.1,
"top_k": 52,
"top_p": 0.6,
"repetition_penalty": 1.1
}
}
})
# Configure response generation (matches GUI word limits)
agent.configure_responses({
"response_lengths": {
"first_response": 60,
"second_response": 80,
"third_response": 80,
"fourth_response": 60,
"fifth_response": 60
}
})
Testing and Deployment
Simulation
In the Sandbox:
- Click “Simulate” button
- Review simulation results
- Adjust settings if needed
In the SDK:
# Run simulation with the same settings
simulation_result = agent.simulate_twitter(
session_id="test-session",
duration=3600, # 1 hour simulation
verbose=True
)
# Check simulation results
if simulation_result["status"] == "success":
print(f"Actions taken: {len(simulation_result['actions'])}")
print(f"Quality score: {simulation_result['metrics']['quality']}")
# Deploy if quality meets threshold
if simulation_result["metrics"]["quality"] > 0.8:
agent.deploy()
Common Patterns and Best Practices
Configuration Management
In the Sandbox:
- Use “Settings” section
- Export/Import configurations
- Save backups
In the SDK:
# Export configuration (same as GUI export)
config = agent.export()
with open('agent_config.json', 'w') as f:
json.dump(config, f, indent=2)
# Import configuration (same as GUI import)
with open('agent_config.json', 'r') as f:
config = json.load(f)
agent.load_config(config)
Error Handling
In the Sandbox:
Monitor error messages in the interface
In the SDK:
import logging
# Set up logging (helps track what you see in GUI)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('athena')
try:
agent.deploy()
except game.AgentError as e:
logger.error(f"Deployment failed: {e}")
# Implement fallback strategy
except game.ConfigurationError as e:
logger.error(f"Configuration error: {e}")
# Load backup configuration
Remember that while the Sandbox provides a visual interface, the SDK gives you programmatic control and automation capabilities. Choose the approach that best fits your needs and expertise level.