Description
Problem
POST /threads/search calls _enrich_thread_state for each thread row individually when values or interrupts fields
are needed. Each call triggers a separate list_checkpoints(thread_id) database query.
File: src/agentseek_api/api/threads.py:354-360
states = await asyncio.gather(*[_enrich_thread_state(row.thread_id) for row in rows])
This is acceptable at limit=10, but at limit=1000 it fires 1000 concurrent checkpoint queries, which could overwhelm the
checkpoint store.
Possible solutions
- Batch loading — Fetch checkpoints for multiple threads in a single query
- Opt-in enrichment — Only query checkpoints when select explicitly includes values/interrupts (partially implemented,
but select=None still triggers full enrichment)
- Cap limit — Reduce max limit for state-enriched requests
Description
Problem
POST /threads/searchcalls_enrich_thread_statefor each thread row individually whenvaluesorinterruptsfieldsare needed. Each call triggers a separate
list_checkpoints(thread_id)database query.File:
src/agentseek_api/api/threads.py:354-360This is acceptable at limit=10, but at limit=1000 it fires 1000 concurrent checkpoint queries, which could overwhelm the
checkpoint store.
Possible solutions
but select=None still triggers full enrichment)