DEV Community

Anton Illarionov
Anton Illarionov

Posted on

Where Does a World Model Fit in Your LLM Stack?

Where Does a World Model Fit in Your LLM Stack?

You have the LLM. You have RAG. You have tools. Something is still missing. Here's where a world model fits.

The Standard LLM Stack (and Its Gaps)

Most production LLM applications look like:

User Input → LLM → Tools → Response
                ↕
            RAG (vector DB)
Enter fullscreen mode Exit fullscreen mode

This works for stateless Q&A. It breaks for agents that:

  • Run for multiple sessions
  • Take consequential actions
  • Need to build on previous work
  • Must avoid repeating actions

Adding a World Model

User Input → LLM → Constitutional Check → Tools → Response
                ↕                              ↕
           World Model (graph)          Execution Log
           ↕           ↑
      Long-term     Action
       memory      tracking
Enter fullscreen mode Exit fullscreen mode

The world model replaces both the vector store and the "hope nothing goes wrong" approach.

What Each Layer Does

RAG / Vector Store:

  • Good for: "What does the documentation say about X?"
  • Bad for: "What did I decide last week about Y?"
  • Fails at: Causal chains, authority checking, deduplication

World Model (Graph):

  • Good for: Session persistence, relational queries, constitutional governance
  • Handles: "What decisions led here?", "Is this agent authorized?", "Already done?"
  • Weak at: Fuzzy semantic search (use RAG for that)

They're complementary, not competitive.

The Three Integration Points

1. Pre-Action Validation

Before any tool call, validate:

verdict = await odei.guardrail_check(
    action=f"calling {tool_name} with {params}",
    severity="medium"
)
if verdict != "APPROVED":
    return handle_escalation(verdict)
Enter fullscreen mode Exit fullscreen mode

2. Context Injection

At session start, inject world model state:

world_state = await odei.query(
    queryType="domain",
    domain="STRATEGY"  # Current active plans
)
system_prompt = f"Current context:
{world_state}

{base_prompt}"
Enter fullscreen mode Exit fullscreen mode

3. Action Logging

After successful tool calls:

await odei.record_action(
    type="tool_execution",
    tool=tool_name,
    params=params,
    result=result,
    timestamp=now()
)
Enter fullscreen mode Exit fullscreen mode

Minimal Integration

Smallest possible addition to your existing stack:

from odei import guardrail_check  # pip install odei-sdk (coming soon)

# Wrap your existing agent's tool calls
def safe_execute(tool, params):
    verdict = guardrail_check(f"execute {tool.__name__} with {params}")
    if verdict.ok:
        return tool(**params)
    raise SafetyViolation(verdict.reason)
Enter fullscreen mode Exit fullscreen mode

Or via MCP — zero code needed:

{"mcpServers": {"odei": {"command": "npx", "args": ["@odei/mcp-server"]}}}
Enter fullscreen mode Exit fullscreen mode

Production Stats

In 2 months of production (ODEI, Jan-Feb 2026):

  • 0 hallucination errors in agent actions
  • 0 duplicate executions
  • 92% task success rate on Virtuals ACP

ODEI: https://api.odei.ai | @elizaos/plugin-odei | MCP: github.com/odei-ai/mcp-odei

Top comments (0)