Skip to content

Grounding in Reality: Ensuring Reasoning Matches Truth

Overview

The Grounding Problem: LLMs can reason about things that don't exist.

Grounding ensures agent reasoning reflects actual reality through explicit feedback from tool results.


The Problem

Agent thinks:     "User has admin rights"
Reality:          User has read-only access
Tool result:      permission_error

Without grounding: Agent ignores error, proceeds anyway
With grounding:    Agent learns, adapts behavior

Grounding Strategies

1. Explicit Validation

class GroundedAgent:
    def execute_action(self, action):
        # Attempt action
        result = tool.call(action)

        # Explicit validation
        if not result['success']:
            # Reality contradicts assumption
            self.update_beliefs(action, result['error'])
            return self.handle_failure(action, result['error'])

        return result

2. Feedback Loops

def grounded_reasoning_loop():
    belief = agent.reason(current_state)
    action = agent.plan(belief)

    # Get real-world feedback
    observation = execute(action)

    # Correct if reality differs
    if observation != belief.expected:
        agent.update_model(observation)
        # Replan based on corrected understanding
        action = agent.plan(agent.reason(current_state))

    return action

3. Reality Reconciliation

def reconcile_with_reality():
    # Agent's model
    agent_state = {
        "user_count": 1000,
        "active_users": 500,
        "system_status": "healthy"
    }

    # Query reality
    real_state = check_system_status()

    # Reconcile differences
    for key in agent_state:
        if agent_state[key] != real_state[key]:
            log_discrepancy(key, agent_state[key], real_state[key])
            agent_state[key] = real_state[key]

    return agent_state

Detecting Hallucinations

class HallucinationDetector:
    def detect(self, agent_claim, tool_result):
        """Detect if agent is hallucinating"""

        if agent_claim['tool'] not in self.available_tools:
            # Tool doesn't exist!
            return True, "Tool doesn't exist"

        if agent_claim['result'] != tool_result['actual']:
            # Reality contradicts claim
            return True, f"Expected {agent_claim['result']}, got {tool_result['actual']}"

        return False, None

Best Practices

  1. Treat tool results as ground truth
  2. Log discrepancies between expectation and reality
  3. Correct beliefs immediately when reality diverges
  4. Monitor hallucination rate as quality metric
  5. Verify critical facts before acting

Last Updated: August 9, 2026