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.
- Completion
Request - Input for a single generation request.
- Hosted
Capabilities - The set of hosted capabilities that the provider advertises.
- Message
- A single message in the conversation history.
- Model
Candidate - A flattened
(provider, model)pair — the smallest projection unit of ACPlist_models. - Model
Capability Overrides - Model-level overrides.
Nonemeans fall back to the provider-levelCapabilitiesfield. - Model
Info - Metadata for a single model.
- Provider
Entry - A provider, the model IDs it exposes, and its session capability configuration.
- Provider
Error - A unified error for provider operation failures.
- Provider
Info - Provider metadata (vendor name, API style, tracing labels, etc.).
- Provider
Registry - A “provider directory” that is materialized at assembly time. The session holds an
Arc<ProviderRegistry>. - Sampling
Params - Sampling parameters.
- Usage
- Token usage statistics. Each field is
Optionto indicate that the provider does not report that field.
Enums§
- Feature
Support - Tri-state feature support declaration.
- Image
Data - Placeholder shape for multimodal image payloads. The exact shape is not yet finalized.
- Message
Content - A piece of content inside a message body.
- Protocol
Id - Protocol identifier. Each variant corresponds one-to-one with a codec in
defect-llm::protocol. - Provider
Activity Kind - The kind of hosted activity. Only appears inside
MessageContent::ProviderActivity. - Provider
Chunk - A single event produced by a provider’s streaming generation.
- Provider
Error Kind - Semantic classification of provider errors.
- Provider
Registry Error - Rate
Limit Scope - Reasoning
Effort - Runtime-level enum for the OpenAI-compatible
reasoning_effortprotocol. - Retry
Action - Retry
Hint - Retry hints for errors.
- Role
- Stop
Reason - Semantic category of generation termination.
- Thinking
Config - Thinking chain configuration. Providers that do not support the concept of a thinking
chain should ignore the budget field of
Enabled, or reportsuper::FeatureSupport::Unsupportedin the capability matrix. - Thinking
Echo - Policy for replaying thinking content.
- Timeout
Phase - Tool
Choice - Tool selection strategy.
- Tool
Result Body - Tool result payload. The codec converts it for the wire during serialization: some
wires only support strings, so they stringify
ToolResultBody::Json. - Tool
Result Content - A single block inside
ToolResultBody::Content. Text follows the same semantics asToolResultBody::Text; images reuse the(mime, data)shape fromMessageContent::Image.
Traits§
- LlmProvider
- LLM provider abstraction.
Type Aliases§
- Provider
Stream - A type-erased stream of events produced by a provider during streaming generation,
enabling direct use with
dyn LlmProvider.