checkpoint_redis_hil_bugTier 1 · 70% confidence

ai-agents-checkpoint-redis-hil-asyncredissaver-aload-pending-sends-fails-when-res-f07f566b

agent: ai_agents

When does this happen?

IF AsyncRedisSaver._aload_pending_sends fails when resuming HIL workflows with errors: AttributeError: 'Document' object has no attribute 'blob' or 'str' object has no attribute 'decode'.

How others solved it

THEN Override _aload_pending_sends in a custom subclass that: (1) uses '$.blob' instead of 'blob' in the RediSearch return_fields; (2) passes checkpoint_ns directly (not via to_storage_safe_str) in the filter; (3) encodes the type field to bytes before returning tuples. Deploy this subclass as the checkpointer instead of the original AsyncRedisSaver.

class AlphaAsyncRedisSaver(AsyncRedisSaver):
    async def _aload_pending_sends(self, thread_id, checkpoint_ns='', parent_checkpoint_id=''):
        parent_writes_query = FilterQuery(
            filter_expression=(
                (Tag('thread_id') == to_storage_safe_id(thread_id))
                & (Tag('checkpoint_ns') == checkpoint_ns)
                & (Tag('checkpoint_id') == to_storage_safe_id(parent_checkpoint_id))
                & (Tag('channel') == TASKS)
            ),
            return_fields=['type', '$.blob', 'task_path', 'task_id', 'idx'],
            num_results=100,
        )
        res = await self.checkpoint_writes_index.search(parent_writes_query)
        docs = sorted(res.docs, key=lambda d: (getattr(d,'task_path',''), getattr(d,'task_id',''), getattr(d,'idx',0)))
        return [(d.type.encode(), blob) for d in docs if (blob := getattr(d,'$.blob', getattr(d,'blob',None))) is not None]

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics