Skip to main content

LlmBackend

Trait LlmBackend 

Source
pub trait LlmBackend: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn complete(&self, prompt: &str) -> Result<String, LlmError>;

    // Provided method
    fn identity(&self) -> &str { ... }
}
Expand description

One-shot completion: prompt in, raw text out.

Required Methods§

Source

fn name(&self) -> &str

What to call this agent on screen, for a reviewer waiting on it.

A product name, not a command line: “Claude Code”, not claude -p --output-format text --allowed-tools Bash(...),.... The reviewer is waiting to learn which agent is thinking, and the argv answers a different question at four times the width — it overran the splash line the moment the allowlist grew.

The command as it will actually run is still reported where it is the answer: LlmError carries it, because a spawn failure is debugged with the whole argv and nothing less.

Source

fn complete(&self, prompt: &str) -> Result<String, LlmError>

Provided Methods§

Source

fn identity(&self) -> &str

Everything about this backend that could change the grouping, and nothing that could not. The grouping cache key hashes this (ADR 0009).

Separate from name because the two answer different questions. name is what to show a reviewer, so it is a product name. This is what determines the answer, so it is the argv — minus the parts that say where this machine keeps things. Hashing a path put the absolute location of dfr into the key, so a debug build, a release build and two checkouts of one commit each re-ran a four-hundred-second call for an identical class partition, and the worktree-shared cache plan::grouping_cache_dir promises was defeated.

Defaults to name, which is right for any backend whose identity has no environment in it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§