Skip to main content

Module llm

Module llm 

Source
Expand description

LLM provider abstraction.

The protocol-level types (chunk / request / model / capability / error / provider) now live in defect-core::llm so defect-llm can implement providers without depending on the agent runtime. They are re-exported here so existing defect_agent::llm::* paths keep working.

The registry module stays in this crate: it depends on the session capabilities config (a runtime concern) and is not needed by the provider implementations.

Structs§

Capabilities
Provider-level capability matrix.
CompletionRequest
Input for a single generation request.
HostedCapabilities
The set of hosted capabilities that the provider advertises.
Message
A single message in the conversation history.
ModelCandidate
A flattened (provider, model) pair — the smallest projection unit of ACP list_models.
ModelCapabilityOverrides
Model-level overrides. None means fall back to the provider-level Capabilities field.
ModelInfo
Metadata for a single model.
ProviderEntry
A provider, the model IDs it exposes, and its session capability configuration.
ProviderError
A unified error for provider operation failures.
ProviderInfo
Provider metadata (vendor name, API style, tracing labels, etc.).
ProviderRegistry
A “provider directory” that is materialized at assembly time. The session holds an Arc<ProviderRegistry>.
SamplingParams
Sampling parameters.
Usage
Token usage statistics. Each field is Option to indicate that the provider does not report that field.

Enums§

FeatureSupport
Tri-state feature support declaration.
ImageData
Placeholder shape for multimodal image payloads. The exact shape is not yet finalized.
MessageContent
A piece of content inside a message body.
ProtocolId
Protocol identifier. Each variant corresponds one-to-one with a codec in defect-llm::protocol.
ProviderActivityKind
The kind of hosted activity. Only appears inside MessageContent::ProviderActivity.
ProviderChunk
A single event produced by a provider’s streaming generation.
ProviderErrorKind
Semantic classification of provider errors.
ProviderRegistryError
RateLimitScope
ReasoningEffort
Runtime-level enum for the OpenAI-compatible reasoning_effort protocol.
RetryAction
RetryHint
Retry hints for errors.
Role
StopReason
Semantic category of generation termination.
ThinkingConfig
Thinking chain configuration. Providers that do not support the concept of a thinking chain should ignore the budget field of Enabled, or report super::FeatureSupport::Unsupported in the capability matrix.
ThinkingEcho
Policy for replaying thinking content.
TimeoutPhase
ToolChoice
Tool selection strategy.
ToolResultBody
Tool result payload. The codec converts it for the wire during serialization: some wires only support strings, so they stringify ToolResultBody::Json.
ToolResultContent
A single block inside ToolResultBody::Content. Text follows the same semantics as ToolResultBody::Text; images reuse the (mime, data) shape from MessageContent::Image.

Traits§

LlmProvider
LLM provider abstraction.

Type Aliases§

ProviderStream
A type-erased stream of events produced by a provider during streaming generation, enabling direct use with dyn LlmProvider.