feat(llm): implement OpenAI-compatible LLM client with retry #84
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/kronai!84
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/0022-implement-llm-client"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implement a generic OpenAI-compatible HTTP client for LLM communication with configurable endpoint, API key, model, and exponential backoff retry.
Why
Core LLM integration needed for processing job prompts against any OpenAI-compatible API.
Testing
Breaking Changes
None.
Closes #0018
Closes #0019
Closes #0020
Closes #0021
Closes #0022
Automated Review — PR #84
Result: APPROVED
Solid LLM client implementation. Standout: exponential backoff retry, clean stdlib-only approach, thorough retry tests.
LLMErrorwrapping HTTP errors, connection failures, and malformed responses. All paths covered.temperature/max_tokenspromoted to explicit params (nice follow-up from earlier PR #72 feedback).Suggestions (non-blocking)
src/kronai/llm.py:78-88—_retryable/_is_retryablepattern usesobject.__setattr__to monkey-patch a flag onLLMErrorinstances. Consider aRetryableLLMError(LLMError)subclass instead:src/kronai/llm.py:12-14—MAX_RETRIESandBASE_DELAYare hardcoded module constants. Consider making them constructor params (max_retries=4, base_delay=1.0) for testability and configurability.src/kronai/llm.py:42-43—complete()takespromptbutJobConfighas asystem_promptfield. System messages aren't sent to the API. Consider adding an optionalsystem_promptparam when the engine wires everything together, or have the engine prepend it to the prompt.