.windsurf/rules/rig-core.md
Apply these Rig architectural constraints when editing Rust code.
Rig is built on several core principles that all contributions must respect:
Rig uses traits to define provider-agnostic interfaces:
CompletionModel - For text completion/chat modelsEmbeddingModel - For embedding generationVectorStoreIndex - For vector similarity searchTool - For defining callable toolsNew implementations should implement these traits rather than creating parallel abstractions.
Nearly every configurable type uses the builder pattern:
let agent = client
.agent(openai::GPT_5_2)
.preamble("System prompt")
.tool(my_tool)
.temperature(0.8)
.build();
Follow this pattern for any new configurable types.
The client system uses a generic architecture with provider extensions:
pub struct Client<Ext = Nothing, H = reqwest::Client> {
// ...
}
Where Ext is a provider extension defining capabilities and H is the HTTP backend.
Providers declare their capabilities explicitly:
impl<H> Capabilities<H> for MyProviderExt {
type Completion = Capable<CompletionModel<H>>; // Supported
type Embeddings = Nothing; // Not supported
// ...
}
Use Capable<T> for supported features and Nothing for unsupported ones.