mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-06 02:41:48 +00:00
fix(run_agent): acquire lock in IterationBudget.used property
The `used` property was reading `self._used` without holding the lock, while `consume()`, `refund()`, and `remaining` all properly acquire `self._lock` before accessing `_used`. This means a concurrent call to `used` during `consume()` or `refund()` could observe a partially- updated value, leading to incorrect iteration budget metrics reported to the gateway, or in extreme cases a ValueError from CPython's list implementation when the internal array resizes during iteration. Fix: acquire the lock in `used` just like `remaining` does. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
64ad7dec0d
commit
fbc477df71
2 changed files with 111 additions and 1 deletions
|
|
@ -304,7 +304,8 @@ class IterationBudget:
|
|||
|
||||
@property
|
||||
def used(self) -> int:
|
||||
return self._used
|
||||
with self._lock:
|
||||
return self._used
|
||||
|
||||
@property
|
||||
def remaining(self) -> int:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue