Skip to main content

Module agent

Module agent 

Source
Expand description

Agent layer — retrieval-as-reasoning over a Corpus, driven by a configurable LLM provider. The loop and tools are provider-agnostic; backends (Bedrock / Paddock) are selected by ProviderConfig and gated by cargo features so neither is a mandatory dependency.

Re-exports§

pub use config::ProviderConfig;
pub use config::native_base_available;
pub use harness::QwenHarness;
pub use provider::LlmProvider;
pub use run::run_agent;
pub use run::AgentAnswer;
pub use run::ToolCallLog;
pub use types::Block;
pub use types::Msg;
pub use types::Role;
pub use types::Stop;
pub use types::ToolSpec;
pub use types::Turn;

Modules§

bedrock
Bedrock provider — Claude via the Converse API (tool-use). Translates the neutral message/tool types to Converse blocks and back. Assumes AWS credentials are available via the standard chain.
config
Provider configuration — pick the LLM backend at runtime. Bedrock (Claude) or a local Paddock/OpenAI-compatible server (e.g. Qwen3.5-2B). Each arm is gated by its cargo feature; a disabled backend returns a clear error rather than failing to compile.
harness
Qwen harness — a reliability wrapper around a small local model so it completes the tool-loop.
native
Native in-process LLM inference (pure-Rust [candle]) — runs the tuned Qwen3-1.7B + our shipped LoRA fully offline, with no Python serve_openai.py and no HTTP server. This is the ollama-parity path: one binary, models resolved via crate::paths.
needle
Cactus Needle provider — drive the agent with the 26M, tool-use-native Needle model (encoder- decoder, distilled for function-calling) served by the needle-code torch port. Needle is a single-turn tool selector: given a query string + a tool list, it emits a JSON array of tool calls. We adapt that to the multi-turn LlmProvider contract — the agent loop already re-invokes us with tool results appended, so each call flattens the running conversation into query, POSTs to /generate, and parses the returned tool-call JSON into a Turn.
paddock
Paddock provider — a local OpenAI-compatible server (e.g. Qwen3.5-2B). Speaks POST {base_url}/chat/completions with function/tool calling. Translates the neutral message/tool types to OpenAI chat messages and back.
profile
Auto-profiler: sniff the constrained bitmap and route to the bitmap programs that carry the most information — deterministically, no model in the loop. Needle only supplies constraints; this picks the programs. For each facet we run a breakdown over the anchor (cheap roaring intersections) and score it by support × entropy — a facet that is both well-populated and actually varies is informative; a near-constant or ultra-sparse facet is not. We then surface: the top facets’ distributions, a crosstab of the two best low-cardinality facets (that’s where “for each A, which B” falls out), rank for a high-cardinality entity facet, and s_clusters when structure is dense.
provider
The provider abstraction: any chat model with tool-use, behind one async trait. Bedrock (Claude) and Paddock (local Qwen) both implement it; the agent loop is provider-agnostic.
run
The agent loop — provider-agnostic. Plan → probe (tool calls against the corpus) → synthesise, bounded by max_steps. Records a trace of every tool call for transparency.
synth
Deterministic answer synthesis — render a bitmap-program result (the structured JSON the analytics programs return) into a grounded natural-language answer via a fixed template, with NO model in the loop. This is the default path for small tool-caller drivers (Needle): the model selects the program and arguments, the engine computes the numbers, and we phrase them here — so the answer can never hallucinate figures the corpus doesn’t support. When a synthesis-capable provider (Bedrock / a large OpenAI-compatible model) is configured, the loop uses the model’s prose instead.
tools
The engine tools the agent may call — pure read primitives over a loaded Corpus. The agent plans a question into IKL probes; retrieval is the reasoning (roaring set-algebra), so these three tools (discover schema, discover a facet’s vocabulary, run an IKL query) are enough to answer.
types
Neutral message/tool types the agent loop speaks. Each provider translates these to/from its own wire format (Bedrock Converse blocks; OpenAI/Paddock chat messages).
workflow
The bitmap-workflow DSL. Needle emits a compact workflow in one shot — WHICH constraints to apply to the SPLADE-expanded candidate rows, and WHICH bitmap program to run — and it compiles here to IKL set-algebra over the roaring index. This is the reasoning contract SteelDB drives on: