generated from coulomb/repo-seed
refactor: simplify post-WP-0002 cleanup
- Remove redundant async_execute_prompt overrides from OpenAI/Gemini/OpenRouter adapters (identical to base class default — asyncio import also removed) - Cache prompt.split() result in MockLLMAdapter to avoid double evaluation - Promote deferred LLMBudgetExceededError imports to module level in models.py and adapter.py (no circular dependency) - Auto-populate context dict in LLMBudgetExceededError.__init__ so callers need not pass redundant context= kwarg Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@ import threading
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, Any, Optional
|
||||
|
||||
from llm_connect.exceptions import LLMBudgetExceededError
|
||||
|
||||
|
||||
class BudgetTracker:
|
||||
"""Shared token budget for a call or delegation chain.
|
||||
@@ -36,8 +38,6 @@ class BudgetTracker:
|
||||
|
||||
def consume(self, tokens: int) -> None:
|
||||
"""Record *tokens* as spent. Raises ``LLMBudgetExceededError`` if cap exceeded."""
|
||||
from llm_connect.exceptions import LLMBudgetExceededError # avoid circular at module load
|
||||
|
||||
with self._lock:
|
||||
new_spent = self.spent + tokens
|
||||
if new_spent > self.total:
|
||||
@@ -46,7 +46,6 @@ class BudgetTracker:
|
||||
total=self.total,
|
||||
spent=self.spent,
|
||||
requested=tokens,
|
||||
context={"total": self.total, "spent": self.spent, "requested": tokens},
|
||||
)
|
||||
self.spent = new_spent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user