Skip to main content

Module query

Module query 

Source
Expand description

Query engine: the core agent loop.

Implements the agentic cycle:

  1. Auto-compact if context nears the window limit
  2. Microcompact stale tool results
  3. Call LLM with streaming
  4. Accumulate response content blocks
  5. Handle errors (prompt-too-long, rate limits, max-output-tokens)
  6. Extract tool_use blocks
  7. Execute tools (concurrent/serial batching)
  8. Inject tool results into history
  9. Repeat from step 1 until no tool_use or max turns

Modules§

source
Query source tagging.

Structs§

NullSink
A no-op stream sink for non-interactive mode.
QueryEngine
The query engine orchestrates the agent loop.
QueryEngineConfig
Configuration for the query engine.

Traits§

StreamSink
Callback for streaming events to the UI.

Functions§

build_system_prompt
Build the system prompt from tool definitions, app state, and memory.