D1 and libSQL memory queries fail when an offset is supplied without a limit
What happens
Both SQLite-backed memory adapters accept offset and limit as independent optional fields in ConversationQueryOptions and WorkflowRunQuery. Supplying an offset alone currently produces an OFFSET ? clause without a preceding LIMIT clause. SQLite requires LIMIT before OFFSET, so the database rejects the query instead of returning the requested later rows.
This affects four public query paths:
D1MemoryAdapter.queryConversations({ offset: 2 })D1MemoryAdapter.queryWorkflowRuns({ offset: 2 })LibSQLMemoryAdapter.queryConversations({ offset: 2 })LibSQLMemoryAdapter.queryWorkflowRuns({ offset: 2 })
getConversationsByUserId in each adapter forwards its options to queryConversations, so callers using that convenience method can encounter the same behavior.
How to reproduce
With either adapter configured against a database containing at least three conversations, call:
await memory.queryConversations({ offset: 2 });The generated SQL has this shape:
SELECT * FROM voltagent_conversations
WHERE 1=1
ORDER BY updated_at DESC
OFFSET ?The workflow-run query produces the same trailing OFFSET ? shape after ORDER BY created_at DESC. The bound argument is 2; the parameter value is not the problem. SQLite reports near "OFFSET": syntax error for this statement. The error is reproducible with SQLite's SELECT n FROM t ORDER BY n OFFSET ? on an in-memory table, independently of either adapter.
The same behavior can be seen with a filtered query, for example queryWorkflowRuns({ workflowId: "workflow-1", offset: 2 }). A normal limit plus offset query works because it includes both clauses.
Expected behavior
An offset-only query should skip the requested number of rows in the selected sort order and return all remaining rows. The option types allow this call, and it is useful when a caller knows where to resume reading but does not want to impose a new page size. Both conversation and workflow-run queries should behave the same way for D1 and libSQL.
Why this matters
This is a runtime failure in the memory storage API for a valid combination of optional query fields. An app that uses offset-only pagination to resume a conversation list or workflow-run list cannot read past the first rows. The failure appears only after the query reaches SQLite, which makes it easy to miss when exercising the adapter with both fields supplied.
SQLite supports the intended behavior with LIMIT -1 OFFSET ?: -1 means there is no upper bound on the number of returned rows. The adapters can add that clause only when an offset is present and no explicit limit was supplied. An explicit limit should remain a bound parameter, including 0, and the offset should remain a bound parameter as it is today.
Source: VoltAgent/voltagent