ai-query has three layers. Most confusion disappears once you know which layer you are using.
The Three Layers
Core Generation
Core generation is the raw model loop.Stateful Agents
Agents add identity and memory.Live Turns
A turn is one live execution of an agent.Tools
Tools are typed Python functions the model can call.Storage
Storage belongs to agents, not core generation.Events
There are two event concepts:agent.emit(...)is for application events sent to clients and optionally replayed later.turn.events()is a live execution stream for text, steps, reasoning, completion, and failure.