World Models and Predictive Planning
Agents that simulate future states before acting: mental simulation for AI.
What Is a World Model?
A world model is the agent's internal representation of the environment: what objects exist, what their states are, what rules govern how they change, and what the agent can do to affect them. It is the agent's mental simulation of the world.
Without a world model, the agent can only react to observations. With one, it can predict and plan.
World State Representation
A world state is a snapshot of all relevant facts about the environment at a moment in time. For an IoT agent, this might be current sensor readings and device states. For a software agent, it might be the state of files, APIs, and databases it manages.
from dataclasses import dataclass, field
from datetime import datetime
from typing import Any
@dataclass
class WorldState:
timestamp: str = ''
entities: dict = field(default_factory=dict) # entity_id -> attributes
relationships: list = field(default_factory=list)
agent_position: str = 'idle'
pending_actions: list = field(default_factory=list)
def __post_init__(self):
if not self.timestamp:
self.timestamp = datetime.utcnow().isoformat()
def update_entity(self, entity_id: str, attributes: dict):
current = self.entities.get(entity_id, {})
self.entities[entity_id] = {**current, **attributes}
def snapshot(self) -> dict:
return {
'timestamp': self.timestamp,
'entities': dict(self.entities),
'agent_position': self.agent_position
}
# Example:
world = WorldState()
world.update_entity('server_room', {'temp_c': 22.5, 'humidity': 55})
world.update_entity('hvac_unit_1', {'status': 'off', 'setpoint': 22})
print(world.snapshot())All lessons in this course
- From Assistant to Autonomous Agent
- World Models and Predictive Planning
- Alignment Challenges in Autonomous Agents
- Research Frontiers: AGI and Beyond