feat(agent): provider-neutral LlmProvider trait + types (#8) - #49
Merged
Conversation
Add core/src/agent/provider with the stable seam between the provider layer (Stream A) and the reasoning loop (Stream C): - LlmProvider trait: async complete(&ChatRequest, api_key) -> ChatResponse; Send+Sync and object-safe for Arc<dyn LlmProvider>. API key passed per call, never stored on the provider. - Neutral types: ChatMessage/Role, ToolDeclaration, ToolCall, GenerationConfig, ChatRequest (+builders), TokenUsage (+Add), ChatResponse, FinishReason, ProviderError. - No reqwest/network dependency; pure data + trait. - 6 unit tests incl. serde round-trip and an in-memory provider proving object-safety (the shape #25/#44 rely on). Re-exported from agent::mod. Closes #8.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #8 — the stable seam between Stream A (providers) and Stream C (the reasoning loop).
What
core/src/agent/provider/mod.rs:LlmProvidertrait (async complete(&ChatRequest, api_key) -> ChatResponse,Send + Sync, object-safe) plus provider-neutral types:ChatMessage/Role,ToolDeclaration,ToolCall,GenerationConfig,ChatRequest(+builders),TokenUsage(+Add),ChatResponse,FinishReason,ProviderError.agent::mod.MVP / Acceptance (#8)
ChatRequestcarries messages, tool/function declarations, gen configChatResponsecarries text, structuredtool_calls, token usagereqwestdependency in this module (pure data + trait)Tests
cargo test -p core agent::→ 21 passed (6 new).Notes
ProviderErroris intentionally minimal here; [A6] Provider error taxonomy + retry/backoff #13 extends it with retry/backoff classification additively.