Skip to content

Bug: Surprisal filter format error - should use {"in": [...]} syntax #559

@Fengqx2022

Description

@Fengqx2022

Description

The Surprisal module in src/dreamer/surprisal.py line 264 uses an incorrect filter format when calling get_all_documents().

Problem

# Current code (incorrect)
filters = {"level": levels}

This format is not recognized by the apply_filter function in src/utils/filter.py, which expects:

# Expected format
filters = {"level": {"in": levels}}

Impact

When Surprisal tries to filter observations by level, it returns 0 results, causing:

  • Surprisal computation to fail silently
  • Dream cycle to skip the Surprisal phase
  • No high-surprisal observations are identified

Fix

Change line 264 in src/dreamer/surprisal.py:

# Before
filters = {"level": levels}

# After
filters = {"level": {"in": levels}}

Environment

  • Honcho version: latest (commit from April 2026)
  • Python: 3.11+

Verification

After fix:

docker compose up -d --build deriver
docker exec honcho-deriver-1 python -c "
from src.dreamer.surprisal import get_surprisal_observations
import asyncio
result = asyncio.run(get_surprisal_observations(workspace='test', peer_id='test'))
print(f'Found {len(result)} high-surprisal observations')
"

Should return non-zero count of observations.

Related

This bug was discovered during practical testing with SURPRISAL_ENABLED=true. The fix was verified with a complete Dream cycle that successfully identified 15 high-surprisal observations from 152 total.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions