mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-30 03:00:41 -04:00
fix(backend/executor): skip execution tier charge for nested tool calls
execution_usage_cost(0) incorrectly charges 1 credit because 0 % threshold == 0. charge_node_usage passes 0 to _charge_usage to signal "no tier increment", but the modulo check fires at 0. Fix: skip execution_usage_cost entirely when execution_count == 0, preserving the intent that nested tool executions don't count against execution tiers.
This commit is contained in:
@@ -1101,7 +1101,13 @@ class ExecutionProcessor:
|
||||
)
|
||||
total_cost += cost
|
||||
|
||||
cost, usage_count = execution_usage_cost(execution_count)
|
||||
# execution_count=0 is used by charge_node_usage for nested tool calls
|
||||
# which must not be pushed into higher execution-count tiers.
|
||||
# execution_usage_cost(0) would trigger a charge because 0 % threshold == 0,
|
||||
# so skip it entirely when execution_count is 0.
|
||||
cost, usage_count = (
|
||||
execution_usage_cost(execution_count) if execution_count > 0 else (0, 0)
|
||||
)
|
||||
if cost > 0:
|
||||
remaining_balance = db_client.spend_credits(
|
||||
user_id=node_exec.user_id,
|
||||
|
||||
Reference in New Issue
Block a user