feat: add credit verification before agent message endpoints [LET-XXXX] (#9433)
* feat: add credit verification before agent message endpoints
Add credit verification checks to message endpoints to prevent
execution when organizations have insufficient credits.
- Add InsufficientCreditsError exception type
- Add CreditVerificationService that calls step-orchestrator API
- Add credit checks to /agents/{id}/messages endpoints
- Add credit checks to /conversations/{id}/messages endpoint
🐾 Generated with [Letta Code](https://letta.com)
Co-Authored-By: Letta <noreply@letta.com>
* surface error in ade
* do per step instead
* parallel check
* parallel to step
* small fixes
* stage publish api
* fixes
* revert unnecessary frontend changes
* insufficient credits stop reason
---------
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -451,6 +451,16 @@ class AgentFileImportError(Exception):
|
||||
"""Exception raised during agent file import operations"""
|
||||
|
||||
|
||||
class InsufficientCreditsError(LettaError):
|
||||
"""Raised when an organization has no remaining credits."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
message="Insufficient credits to process this request.",
|
||||
details={"error_code": "INSUFFICIENT_CREDITS"},
|
||||
)
|
||||
|
||||
|
||||
class RunCancelError(LettaError):
|
||||
"""Error raised when a run cannot be cancelled."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user