Skip to main content

Introduction

Hyperscape integrates ElizaOS to enable AI agents that play the game autonomously. Unlike scripted NPCs, these agents use LLMs to make decisions, set goals, and interact with the world just like human players.
ElizaOS 1.7.0: Hyperscape is compatible with ElizaOS 1.7.0+ with backwards-compatible shims for cross-version support. AI agents connect via the same WebSocket protocol as human players and have full access to all game mechanics.

Plugin Architecture

The @hyperscape/plugin-hyperscape package provides:

Plugin Registration


LLM Autonomy System

As of PR #628, agents use a THINKING+ACTION format that separates reasoning from action selection, making agent behavior transparent and debuggable.

THINKING+ACTION Format

Agents respond with structured reasoning before taking actions:
Benefits:
  • Clear separation of reasoning and decision
  • Debuggable agent behavior (see why it chose an action)
  • Better parsing and error handling
  • Foundation for multi-step reasoning

Target Locking

Agents lock onto combat targets for 30 seconds to prevent target switching:
Behavior:
  • Agent attacks one target until it dies
  • Lock clears when target dies, despawns, or 30s timeout
  • Dramatically improves combat effectiveness

Force Flee Mechanism

Pre-emptive survival check runs BEFORE LLM selection:
Survival instinct overrides LLM decisions to prevent deaths.

Combat Readiness Scoring

New getCombatReadiness() function evaluates combat preparedness:
Factors:
  • Health level (deduct up to 30 points for low health)
  • Weapon equipped (deduct 25 points if no weapon)
  • Food available (deduct 20 points if no food)
Combat goals are scaled down when readiness is low.

Available Actions

The plugin provides 23 actions across 9 categories:

Goal-Oriented Actions

Autonomous Behavior

Movement Actions

Combat Actions

Skill Actions

Inventory Actions

Social Actions

Banking Actions


State Providers

Providers supply game context to the agent’s decision-making. As of PR #628, three new providers enhance LLM decision-making:

New Providers (PR #628)

possibilitiesProvider

Tells the LLM what actions are currently possible:

goalTemplatesProvider

Provides structured goal templates for OSRS beginner flows:
Goal Types:
  • woodcutting, mining, fishing - Gathering skills
  • smithing, firemaking, cooking - Artisan skills
  • combat - Combat training
  • exploration - Discover new areas
  • starter_items - Acquire basic tools

guardrailsProvider

Provides safety constraints and warnings:

Core Providers

goalProvider

Provides current goal and progress tracking.

gameStateProvider

inventoryProvider

nearbyEntitiesProvider

skillsProvider

equipmentProvider

availableActionsProvider


Evaluators

Evaluators assess game state for autonomous decision-making:

Configuration

Environment Variables

ElizaOS 1.7.0: Added support for Ollama plugin (@elizaos/plugin-ollama) for local LLM inference.

Running AI Agents

This starts:
  • Game server on port 5555
  • Client on port 3333
  • ElizaOS runtime on port 4001
  • ElizaOS dashboard on port 4000

Agent Dashboard

Access the agent dashboard at http://localhost:4000 to:
  • View agent status and goals
  • Monitor skill progression and XP gains
  • See current position and nearby locations
  • Control agent behavior (stop/resume goals)
  • Send messages and quick commands
  • Configure API keys and settings
Dashboard Features:
  • Summary Card: Online status, combat level, total level, current goal
  • Goal Panel: Current objective, progress, time estimates, stop/resume controls
  • Skills Panel: All skill levels with XP progress bars and session gains
  • Activity Panel: Recent actions, kills, deaths, gold earned
  • Position Panel: Current zone, nearby POIs, coordinates
  • Quick Action Menu: One-click commands (woodcutting, mining, fishing, combat, pickup, bank, stop, idle)

ElizaOS 1.7 Compatibility

Hyperscape now uses ElizaOS 1.7.0 with backwards-compatible shims for API changes: Key Changes:
  • max_tokensmaxTokens (with fallback for older versions)
  • Updated dependencies: @elizaos/core, @elizaos/plugin-sql, @elizaos/server
  • Added @elizaos/plugin-ollama support for local LLM inference

Agent Dashboard

The agent dashboard provides real-time monitoring and control of AI agents.

Dashboard Features

Agent Summary Card:
  • Online/offline status with uptime
  • Combat level and total level
  • Current goal with progress bar
  • Session statistics
Goal Panel:
  • Current goal description and progress
  • Estimated time to completion
  • XP rate tracking
  • Lock/unlock goal controls
  • Stop button - Immediately halts agent and sets to idle
  • Resume Auto - Resumes autonomous goal selection
  • Recent goals history
Skills Panel:
  • All skill levels with XP progress bars
  • Session XP gains tracking
  • Live updates when viewport is active
Activity Panel:
  • Recent actions feed (combat, skills, items, goals)
  • Session stats (kills, deaths, gold earned, resources gathered)
  • Live activity tracking
Position Panel:
  • Current zone name (Central Haven, Eastern Forest, etc.)
  • Coordinates (X, Y, Z)
  • Nearby points of interest with distances
  • Live position tracking
Quick Action Menu:
  • One-click commands for common tasks
  • Nearby locations (banks, furnaces, trees, fishing spots)
  • Quick commands (woodcutting, mining, fishing, combat, pickup, stop, idle)
  • Available goals
  • Inventory actions (equip, use, drop)

Stop/Resume Goal Control

The dashboard includes robust stop/resume functionality: Stop Goal:
  • Immediately cancels current movement path
  • Sets agent to idle mode
  • Blocks autonomous goal selection
  • Shows “Goals Paused” state in UI
  • Chat commands still work (user can send manual commands)
Resume Auto:
  • Re-enables autonomous goal selection
  • Agent resumes normal behavior
  • Clears paused state
Implementation:
  • POST /api/agents/:agentId/goal/stop - Stops goal and sets paused state
  • POST /api/agents/:agentId/goal/resume - Resumes autonomous behavior
  • goalsPaused flag tracked server-side and synced to plugin
  • Pause state persists across reconnections

Dashboard API Endpoints

Rate Limiting

Dashboard components use polling with retry logic to avoid rate limiting: Polling Intervals:
  • Agent Summary: 10 seconds
  • Goal Panel: 10 seconds
  • Skills Panel: 10 seconds
  • Activity Panel: 10 seconds
  • Position Panel: 5-10 seconds (faster when viewport active)
Retry Logic: Exponential backoff (1s → 2s → 4s) for failed requests.

Spectator Mode

Watch AI agents play in real-time:
  1. Start with bun run dev:ai
  2. Open http://localhost:3333
  3. Click the Dashboard icon
  4. Select an agent to spectate
  5. Observe decision-making in the viewport and activity feed

Agent Architecture Flow

Decision-Making Pipeline

  1. Providers - Gather game context (10 providers)
  2. Compose State - Merge provider data into unified state
  3. Evaluators - Assess situation (5 evaluators)
  4. LLM Decision - Generate THINKING+ACTION response
  5. Parse - Extract reasoning and action name
  6. Validate - Check if action is possible
  7. Execute - Perform action via HyperscapeService
  8. Update - Server sends state changes back
Survival Override: If health < 25% with threats, skip LLM and force FLEE.

Event Handlers

Game events are stored as memories for agent learning:


Detailed Documentation

Actions Reference

Complete reference for all 22 agent actions including movement, combat, skills, inventory, and goals.

Providers Reference

All 7 context providers that supply game state to the LLM for decision-making.