refactor(llm): clean up provider layer — fix leak, deduplicate, optimize#671
Merged
refactor(llm): clean up provider layer — fix leak, deduplicate, optimize#671
Conversation
…ize (#620) Eliminate Box::leak in CompatibleProvider::name() by changing LlmProvider::name() return type from &'static str to &str. Extract send_with_retry() and SSE stream helpers to remove duplicated retry/parsing logic across Claude and OpenAI providers. Replace double AnyProvider clone in embed_fn with Arc, add with_client() builder for shared reqwest::Client, and cache JsonSchema per TypeId in chat_typed. Closes #633, #634, #635, #636, #637, #638
3732964 to
06ddb0a
Compare
This was
linked to
issues
Feb 19, 2026
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.
Summary
LlmProvider::name()from&'static strto&str, eliminatingBox::leakmemory leak in CompatibleProvider (Change LlmProvider::name() from &'static str to &str #633)send_with_retry()rate-limit retry helper, deduplicating 3 retry loops in Claude provider (Extract rate-limit retry helper in zeph-llm #634)sse_to_chat_stream()helpers shared by Claude and OpenAI SSE parsing (Extract sse_to_chat_stream helper #635)AnyProvider::clone()inembed_fn()with singleArcclone (Eliminate double AnyProvider::clone() in embed_fn() #636)with_client()builder to Claude/OpenAI providers for sharedreqwest::Client(Share single reqwest::Client across provider instances #637)JsonSchemaperTypeIdinchat_typedto avoid per-call generation (Cache JsonSchema per TypeId in chat_typed #638)Net: 14 files changed, +466 -527 lines (all within
zeph-llmcrate).Closes #620, #633, #634, #635, #636, #637, #638
Test plan
cargo +nightly fmt --check— passcargo clippy --workspace -- -D warnings— 0 warningscargo nextest run --workspace --lib --bins— 2016 passed, 9 skipped